Skip to content

Commit 729088b

Browse files
authored
add redirect_uri client_id_prefix validation (#366)
Signed-off-by: Johannes Tuerk <johannes.tuerk@lissi.id>
1 parent 07c9096 commit 729088b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/WalletFramework.Oid4Vc/Oid4Vp/Models/RequestObject.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,13 @@ public static RequestObject ValidateTrustChain(this RequestObject requestObject)
182182
else
183183
throw new InvalidOperationException("Validation of trust chain failed");
184184
}
185-
185+
186+
public static RequestObject ValidateClientIdPrefix(this RequestObject requestObject) =>
187+
requestObject.ClientIdScheme.Value == ClientIdScheme.ClientIdSchemeValue.RedirectUri
188+
&& requestObject.ToAuthorizationRequest().ResponseUri != requestObject.ClientId
189+
? throw new InvalidOperationException("When client_id_prefix is 'redirect_uri', the response_uri must match the client_id")
190+
: requestObject;
191+
186192
internal static List<X509Certificate> GetCertificates(this RequestObject requestObject)
187193
{
188194
var x5C = ((JwtSecurityToken)requestObject).Header.X5c;

src/WalletFramework.Oid4Vc/Oid4Vp/Services/AuthorizationRequestService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ private async Task<Validation<AuthorizationRequestCancellation, RequestObject>>
7070
.WithX509()
7171
.WithClientMetadata(clientMetadataOption),
7272
RedirectUri => requestObject
73+
.ValidateClientIdPrefix()
7374
.WithClientMetadata(clientMetadataOption),
7475
//TODO: Remove Did in the future (kept for now for compatibility)
7576
Did => requestObject

0 commit comments

Comments
 (0)