From b1b012d0654914dd44331276f98d482638dec725 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 21 Feb 2024 12:44:45 +0100 Subject: [PATCH] chore: fix tests and add changeset Signed-off-by: blam --- .changeset/tricky-months-hug.md | 8 ++++++++ .../src/authenticator.test.ts | 4 ++++ .../src/authenticator.test.ts | 10 ++++++++-- plugins/auth-node/api-report.md | 6 +++++- plugins/auth-node/src/proxy/types.ts | 6 +++++- 5 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 .changeset/tricky-months-hug.md diff --git a/.changeset/tricky-months-hug.md b/.changeset/tricky-months-hug.md new file mode 100644 index 0000000000..2f28ec1d63 --- /dev/null +++ b/.changeset/tricky-months-hug.md @@ -0,0 +1,8 @@ +--- +'@backstage/plugin-auth-backend-module-oauth2-proxy-provider': patch +'@backstage/plugin-auth-backend-module-aws-alb-provider': patch +'@backstage/plugin-auth-backend-module-gcp-iap-provider': patch +'@backstage/plugin-auth-node': patch +--- + +Fix issue with `providerInfo` not being set properly for some auth providers, by making `providerInfo` an explicit optional return from `authenticate` diff --git a/plugins/auth-backend-module-aws-alb-provider/src/authenticator.test.ts b/plugins/auth-backend-module-aws-alb-provider/src/authenticator.test.ts index 5f19d800a0..e4700d10dd 100644 --- a/plugins/auth-backend-module-aws-alb-provider/src/authenticator.test.ts +++ b/plugins/auth-backend-module-aws-alb-provider/src/authenticator.test.ts @@ -107,6 +107,10 @@ describe('AwsAlbProvider', () => { expiresInSeconds: mockClaims.exp, accessToken: mockAccessToken, }, + providerInfo: { + accessToken: mockAccessToken, + expiresInSeconds: mockClaims.exp, + }, }); }); }); diff --git a/plugins/auth-backend-module-gcp-iap-provider/src/authenticator.test.ts b/plugins/auth-backend-module-gcp-iap-provider/src/authenticator.test.ts index 5f90d3a379..dfe08a7fe2 100644 --- a/plugins/auth-backend-module-gcp-iap-provider/src/authenticator.test.ts +++ b/plugins/auth-backend-module-gcp-iap-provider/src/authenticator.test.ts @@ -45,7 +45,10 @@ describe('GcpIapProvider', () => { }, ctx, ), - ).resolves.toEqual({ result: { iapToken: { sub: 's', email: 'e' } } }); + ).resolves.toEqual({ + result: { iapToken: { sub: 's', email: 'e' } }, + providerInfo: { iapToken: { sub: 's', email: 'e' } }, + }); }); it('should find custom JWT header', async () => { @@ -66,7 +69,10 @@ describe('GcpIapProvider', () => { }, ctx, ), - ).resolves.toEqual({ result: { iapToken: { sub: 's', email: 'e' } } }); + ).resolves.toEqual({ + result: { iapToken: { sub: 's', email: 'e' } }, + providerInfo: { iapToken: { sub: 's', email: 'e' } }, + }); }); it('should throw if header is missing', async () => { diff --git a/plugins/auth-node/api-report.md b/plugins/auth-node/api-report.md index cf51f0f203..5c8c547442 100644 --- a/plugins/auth-node/api-report.md +++ b/plugins/auth-node/api-report.md @@ -538,7 +538,11 @@ export type ProfileTransform = ( }>; // @public (undocumented) -export interface ProxyAuthenticator { +export interface ProxyAuthenticator< + TContext, + TResult, + TProviderInfo = undefined, +> { // (undocumented) authenticate( options: { diff --git a/plugins/auth-node/src/proxy/types.ts b/plugins/auth-node/src/proxy/types.ts index f127fc5c3f..06f5a145fd 100644 --- a/plugins/auth-node/src/proxy/types.ts +++ b/plugins/auth-node/src/proxy/types.ts @@ -19,7 +19,11 @@ import { Request } from 'express'; import { ProfileTransform } from '../types'; /** @public */ -export interface ProxyAuthenticator { +export interface ProxyAuthenticator< + TContext, + TResult, + TProviderInfo = undefined, +> { defaultProfileTransform: ProfileTransform; initialize(ctx: { config: Config }): TContext; authenticate(