Fixed a bug where expired cookies would not be refreshed.

Signed-off-by: Hitoshi Kamezaki <kamezaki@ap-com.co.jp>

update
This commit is contained in:
Hitoshi Kamezaki
2024-04-01 14:31:57 +09:00
parent fa512d2eec
commit 7e584d6670
2 changed files with 22 additions and 7 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-app-api': patch
---
Fixed a bug where expired cookies would not be refreshed.
@@ -235,14 +235,24 @@ class DefaultHttpAuthService implements HttpAuthService {
return undefined;
}
const existingCredentials = await this.#auth.authenticate(existingCookie, {
allowLimitedAccess: true,
});
if (!this.#auth.isPrincipal(existingCredentials, 'user')) {
return undefined;
}
try {
const existingCredentials = await this.#auth.authenticate(
existingCookie,
{
allowLimitedAccess: true,
},
);
if (!this.#auth.isPrincipal(existingCredentials, 'user')) {
return undefined;
}
return existingCredentials.expiresAt;
return existingCredentials.expiresAt;
} catch (error) {
if (error.name === 'AuthenticationError') {
return undefined;
}
throw error;
}
}
}