Merge pull request #28892 from benjidotsh/auth/bitbucket-persist

feat(auth): enable persistency of scopes for Bitbucket Cloud
This commit is contained in:
Vincenzo Scamporlino
2025-03-27 22:13:21 +01:00
committed by GitHub
6 changed files with 17 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-auth-backend-module-bitbucket-provider': patch
---
Enabled persistency of scopes for Bitbucket Cloud.
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/integration-react': patch
---
Added scope `project` for Bitbucket Cloud.
@@ -129,7 +129,7 @@ describe('ScmAuth', () => {
await expect(
bitbucketAuth.getCredentials({ url: 'http://example.com' }),
).resolves.toMatchObject({
token: 'account team pullrequest snippet issue',
token: 'account team pullrequest snippet issue project',
});
await expect(
bitbucketAuth.getCredentials({
@@ -138,7 +138,7 @@ describe('ScmAuth', () => {
}),
).resolves.toMatchObject({
token:
'account team pullrequest snippet issue pullrequest:write snippet:write issue:write',
'account team pullrequest snippet issue project pullrequest:write snippet:write issue:write',
});
});
@@ -195,7 +195,8 @@ describe('ScmAuth', () => {
},
}),
).resolves.toMatchObject({
token: 'account team pullrequest snippet issue snippet:write issue:write',
token:
'account team pullrequest snippet issue project snippet:write issue:write',
});
});
@@ -239,6 +239,7 @@ export class ScmAuth implements ScmAuthApi {
'pullrequest',
'snippet',
'issue',
'project',
];
const repoWriteScopes = options?.scopeMapping?.repoWrite ?? [
'pullrequest:write',
@@ -28,6 +28,7 @@ export const bitbucketAuthenticator = createOAuthAuthenticator({
PassportOAuthAuthenticatorHelper.defaultProfileTransform,
scopes: {
required: ['account'],
persist: true,
},
initialize({ callbackUrl, config }) {
const clientID = config.getString('clientId');
@@ -73,6 +73,7 @@ describe('authModuleBitbucketProvider', () => {
expect(decodeOAuthState(startUrl.searchParams.get('state')!)).toEqual({
env: 'development',
nonce: decodeURIComponent(nonceCookie.value),
scope: 'account',
});
});
});