Skip to content
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solid/oidc-rp",
"version": "0.12.0",
"version": "0.12.1",
"description": "OpenID Connect Relying Party client library",
"main": "./src/index.js",
"module": "./src/index.js",
Expand Down
32 changes: 32 additions & 0 deletions src/AuthenticationResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class AuthenticationResponse {
.then(this.errorResponse)
.then(this.matchRequest)
.then(this.validateStateParam)
.then(this.validateIssParam)
.then(this.validateResponseMode)
.then(this.validateResponseParams)
.then(this.exchangeAuthorizationCode)
Expand Down Expand Up @@ -181,6 +182,37 @@ class AuthenticationResponse {
})
}

/**
* validateIssParam
*
* @description
* RFC 9207: OAuth 2.0 Authorization Server Issuer Identification
* Validates the iss parameter in the authorization response, if present.
* The iss parameter helps prevent mix-up attacks by ensuring the response
* came from the expected authorization server.
*
* @param {Object} response
* @returns {Promise}
*/
static validateIssParam (response) {
let {params, rp} = response

// RFC 9207: If iss parameter is present, it MUST match the provider issuer
if (params.iss) {
let expectedIssuer = rp.provider.issuer || rp.provider.url

if (params.iss !== expectedIssuer) {
throw new Error(
`Mismatching issuer in authentication response. Expected: ${expectedIssuer}, Got: ${params.iss}`)
}
}

// Note: RFC 9207 specifies iss SHOULD be present, but we don't enforce it
// for backward compatibility with authorization servers that don't support RFC 9207

return Promise.resolve(response)
}

/**
* validateResponseMode
*
Expand Down