Skip to content

Commit

Permalink
fix: authts#415 allow to get and process claims when scope does not c…
Browse files Browse the repository at this point in the history
…ontain openid
  • Loading branch information
pamapa committed Mar 15, 2022
1 parent 0d2e402 commit 558319b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/ResponseValidator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ describe("ResponseValidator", () => {
});
});

it("should not run if request was not openid", async () => {
it("should run if request was not openid", async () => {
// arrange
Object.assign(settings, { loadUserInfo: true });
Object.assign(stubResponse, {
Expand All @@ -322,7 +322,7 @@ describe("ResponseValidator", () => {
await subject.validateSigninResponse(stubResponse, stubState);

// assert
expect(subject["_userInfoService"].getClaims).not.toHaveBeenCalled();
expect(subject["_userInfoService"].getClaims).toHaveBeenCalled();
});

it("should not load and merge user info claims when loadUserInfo not configured", async () => {
Expand Down
8 changes: 1 addition & 7 deletions src/ResponseValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,6 @@ export class ResponseValidator {

protected async _processClaims(response: SigninResponse, skipUserInfo = false): Promise<void> {
const logger = this._logger.create("_processClaims");
if (!response.isOpenId) {
logger.debug("response is not OIDC, skipping claims processing");
return;
}
logger.debug("response is OIDC, processing claims", response.profile);
response.profile = this._filterProtocolClaims(response.profile);

if (skipUserInfo || !this._settings.loadUserInfo || !response.access_token) {
Expand All @@ -165,11 +160,10 @@ export class ResponseValidator {
}

logger.debug("loading user info");

const claims = await this._userInfoService.getClaims(response.access_token);
logger.debug("user info claims received from user info endpoint");

if (claims.sub !== response.profile.sub) {
if (response.isOpenId && claims.sub !== response.profile.sub) {
logger.throw(new Error("subject from UserInfo response does not match subject in ID Token"));
}

Expand Down

0 comments on commit 558319b

Please sign in to comment.