refactor: apply review suggestions

Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2024-09-09 15:14:45 +02:00
parent 527d973410
commit 7ee6d38841
7 changed files with 79 additions and 52 deletions
+3 -2
View File
@@ -14,7 +14,6 @@ import { AwsAlbResult as AwsAlbResult_2 } from '@backstage/plugin-auth-backend-m
import { AzureEasyAuthResult } from '@backstage/plugin-auth-backend-module-azure-easyauth-provider';
import { BackendFeature } from '@backstage/backend-plugin-api';
import { BackstageSignInResult } from '@backstage/plugin-auth-node';
import { bitbucketServerSignInResolvers } from '@backstage/plugin-auth-backend-module-bitbucket-server-provider';
import { CacheService } from '@backstage/backend-plugin-api';
import { CatalogApi } from '@backstage/catalog-client';
import { ClientAuthResponse } from '@backstage/plugin-auth-node';
@@ -443,7 +442,9 @@ export const providers: Readonly<{
}
| undefined,
) => AuthProviderFactory_2;
resolvers: Readonly<bitbucketServerSignInResolvers>;
resolvers: Readonly<{
emailMatchingUserEntityProfileEmail: () => SignInResolver_2<BitbucketServerOAuthResult>;
}>;
}>;
cfAccess: Readonly<{
create: (options: {
@@ -85,5 +85,32 @@ export const bitbucketServer = createAuthProviderIntegration({
signInResolver: adaptLegacyOAuthSignInResolver(options?.signIn?.resolver),
});
},
resolvers: bitbucketServerSignInResolvers,
resolvers: {
/**
* Looks up the user by matching their email to the entity email.
*/
emailMatchingUserEntityProfileEmail:
(): SignInResolver<BitbucketServerOAuthResult> => {
const resolver =
bitbucketServerSignInResolvers.emailMatchingUserEntityProfileEmail();
return async (info, ctx) => {
return resolver(
{
profile: info.profile,
result: {
fullProfile: info.result.fullProfile,
session: {
accessToken: info.result.accessToken,
tokenType: info.result.params.token_type ?? 'bearer',
scope: info.result.params.scope,
expiresInSeconds: info.result.params.expires_in,
refreshToken: info.result.refreshToken,
},
},
},
ctx,
);
};
},
},
});