Skip to content

Commit

Permalink
Fix problems with localhost cached tokens between issuers.
Browse files Browse the repository at this point in the history
  • Loading branch information
wparad committed Jan 27, 2024
1 parent 9eb9f65 commit 37cc9d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/extensionClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ExtensionClient {
* @return {Promise<Record<string, unknown>>} The user data object.
*/
async getUserIdentity() {
const userData = await this.accessToken && jwtManager.decode(this.accessToken);
const userData = this.accessToken && await jwtManager.decode(this.accessToken);
if (!userData) {
return null;
}
Expand Down
8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ class LoginClient {
if (!userData) {
return null;
}

// We use startsWith because the issuer will be limited to only the authress custom domain FQDN subdomain, the hostUrl could be a specific subdomain subdomain for the tenant.
if (!this.hostUrl.startsWith(userData.iss)) {
this.logger && this.logger.log && this.logger.log({ title: 'Token saved in browser is for a different issuer, discarding', currentHostUrl: this.hostUrl, savedUserData: userData });
userIdentityTokenStorageManager.clear();
return null;
}

userData.userId = userData.sub;
return userData;
}
Expand Down

0 comments on commit 37cc9d2

Please sign in to comment.