Skip to content

Commit 86bfbfb

Browse files
committed
fix: improve token issuer validation
1 parent 5479a2d commit 86bfbfb

3 files changed

Lines changed: 5 additions & 10 deletions

File tree

packages/auth0/src/api/features/Auth0Idp/Auth0IdpProviderFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Auth0IdpProviderFactoryImpl implements IdpProviderFactory.Interface {
1919
return false;
2020
}
2121

22-
return new URL(issuer).hostname.includes("auth0.com") ?? false;
22+
return new URL(issuer).hostname.endsWith(".auth0.com") ?? false;
2323
}
2424
},
2525
jwksCache

packages/cognito/src/api/features/CognitoIdp/CognitoIdpProviderFactory.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ class CognitoIdpProviderFactoryImpl implements IdpProviderFactory.Interface {
1313
const clientId = String(process.env.COGNITO_CLIENT_ID);
1414

1515
// Cognito issuer format: https://cognito-idp.{region}.amazonaws.com/{userPoolId}
16-
const issuer = `https://cognito-idp.${region}.amazonaws.com/${userPoolId}`;
16+
const expectedIssuer = `https://cognito-idp.${region}.amazonaws.com/${userPoolId}`;
1717

1818
return new OidcIdpProvider(
1919
{
20-
issuer,
20+
issuer: expectedIssuer,
2121
clientId,
2222
config: this.config,
2323
isApplicable: (token: JwtPayload) => {
@@ -26,12 +26,7 @@ class CognitoIdpProviderFactoryImpl implements IdpProviderFactory.Interface {
2626
return false;
2727
}
2828

29-
const url = new URL(issuer);
30-
31-
return (
32-
url.hostname.includes("cognito-idp") ||
33-
url.hostname.includes("amazonaws.com")
34-
);
29+
return issuer === expectedIssuer;
3530
}
3631
},
3732
jwksCache

packages/okta/src/api/features/OktaIdp/OktaIdpProviderFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class OktaIdpProviderFactoryImpl implements IdpProviderFactory.Interface {
1919
return false;
2020
}
2121

22-
return new URL(issuer).hostname.includes("okta.com") ?? false;
22+
return new URL(issuer).hostname.endsWith(".okta.com") ?? false;
2323
}
2424
},
2525
jwksCache

0 commit comments

Comments
 (0)