| | | 1 | | using ArturRios.Util.WebApi.Security.Enums; |
| | | 2 | | |
| | | 3 | | namespace ArturRios.Util.WebApi.Security.Configuration; |
| | | 4 | | |
| | | 5 | | /// <summary>Consolidated options controlling how <c>AuthenticationMiddleware</c> reads and validates the request token. |
| | | 6 | | public class AuthenticationOptions |
| | | 7 | | { |
| | | 8 | | /// <summary>Where the token is read from. Defaults to <see cref="TokenSource.Header"/>.</summary> |
| | 25 | 9 | | public TokenSource Source { get; set; } = TokenSource.Header; |
| | | 10 | | |
| | | 11 | | /// <summary>The cookie name used when <see cref="Source"/> is <see cref="TokenSource.Cookie"/> or <see cref="TokenS |
| | 89 | 12 | | public string CookieName { get; set; } = "access_token"; |
| | | 13 | | |
| | | 14 | | /// <summary>Whether the app's own HMAC JWT is accepted. Defaults to <see langword="true"/>.</summary> |
| | 104 | 15 | | public bool EnableJwt { get; set; } = true; |
| | | 16 | | |
| | | 17 | | /// <summary>Whether Google ID tokens are accepted. Defaults to <see langword="false"/>. Requires <see cref="GoogleC |
| | 41 | 18 | | public bool EnableGoogle { get; set; } |
| | | 19 | | |
| | | 20 | | /// <summary>How the user is resolved for a valid app JWT. Defaults to <see cref="JwtValidationMode.ClaimsOnly"/>.</ |
| | 50 | 21 | | public JwtValidationMode JwtMode { get; set; } = JwtValidationMode.ClaimsOnly; |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Whether an app JWT must carry an <c>iss</c> claim equal (ordinal) to <c>JwtConfiguration.Issuer</c>. |
| | | 25 | | /// Defaults to <see langword="false"/>: only the signature is checked, as before 5.2.0. Turn it on when the |
| | | 26 | | /// signing key is shared with another issuer, so its tokens are not accepted here. When on, a blank |
| | | 27 | | /// <c>JwtConfiguration.Issuer</c> fails the application's startup. |
| | | 28 | | /// </summary> |
| | 125 | 29 | | public bool ValidateIssuer { get; set; } |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// Whether an app JWT must list <c>JwtConfiguration.Audience</c> (ordinal) among its <c>aud</c> claims. |
| | | 33 | | /// Defaults to <see langword="false"/>: only the signature is checked, as before 5.2.0. Turn it on when the |
| | | 34 | | /// signing key is shared by several audiences, so a token minted for one is not accepted by another. When on, |
| | | 35 | | /// a blank <c>JwtConfiguration.Audience</c> fails the application's startup. |
| | | 36 | | /// </summary> |
| | 108 | 37 | | public bool ValidateAudience { get; set; } |
| | | 38 | | |
| | | 39 | | /// <summary>The accepted Google OAuth client IDs (token audiences). Required when <see cref="EnableGoogle"/> is <se |
| | 85 | 40 | | public IList<string> GoogleClientIds { get; set; } = new List<string>(); |
| | | 41 | | } |