#nullable enable using System.Collections.Generic; using System.Security.Claims; using API.Entities.Enums; namespace API.DTOs.Settings; /// /// All configuration regarding OIDC /// /// This class is saved as a JsonObject in the DB, assign default values to prevent unexpected NPE public sealed record OidcConfigDto: OidcPublicConfigDto { /// /// Optional OpenID Connect Authority URL. Not managed in DB. Managed in appsettings.json and synced to DB. /// public string Authority { get; set; } = string.Empty; /// /// Optional OpenID Connect ClientId, defaults to kavita. Not managed in DB. Managed in appsettings.json and synced to DB. /// public string ClientId { get; set; } = string.Empty; /// /// Optional OpenID Connect Secret. Not managed in DB. Managed in appsettings.json and synced to DB. /// public string Secret { get; set; } = string.Empty; /// /// If true, auto creates a new account when someone logs in via OpenID Connect /// public bool ProvisionAccounts { get; set; } = false; /// /// Require emails to be verified by the OpenID Connect provider when creating accounts on login /// public bool RequireVerifiedEmail { get; set; } = true; /// /// Overwrite Kavita roles, libraries and age rating with OpenIDConnect provided roles on log in. /// public bool SyncUserSettings { get; set; } = false; /// /// A prefix that all roles Kavita checks for during sync must have /// public string RolesPrefix { get; set; } = string.Empty; /// /// The JWT claim roles are mapped under, defaults to /// public string RolesClaim { get; set; } = ClaimTypes.Role; /// /// Custom scopes Kavita should request from your OIDC provider /// /// Advanced setting public List CustomScopes { get; set; } = []; // Default values used when SyncUserSettings is false #region Default user settings public List DefaultRoles { get; set; } = []; public List DefaultLibraries { get; set; } = []; public AgeRating DefaultAgeRestriction { get; set; } = AgeRating.Unknown; public bool DefaultIncludeUnknowns { get; set; } = false; #endregion /// /// Returns true if the has been set /// public bool Enabled => !string.IsNullOrEmpty(Authority); }