This repository has been archived by the owner on Apr 21, 2022. It is now read-only.
/
OidcJwtBearerOptions.cs
65 lines (59 loc) · 1.69 KB
/
OidcJwtBearerOptions.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authentication.OAuth.Claims;
namespace Hal24k.Auth.OidcJwtBearer
{
/// <summary>
/// Options class provides configuration for the OidcJwtBearer middleware.
/// </summary>
public class OidcJwtBearerOptions : JwtBearerOptions
{
private static string[] deletedClaims = new string[]
{
"nonce",
"aud",
"azp",
"acr",
"amr",
"iss",
"iat",
"nbf",
"exp",
"at_hash",
"c_hash",
"auth_time",
"ipaddr",
"platf",
"ver"
};
private static string[] mappedClaims = new string[]
{
"sub",
"name",
"given_name",
"family_name",
"profile",
"email",
};
/// <summary>
/// Initializes a new instance of the <see cref="OidcJwtBearerOptions"/> class.
/// </summary>
public OidcJwtBearerOptions()
{
ClaimActions = new ClaimActionCollection();
foreach (string deleted in deletedClaims)
{
ClaimActions.DeleteClaim(deleted);
}
// Map query claims
foreach (string mapped in mappedClaims)
{
ClaimActions.MapJsonKey(mapped, mapped);
}
}
/// <summary>
/// Configure how claims will be mapped from the userinfo to the UserPrincipal
/// </summary>
public ClaimActionCollection ClaimActions { get; set; }
}
}