Skip to content

Commit de8b5e8

Browse files
committed
fix: jwks string
1 parent 3862101 commit de8b5e8

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/NetDevPack.Security.JwtExtensions/JwkOptions.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ namespace NetDevPack.Security.JwtExtensions
44
{
55
public class JwkOptions
66
{
7+
public JwkOptions() { }
78
public JwkOptions(string jwksUri, string issuer = null, TimeSpan? cacheTime = null, string audience = null)
89
{
9-
JwksUri = new Uri(jwksUri);
10-
Issuer = issuer ?? $"{JwksUri.Scheme}://{JwksUri.Authority}";
10+
JwksUri = jwksUri;
11+
var jwks = new Uri(jwksUri);
12+
Issuer = issuer ?? $"{jwks.Scheme}://{jwks.Authority}";
1113
KeepFor = cacheTime ?? TimeSpan.FromMinutes(15);
1214
Audience = audience;
1315
}
14-
public string Issuer { get; }
15-
public Uri JwksUri { get; }
16-
public TimeSpan KeepFor { get; }
17-
public string Audience { get; }
16+
public string Issuer { get; set; }
17+
public string JwksUri { get; set; }
18+
public TimeSpan KeepFor { get; set; }
19+
public string Audience { get; set; }
1820
}
1921
}

src/NetDevPack.Security.JwtExtensions/JwksExtension.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Net.Http;
1+
using System.Net.Http;
42
using Microsoft.AspNetCore.Authentication.JwtBearer;
53
using Microsoft.IdentityModel.Protocols;
64
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
@@ -18,7 +16,7 @@ public static void SetJwksOptions(this JwtBearerOptions options, JwkOptions jwkO
1816
};
1917

2018
options.ConfigurationManager = new ConfigurationManager<OpenIdConnectConfiguration>(
21-
jwkOptions.JwksUri.OriginalString,
19+
jwkOptions.JwksUri,
2220
new JwksRetriever(),
2321
new HttpDocumentRetriever(httpClient) { RequireHttps = options.RequireHttpsMetadata });
2422

0 commit comments

Comments
 (0)