Skip to content

Commit c03be56

Browse files
authored
v0.12.1 and check iss
v0.12.1 and check iss
2 parents a083f17 + 36f6420 commit c03be56

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@solid/oidc-rp",
3-
"version": "0.12.0",
3+
"version": "0.12.1",
44
"description": "OpenID Connect Relying Party client library",
55
"main": "./src/index.js",
66
"module": "./src/index.js",

src/AuthenticationResponse.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class AuthenticationResponse {
5151
.then(this.errorResponse)
5252
.then(this.matchRequest)
5353
.then(this.validateStateParam)
54+
.then(this.validateIssParam)
5455
.then(this.validateResponseMode)
5556
.then(this.validateResponseParams)
5657
.then(this.exchangeAuthorizationCode)
@@ -181,6 +182,37 @@ class AuthenticationResponse {
181182
})
182183
}
183184

185+
/**
186+
* validateIssParam
187+
*
188+
* @description
189+
* RFC 9207: OAuth 2.0 Authorization Server Issuer Identification
190+
* Validates the iss parameter in the authorization response, if present.
191+
* The iss parameter helps prevent mix-up attacks by ensuring the response
192+
* came from the expected authorization server.
193+
*
194+
* @param {Object} response
195+
* @returns {Promise}
196+
*/
197+
static validateIssParam (response) {
198+
let {params, rp} = response
199+
200+
// RFC 9207: If iss parameter is present, it MUST match the provider issuer
201+
if (params.iss) {
202+
let expectedIssuer = rp.provider.issuer || rp.provider.url
203+
204+
if (params.iss !== expectedIssuer) {
205+
throw new Error(
206+
`Mismatching issuer in authentication response. Expected: ${expectedIssuer}, Got: ${params.iss}`)
207+
}
208+
}
209+
210+
// Note: RFC 9207 specifies iss SHOULD be present, but we don't enforce it
211+
// for backward compatibility with authorization servers that don't support RFC 9207
212+
213+
return Promise.resolve(response)
214+
}
215+
184216
/**
185217
* validateResponseMode
186218
*

0 commit comments

Comments
 (0)