@@ -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