| | | 1 | | using Microsoft.AspNetCore.Authentication.Certificate; |
| | | 2 | | using Kestrun.Hosting; |
| | | 3 | | |
| | | 4 | | namespace Kestrun.Authentication; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Options for configuring Client Certificate Authentication in Kestrun. |
| | | 8 | | /// </summary> |
| | | 9 | | public class ClientCertificateAuthenticationOptions : CertificateAuthenticationOptions, IOpenApiAuthenticationOptions, I |
| | | 10 | | { |
| | | 11 | | /// <inheritdoc/> |
| | 23 | 12 | | public string? DisplayName { get; set; } |
| | | 13 | | |
| | | 14 | | /// <inheritdoc/> |
| | 26 | 15 | | public bool GlobalScheme { get; set; } |
| | | 16 | | |
| | | 17 | | /// <inheritdoc/> |
| | 29 | 18 | | public string? Description { get; set; } |
| | | 19 | | |
| | | 20 | | /// <inheritdoc/> |
| | 62 | 21 | | public string[] DocumentationId { get; set; } = []; |
| | | 22 | | |
| | | 23 | | /// <inheritdoc/> |
| | 36 | 24 | | public KestrunHost Host { get; set; } = default!; |
| | | 25 | | |
| | | 26 | | /// <inheritdoc/> |
| | 29 | 27 | | public bool Deprecated { get; set; } |
| | | 28 | | |
| | | 29 | | private Serilog.ILogger? _logger; |
| | | 30 | | |
| | | 31 | | /// <inheritdoc/> |
| | | 32 | | public Serilog.ILogger Logger |
| | | 33 | | { |
| | 2 | 34 | | get => _logger ?? (Host is null ? Serilog.Log.Logger : Host.Logger); |
| | 1 | 35 | | set => _logger = value; |
| | | 36 | | } |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// Helper to copy values from a user-supplied ClientCertificateAuthenticationOptions instance |
| | | 40 | | /// to the instance created by the framework inside AddCertificate(). |
| | | 41 | | /// </summary> |
| | | 42 | | /// <param name="target">The target instance to which values will be copied.</param> |
| | | 43 | | public void ApplyTo(ClientCertificateAuthenticationOptions target) |
| | | 44 | | { |
| | | 45 | | // Copy base CertificateAuthenticationOptions properties |
| | 9 | 46 | | target.AllowedCertificateTypes = AllowedCertificateTypes; |
| | 9 | 47 | | target.ChainTrustValidationMode = ChainTrustValidationMode; |
| | 9 | 48 | | target.CustomTrustStore = CustomTrustStore; |
| | 9 | 49 | | target.RevocationFlag = RevocationFlag; |
| | 9 | 50 | | target.RevocationMode = RevocationMode; |
| | 9 | 51 | | target.ValidateCertificateUse = ValidateCertificateUse; |
| | 9 | 52 | | target.ValidateValidityPeriod = ValidateValidityPeriod; |
| | | 53 | | |
| | | 54 | | // Copy event handlers |
| | 9 | 55 | | target.Events = Events; |
| | | 56 | | |
| | | 57 | | // Copy IAuthenticationHostOptions properties |
| | 9 | 58 | | target.Host = Host; |
| | | 59 | | |
| | | 60 | | // OpenAPI / documentation properties (IOpenApiAuthenticationOptions) |
| | 9 | 61 | | target.GlobalScheme = GlobalScheme; |
| | 9 | 62 | | target.Description = Description; |
| | 9 | 63 | | target.DocumentationId = DocumentationId; |
| | 9 | 64 | | target.DisplayName = DisplayName; |
| | 9 | 65 | | target.Deprecated = Deprecated; |
| | 9 | 66 | | } |
| | | 67 | | } |