| | | 1 | | using System.Security.Claims; |
| | | 2 | | using Kestrun.Claims; |
| | | 3 | | using Microsoft.AspNetCore.Authentication.JwtBearer; |
| | | 4 | | using Microsoft.IdentityModel.Tokens; |
| | | 5 | | |
| | | 6 | | namespace Kestrun.Authentication; |
| | | 7 | | |
| | | 8 | | |
| | | 9 | | /// <summary> |
| | | 10 | | /// Provides options for JWT authentication, including claim policies and custom claim issuance. |
| | | 11 | | /// </summary> |
| | | 12 | | public class JwtAuthenticationOptions : JwtBearerOptions, IClaimsCommonOptions |
| | | 13 | | { |
| | | 14 | | /// <summary> |
| | | 15 | | /// Gets or sets the token validation parameters. |
| | | 16 | | /// </summary> |
| | 2 | 17 | | public TokenValidationParameters? ValidationParameters { get; set; } |
| | | 18 | | |
| | | 19 | | /// <summary> |
| | | 20 | | /// Gets or sets the claim policy. |
| | | 21 | | /// </summary> |
| | 2 | 22 | | public ClaimPolicyConfig? ClaimPolicy { get; set; } |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// After credentials are valid, this is called to add extra Claims. |
| | | 26 | | /// Parameters: HttpContext, username → IEnumerable of extra claims. |
| | | 27 | | /// </summary> |
| | 3 | 28 | | public Func<HttpContext, string, Task<IEnumerable<Claim>>>? IssueClaims { get; set; } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Settings for the claims issuing code, if using a script. |
| | | 32 | | /// </summary> |
| | | 33 | | /// <remarks> |
| | | 34 | | /// This allows you to specify the language, code, and additional imports/refs for claims issuance. |
| | | 35 | | /// </remarks> |
| | 7 | 36 | | public AuthenticationCodeSettings IssueClaimsCodeSettings { get; set; } = new(); |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// Gets or sets the claim policy configuration. |
| | | 40 | | /// </summary> |
| | | 41 | | /// <remarks> |
| | | 42 | | /// This allows you to define multiple authorization policies based on claims. |
| | | 43 | | /// Each policy can specify a claim type and allowed values. |
| | | 44 | | /// </remarks> |
| | 2 | 45 | | public ClaimPolicyConfig? ClaimPolicyConfig { get; set; } |
| | | 46 | | } |