Skip to content

Commit

Permalink
fix(oidc-service-worker): normalize userinfo endpoint in service work…
Browse files Browse the repository at this point in the history
…er (#1320) (release)

Co-authored-by: Mees van Dongen <mees.vandongen@edsn.nl>
  • Loading branch information
meesvandongen and Mees van Dongen authored Mar 13, 2024
1 parent b911130 commit b7568f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ describe('domains', () => {
expect(getCurrentDatabaseDomain(db, url, trustedDomains)).not.toBeNull();
});

it('will not return null, url is the userinfo endpoint on other domain, default port is set', () => {
db['default'].oidcServerConfiguration!.userInfoEndpoint =
'https://otherdomain.com:443/connect/userinfo';

const url = 'https://otherdomain.com/connect/userinfo';
expect(getCurrentDatabaseDomain(db, url, null)).not.toBeNull();
});

it('will test urls against domains list if accessTokenDomains list is not present', () => {
const trustedDomains: TrustedDomains = {
default: {
Expand Down
4 changes: 1 addition & 3 deletions packages/oidc-client-service-worker/src/utils/domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ export const getDomains = (
return trustedDomain[`${type}Domains`] ?? trustedDomain.domains ?? [];
};



export const getCurrentDatabaseDomain = (
database: Database,
url: string,
Expand Down Expand Up @@ -69,7 +67,7 @@ export const getCurrentDatabaseDomain = (

const domains = getDomains(trustedDomain, 'accessToken');
const domainsToSendTokens = oidcServerConfiguration.userInfoEndpoint
? [oidcServerConfiguration.userInfoEndpoint, ...domains]
? [normalizeUrl(oidcServerConfiguration.userInfoEndpoint), ...domains]
: [...domains];

let hasToSendToken = false;
Expand Down

0 comments on commit b7568f8

Please sign in to comment.