Handle token difference in Microsoft provider

Signed-off-by: Adi Krhan <adikrhan43@gmail.com>
This commit is contained in:
Adi Krhan
2023-03-13 09:23:59 +01:00
parent 87628d47c7
commit e262738b8a
2 changed files with 13 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-auth-backend': patch
---
Handle difference in expiration time between Microsoft session and Backstage session which caused the Backstage token to be invalid during a time frame.
@@ -50,6 +50,8 @@ import {
import { Logger } from 'winston';
import fetch from 'node-fetch';
const BACKSTAGE_SESSION_EXPIRATION = 3600;
type PrivateInfo = {
refreshToken: string;
};
@@ -145,12 +147,17 @@ export class MicrosoftAuthProvider implements OAuthHandlers {
const { profile } = await this.authHandler(result, this.resolverContext);
const expiresInSeconds =
result.params.expires_in === undefined
? BACKSTAGE_SESSION_EXPIRATION
: Math.min(result.params.expires_in, BACKSTAGE_SESSION_EXPIRATION);
const response: OAuthResponse = {
providerInfo: {
idToken: result.params.id_token,
accessToken: result.accessToken,
scope: result.params.scope,
expiresInSeconds: result.params.expires_in,
expiresInSeconds,
},
profile,
};