Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: normalize userinfo endpoint in service worker #1320

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading