forked from clinically-au/kinde-authentication
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JwksHelper.cs
40 lines (34 loc) · 932 Bytes
/
JwksHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System.Text.Json;
using Microsoft.IdentityModel.Tokens;
namespace Clinically.Kinde.Authentication;
public static class JwksHelper
{
public static IEnumerable<SecurityKey> LoadKeysFromJson(string json)
{
var jwks = JsonSerializer.Deserialize<Jwks>(json);
return jwks.keys.Select(jwk => new JsonWebKey
{
Kty = jwk.kty,
E = jwk.e,
N = jwk.n,
Kid = jwk.kid,
X5t = jwk.x5t,
Alg = jwk.alg,
Use = jwk.use
});
}
public class Jwks
{
public List<Jwk> keys { get; set; }
}
public class Jwk
{
public string kty { get; set; }
public string use { get; set; }
public string alg { get; set; }
public string kid { get; set; }
public string n { get; set; }
public string e { get; set; }
public string x5t { get; set; }
}
}