Skip to content

Commit 3aeaa7b

Browse files
committed
fix creation of auth server metadata url
Signed-off-by: Johannes Tuerk <johannes.tuerk@lissi.id>
1 parent d314c94 commit 3aeaa7b

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/WalletFramework.Oid4Vc/Oid4Vci/Implementations/Oid4VciClientService.cs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -406,21 +406,8 @@ private async Task<AuthorizationServerMetadata> FetchAuthorizationServerMetadata
406406
Uri credentialIssuer = issuerMetadata.CredentialIssuer;
407407

408408
var authServerUrl = issuerMetadata.AuthorizationServers.Match(
409-
servers =>
410-
{
411-
Uri first = servers.First();
412-
return first;
413-
},
414-
() =>
415-
{
416-
string result;
417-
if (string.IsNullOrWhiteSpace(credentialIssuer.AbsolutePath) || credentialIssuer.AbsolutePath == "/")
418-
result = $"{credentialIssuer.GetLeftPart(UriPartial.Authority)}/.well-known/oauth-authorization-server";
419-
else
420-
result = $"{credentialIssuer.GetLeftPart(UriPartial.Authority)}/.well-known/oauth-authorization-server" + credentialIssuer.AbsolutePath.TrimEnd('/');
421-
422-
return new Uri(result);
423-
});
409+
servers => CreateAuthorizationServerMetadataUri(servers.First()),
410+
() => CreateAuthorizationServerMetadataUri(credentialIssuer));
424411

425412
var getAuthServerResponse = await _httpClient.GetAsync(authServerUrl);
426413

@@ -437,4 +424,14 @@ private async Task<AuthorizationServerMetadata> FetchAuthorizationServerMetadata
437424

438425
return authServer;
439426
}
427+
428+
private static Uri CreateAuthorizationServerMetadataUri(Uri authorizationServerUri)
429+
{
430+
string result;
431+
if (string.IsNullOrWhiteSpace(authorizationServerUri.AbsolutePath) || authorizationServerUri.AbsolutePath == "/")
432+
result = $"{authorizationServerUri.GetLeftPart(UriPartial.Authority)}/.well-known/oauth-authorization-server";
433+
else
434+
result = $"{authorizationServerUri.GetLeftPart(UriPartial.Authority)}/.well-known/oauth-authorization-server" + authorizationServerUri.AbsolutePath.TrimEnd('/');
435+
return new Uri(result);
436+
}
440437
}

0 commit comments

Comments
 (0)