Skip to content

Commit

Permalink
Merge pull request #23915 from apc-kamezaki/feature/handle-error-tech…
Browse files Browse the repository at this point in the history
…docs-cookie

fixed bug the treat as same as no cookie if existing cookie vas invalid.
  • Loading branch information
Rugvip committed Apr 2, 2024
2 parents 1cbc081 + 7e584d6 commit 89a5b69
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/giant-olives-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage/backend-app-api': patch
---

Fixed a bug where expired cookies would not be refreshed.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit 89a5b69

Please sign in to comment.