Merge pull request #4465 from n2ygk/config_oauth_scope
Add configurable OAuth 2.0 scopes
This commit is contained in:
Vendored
+7
-1
@@ -58,7 +58,13 @@ export interface Config {
|
||||
development: { [key: string]: string };
|
||||
};
|
||||
oauth2?: {
|
||||
development: { [key: string]: string };
|
||||
development: {
|
||||
clientId: string;
|
||||
clientSecret: string;
|
||||
authorizationUrl: string;
|
||||
tokenUrl: string;
|
||||
scope?: string;
|
||||
};
|
||||
};
|
||||
oidc?: {
|
||||
development: { [key: string]: string };
|
||||
|
||||
@@ -44,6 +44,7 @@ type PrivateInfo = {
|
||||
export type OAuth2AuthProviderOptions = OAuthProviderOptions & {
|
||||
authorizationUrl: string;
|
||||
tokenUrl: string;
|
||||
scope?: string;
|
||||
};
|
||||
|
||||
export class OAuth2AuthProvider implements OAuthHandlers {
|
||||
@@ -58,6 +59,7 @@ export class OAuth2AuthProvider implements OAuthHandlers {
|
||||
authorizationURL: options.authorizationUrl,
|
||||
tokenURL: options.tokenUrl,
|
||||
passReqToCallback: false as true,
|
||||
scope: options.scope,
|
||||
},
|
||||
(
|
||||
accessToken: any,
|
||||
@@ -168,6 +170,7 @@ export const createOAuth2Provider: AuthProviderFactory = ({
|
||||
const callbackUrl = `${globalConfig.baseUrl}/${providerId}/handler/frame`;
|
||||
const authorizationUrl = envConfig.getString('authorizationUrl');
|
||||
const tokenUrl = envConfig.getString('tokenUrl');
|
||||
const scope = envConfig.getOptionalString('scope');
|
||||
|
||||
const provider = new OAuth2AuthProvider({
|
||||
clientId,
|
||||
@@ -175,6 +178,7 @@ export const createOAuth2Provider: AuthProviderFactory = ({
|
||||
callbackUrl,
|
||||
authorizationUrl,
|
||||
tokenUrl,
|
||||
scope,
|
||||
});
|
||||
|
||||
return OAuthAdapter.fromConfig(globalConfig, provider, {
|
||||
|
||||
Reference in New Issue
Block a user