auth-backend: track backstage session expiration separately
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -37,7 +37,7 @@ export function adaptLegacyOAuthHandler(
|
||||
scope: result.session.scope,
|
||||
id_token: result.session.idToken,
|
||||
token_type: result.session.tokenType,
|
||||
expires_in: result.session.expiresInSeconds,
|
||||
expires_in: result.session.expiresInSeconds!,
|
||||
},
|
||||
},
|
||||
ctx,
|
||||
|
||||
@@ -39,7 +39,7 @@ export function adaptLegacyOAuthSignInResolver(
|
||||
scope: input.result.session.scope,
|
||||
id_token: input.result.session.idToken,
|
||||
token_type: input.result.session.tokenType,
|
||||
expires_in: input.result.session.expiresInSeconds,
|
||||
expires_in: input.result.session.expiresInSeconds!,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -30,6 +30,10 @@ describe('MicrosoftAuthProvider', () => {
|
||||
const state = Buffer.from(
|
||||
`nonce=${encodeURIComponent(nonce)}&env=development`,
|
||||
).toString('hex');
|
||||
const mockBackstageToken = `header.${Buffer.from(
|
||||
JSON.stringify({ sub: 'user:default/mock' }),
|
||||
'utf8',
|
||||
).toString('base64')}.backstage`;
|
||||
|
||||
const server = setupServer();
|
||||
const microsoftApi = new FakeMicrosoftAPI();
|
||||
@@ -64,10 +68,9 @@ describe('MicrosoftAuthProvider', () => {
|
||||
resolverContext: {
|
||||
issueToken: jest.fn(),
|
||||
findCatalogUser: jest.fn(),
|
||||
signInWithCatalogUser: _ =>
|
||||
Promise.resolve({
|
||||
token: 'header.e30K.backstage',
|
||||
}),
|
||||
signInWithCatalogUser: async _ => ({
|
||||
token: mockBackstageToken,
|
||||
}),
|
||||
} as AuthResolverContext,
|
||||
}) as AuthProviderRouteHandlers;
|
||||
|
||||
@@ -209,8 +212,12 @@ describe('MicrosoftAuthProvider', () => {
|
||||
displayName: 'Conrad',
|
||||
},
|
||||
backstageIdentity: {
|
||||
token: 'header.e30K.backstage',
|
||||
identity: { type: 'user', ownershipEntityRefs: [] },
|
||||
token: mockBackstageToken,
|
||||
identity: {
|
||||
type: 'user',
|
||||
userEntityRef: 'user:default/mock',
|
||||
ownershipEntityRefs: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
@@ -330,8 +337,12 @@ describe('MicrosoftAuthProvider', () => {
|
||||
displayName: 'Conrad',
|
||||
},
|
||||
backstageIdentity: {
|
||||
token: 'header.e30K.backstage',
|
||||
identity: { type: 'user', ownershipEntityRefs: [] },
|
||||
token: mockBackstageToken,
|
||||
identity: {
|
||||
type: 'user',
|
||||
userEntityRef: 'user:default/mock',
|
||||
ownershipEntityRefs: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
@@ -430,7 +441,7 @@ describe('MicrosoftAuthProvider', () => {
|
||||
expect(response.json).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
backstageIdentity: expect.objectContaining({
|
||||
token: 'header.e30K.backstage',
|
||||
token: mockBackstageToken,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user