Use StaticAuthSessionManager for Github

This commit is contained in:
Marcus Eide
2020-06-01 12:07:58 +02:00
parent d3055d4321
commit 438bdba2cf
3 changed files with 18 additions and 49 deletions
@@ -19,7 +19,6 @@ import { Strategy as GithubStrategy } from 'passport-github2';
import {
executeFrameHandlerStrategy,
executeRedirectStrategy,
executeRefreshTokenStrategy,
} from '../PassportStrategyHelper';
import {
OAuthProviderHandlers,
@@ -37,23 +36,13 @@ export class GithubAuthProvider implements OAuthProviderHandlers {
this.providerConfig = providerConfig;
this._strategy = new GithubStrategy(
{ ...this.providerConfig.options },
(
accessToken: any,
refreshToken: any,
params: any,
profile: any,
done: any,
) => {
done(
undefined,
{
profile,
accessToken,
scope: 'user', // params.scope is an empty string here for some reason, so hardcoding for now
expiresInSeconds: params.expires_in,
},
{ refreshToken },
);
(accessToken: any, _: any, params: any, profile: any, done: any) => {
done(undefined, {
profile,
accessToken,
scope: params.scope,
expiresInSeconds: params.expires_in,
});
},
);
}
@@ -67,18 +56,4 @@ export class GithubAuthProvider implements OAuthProviderHandlers {
): Promise<{ user: AuthInfoBase; info: AuthInfoPrivate }> {
return await executeFrameHandlerStrategy(req, this._strategy);
}
async refresh(refreshToken: string, scope: string): Promise<AuthInfoBase> {
const { accessToken, params } = await executeRefreshTokenStrategy(
this._strategy,
refreshToken,
scope,
);
return {
accessToken,
expiresInSeconds: params.expires_in,
scope: params.scope,
};
}
}