Merge pull request #24185 from nikolaik/nikolaik/gcp-iap-user-id

feat(gcp-iap): Add user id annotation sign-in resolver
This commit is contained in:
Patrik Oldsberg
2024-04-16 12:31:24 +02:00
committed by GitHub
3 changed files with 26 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-auth-backend-module-gcp-iap-provider': patch
---
Add user id annotation sign-in resolver
@@ -37,6 +37,10 @@ export namespace gcpIapSignInResolvers {
GcpIapResult,
unknown
>;
const idMatchingUserEntityAnnotation: SignInResolverFactory<
GcpIapResult,
unknown
>;
}
// @public
@@ -46,4 +46,21 @@ export namespace gcpIapSignInResolvers {
};
},
});
/**
* Looks up the user by matching their user ID to the `google.com/user-id` annotation.
*/
export const idMatchingUserEntityAnnotation = createSignInResolverFactory({
create() {
return async (info: SignInInfo<GcpIapResult>, ctx) => {
const userId = info.result.iapToken.sub.split(':')[1];
return ctx.signInWithCatalogUser({
annotations: {
'google.com/user-id': userId,
},
});
};
},
});
}