Skip to content

Commit ae8c77e

Browse files
authored
Merge pull request #2136 from amoeller83/issue-2132
fix: config to disable strict issuer validation upon wellknown retrie…
2 parents 66df13e + 553700d commit ae8c77e

File tree

5 files changed

+43
-1
lines changed

5 files changed

+43
-1
lines changed

docs/site/angular-auth-oidc-client/docs/documentation/configuration.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,14 @@ Sets the log level displayed in the console.
446446

447447
Makes it possible to turn the `iss` validation off per configuration. **You should not turn this off!**
448448

449+
### `strictIssuerValidationOnWellKnownRetrievalOff`
450+
451+
452+
- Type: `boolean`
453+
- Required: `false`
454+
455+
Makes it possible to turn the strict issuer validation on well known retrieval off per configuration.
456+
449457
### `historyCleanupOff`
450458

451459
- Type: `boolean`

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

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

274+
it('throws no error if well known issuer does not match authwellknownUrl and validation is disabled', waitForAsync(() => {
275+
const loggerSpy = spyOn(loggerService, 'logError');
276+
const maliciousWellKnown = {
277+
...DUMMY_WELL_KNOWN_DOCUMENT,
278+
issuer: DUMMY_MALICIOUS_URL
279+
};
280+
281+
spyOn(dataService, 'get').and.returnValue(
282+
createRetriableStream(
283+
of(maliciousWellKnown)
284+
)
285+
);
286+
287+
const config = {
288+
configId: 'configId1',
289+
authWellknownEndpointUrl: DUMMY_WELL_KNOWN_DOCUMENT.issuer,
290+
strictIssuerValidationOnWellKnownRetrievalOff: true,
291+
};
292+
293+
service.getWellKnownEndPointsForConfig(config).subscribe({
294+
next: (result) => {
295+
expect(result.issuer).toBe(DUMMY_MALICIOUS_URL);
296+
expect(loggerSpy).not.toHaveBeenCalled();
297+
},
298+
error: (err) => {
299+
fail(err);
300+
},
301+
});
302+
}));
303+
304+
274305
it('should not throws error and logs if well known issuer has a trailing slash compared to authwellknownUrl ', waitForAsync(() => {
275306
const trailingSlashIssuerWellKnown = {
276307
...DUMMY_WELL_KNOWN_DOCUMENT,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class AuthWellKnownDataService {
5353
const wellKnownSuffix = config.authWellknownUrlSuffix || WELL_KNOWN_SUFFIX;
5454
const configuredWellKnownEndpoint = authWellknownEndpointUrl.replace(wellKnownSuffix, "");
5555

56-
if (issuer !== configuredWellKnownEndpoint && issuer !== `${configuredWellKnownEndpoint}/`) {
56+
if (!config.strictIssuerValidationOnWellKnownRetrievalOff && issuer !== configuredWellKnownEndpoint && issuer !== `${configuredWellKnownEndpoint}/`) {
5757
const errorMessage = `Issuer mismatch. Well known issuer ${wellKnownEndpoints.issuer} does not match configured well known url ${authWellknownEndpointUrl}`;
5858

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

projects/angular-auth-oidc-client/src/lib/config/default-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const DEFAULT_CONFIG: OpenIdConfiguration = {
2828
triggerAuthorizationResultEvent: false,
2929
logLevel: LogLevel.Warn,
3030
issValidationOff: false,
31+
strictIssuerValidationOnWellKnownRetrievalOff: false,
3132
historyCleanupOff: false,
3233
maxIdTokenIatOffsetAllowedInSeconds: 120,
3334
disableIatOffsetValidation: false,

projects/angular-auth-oidc-client/src/lib/config/openid-configuration.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ export interface OpenIdConfiguration {
132132
logLevel?: LogLevel;
133133
/** Make it possible to turn off the iss validation per configuration. **You should not turn this off!** */
134134
issValidationOff?: boolean;
135+
/** Skip validation of issuer against well-known url */
136+
strictIssuerValidationOnWellKnownRetrievalOff?: boolean;
135137
/**
136138
* If this is active, the history is not cleaned up on an authorize callback.
137139
* This can be used when the application needs to preserve the history.

0 commit comments

Comments
 (0)