fix(auth): use default scope account for Bitbucket auth

Fixes https://github.com/backstage/backstage/issues/22383

The scope `team` does not exist, a list of valid OAuth2 scopes can be
found here:

- https://developer.atlassian.com/cloud/bitbucket/rest/intro/#bitbucket-oauth-2-0-scopes

The `passport-bitbucket-oauth2` package implementing OAuth2 for
Bitbucket under the hood uses the `/2.0/user` API to retrieve the user
information, which requires the `account` scope:

- https://developer.atlassian.com/cloud/bitbucket/rest/api-group-users/#api-user-get
- https://github.com/bithound/passport-bitbucket-oauth2/blob/master/lib/passport-bitbucket/strategy.js#L60

Signed-off-by: Martin Ohmann <martin.ohmann@bonial.com>
This commit is contained in:
Martin Ohmann
2024-01-23 12:00:53 +01:00
parent 086294bda1
commit 7da67ce937
4 changed files with 10 additions and 3 deletions
+7
View File
@@ -0,0 +1,7 @@
---
'@backstage/app-defaults': patch
'@backstage/core-app-api': patch
'@backstage/test-utils': patch
---
Change `defaultScopes` for Bitbucket auth from invalid `team` to `account`.
+1 -1
View File
@@ -224,7 +224,7 @@ export const apis = [
configApi,
discoveryApi,
oauthRequestApi,
defaultScopes: ['team'],
defaultScopes: ['account'],
environment: configApi.getOptionalString('auth.environment'),
}),
}),
@@ -52,7 +52,7 @@ export default class BitbucketAuth {
environment = 'development',
provider = DEFAULT_PROVIDER,
oauthRequestApi,
defaultScopes = ['team'],
defaultScopes = ['account'],
} = options;
return OAuth2.create({
@@ -183,7 +183,7 @@ export const defaultApis = [
configApi,
discoveryApi,
oauthRequestApi,
defaultScopes: ['team'],
defaultScopes: ['account'],
environment: configApi.getOptionalString('auth.environment'),
}),
}),