feat(githubAuth): make default scopes configurable
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
---
|
||||
'@backstage/core': minor
|
||||
'@backstage/core-api': minor
|
||||
---
|
||||
|
||||
Updated the `GithubAuth.create` method to configure the default scope of the Github Auth Api. As a result the
|
||||
default scope is configurable when overwriting the Core Api in the app.
|
||||
|
||||
```
|
||||
GithubAuth.create({
|
||||
discoveryApi,
|
||||
oauthRequestApi,
|
||||
defaultScopes: ['read:user', 'repo'],
|
||||
}),
|
||||
```
|
||||
@@ -41,6 +41,7 @@ type CreateOptions = {
|
||||
discoveryApi: DiscoveryApi;
|
||||
oauthRequestApi: OAuthRequestApi;
|
||||
|
||||
defaultScopes?: string[];
|
||||
environment?: string;
|
||||
provider?: AuthProvider & { id: string };
|
||||
};
|
||||
@@ -67,6 +68,7 @@ class GithubAuth implements OAuthApi, SessionApi {
|
||||
environment = 'development',
|
||||
provider = DEFAULT_PROVIDER,
|
||||
oauthRequestApi,
|
||||
defaultScopes = ['read:user'],
|
||||
}: CreateOptions) {
|
||||
const connector = new DefaultAuthConnector({
|
||||
discoveryApi,
|
||||
@@ -89,7 +91,7 @@ class GithubAuth implements OAuthApi, SessionApi {
|
||||
|
||||
const sessionManager = new StaticAuthSessionManager({
|
||||
connector,
|
||||
defaultScopes: new Set(['read:user']),
|
||||
defaultScopes: new Set(defaultScopes),
|
||||
sessionScopes: (session: GithubSession) => session.providerInfo.scopes,
|
||||
});
|
||||
|
||||
|
||||
@@ -96,7 +96,11 @@ export const defaultApis = [
|
||||
oauthRequestApi: oauthRequestApiRef,
|
||||
},
|
||||
factory: ({ discoveryApi, oauthRequestApi }) =>
|
||||
GithubAuth.create({ discoveryApi, oauthRequestApi }),
|
||||
GithubAuth.create({
|
||||
discoveryApi,
|
||||
oauthRequestApi,
|
||||
defaultScopes: ['read:user'],
|
||||
}),
|
||||
}),
|
||||
createApiFactory({
|
||||
api: oktaAuthApiRef,
|
||||
|
||||
Reference in New Issue
Block a user