Skip to content

Commit bc29675

Browse files
authored
Merge pull request #2124 from syalioune/fix/strictissuer-validation-OIDC-Discovery-samples
fix: Allow trailing slash when comparing OIDC issuer and OIDC discovery URL
2 parents e472681 + e58e6fd commit bc29675

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

projects/angular-auth-oidc-client/src/lib/config/auth-well-known/auth-well-known-data.service.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,28 @@ describe('AuthWellKnownDataService', () => {
271271
});
272272
}));
273273

274+
it('should not throws error and logs if well known issuer has a trailing slash compared to authwellknownUrl ', waitForAsync(() => {
275+
const trailingSlashIssuerWellKnown = {
276+
...DUMMY_WELL_KNOWN_DOCUMENT,
277+
issuer: DUMMY_WELL_KNOWN_DOCUMENT.issuer+"/"
278+
};
279+
280+
spyOn(dataService, 'get').and.returnValue(of(trailingSlashIssuerWellKnown));
281+
282+
const expected: AuthWellKnownEndpoints = {
283+
issuer: DUMMY_WELL_KNOWN_DOCUMENT.issuer+"/",
284+
};
285+
286+
service
287+
.getWellKnownEndPointsForConfig({
288+
configId: 'configId1',
289+
authWellknownEndpointUrl: DUMMY_WELL_KNOWN_DOCUMENT.issuer
290+
})
291+
.subscribe((result) => {
292+
expect(result).toEqual(jasmine.objectContaining(expected));
293+
});
294+
}));
295+
274296
it('should merge the mapped endpoints with the provided endpoints and ignore issuer/authwellknownUrl mismatch', waitForAsync(() => {
275297
const maliciousWellKnown = {
276298
...DUMMY_WELL_KNOWN_DOCUMENT,

projects/angular-auth-oidc-client/src/lib/config/auth-well-known/auth-well-known-data.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ export class AuthWellKnownDataService {
5151
(wellKnownEndpoints) => {
5252
const issuer = wellKnownEndpoints.issuer || "";
5353
const wellKnownSuffix = config.authWellknownUrlSuffix || WELL_KNOWN_SUFFIX;
54-
55-
if (issuer !== authWellknownEndpointUrl.replace(wellKnownSuffix, "")) {
54+
const configuredWellKnownEndpoint = authWellknownEndpointUrl.replace(wellKnownSuffix, "");
55+
56+
if (issuer !== configuredWellKnownEndpoint && issuer !== `${configuredWellKnownEndpoint}/`) {
5657
const errorMessage = `Issuer mismatch. Well known issuer ${wellKnownEndpoints.issuer} does not match configured well known url ${authWellknownEndpointUrl}`;
5758

5859
this.loggerService.logError(config, errorMessage);

0 commit comments

Comments
 (0)