From 8b8b1d23aef38e7908b7a2477a1f924e560e18c3 Mon Sep 17 00:00:00 2001 From: Adam Kunicki Date: Wed, 4 Oct 2023 10:14:02 -0700 Subject: [PATCH] auth-node: Refresh handler not returning persisted scope in response The refresh handler is returning an empty scope if scope was previously saved in a cookie. The session is successfully refreshed but the client receives a response without the scope it requested, prompting a new login. Resolves #20322 Signed-off-by: Adam Kunicki --- .changeset/stale-stingrays-explode.md | 5 +++++ plugins/auth-node/src/oauth/createOAuthRouteHandlers.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/stale-stingrays-explode.md diff --git a/.changeset/stale-stingrays-explode.md b/.changeset/stale-stingrays-explode.md new file mode 100644 index 0000000000..b8b66b8398 --- /dev/null +++ b/.changeset/stale-stingrays-explode.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-auth-node': patch +--- + +Fixed cookie persisted scope not returned in OAuth refresh handler response. diff --git a/plugins/auth-node/src/oauth/createOAuthRouteHandlers.ts b/plugins/auth-node/src/oauth/createOAuthRouteHandlers.ts index 165d7ce6b3..a0735e3ba0 100644 --- a/plugins/auth-node/src/oauth/createOAuthRouteHandlers.ts +++ b/plugins/auth-node/src/oauth/createOAuthRouteHandlers.ts @@ -320,7 +320,9 @@ export function createOAuthRouteHandlers( providerInfo: { idToken: result.session.idToken, accessToken: result.session.accessToken, - scope: result.session.scope, + scope: authenticator.shouldPersistScopes + ? scope + : result.session.scope, expiresInSeconds: result.session.expiresInSeconds, }, };