using System; using System.Collections.Generic; using Jellyfin.Plugin.SSO_Auth.Api; namespace Jellyfin.Plugin.SSO_Auth.State; /// /// A redacted view of an in-flight authorization state. The PKCE code verifier and the authorization /// URL derived from it are deliberately omitted so that listing flows cannot leak them. /// public class SsoStateInfo { /// /// Gets or sets the OpenID state value. /// public string State { get; set; } /// /// Gets or sets the redirect URI the provider calls back to. /// public string RedirectUri { get; set; } /// /// Gets or sets when the flow started. /// public DateTime Created { get; set; } /// /// Gets or sets a value indicating whether the flow has been validated. /// public bool Valid { get; set; } /// /// Gets or sets the user tied to the flow. /// public string Username { get; set; } /// /// Gets or sets a value indicating whether the user is an administrator. /// public bool Admin { get; set; } /// /// Gets or sets a value indicating whether the flow links an existing account. /// public bool IsLinking { get; set; } /// /// Gets or sets the folders the user is allowed access to. /// public IReadOnlyList Folders { get; set; } /// /// Gets or sets a value indicating whether the user is allowed to view live TV. /// public bool EnableLiveTv { get; set; } /// /// Gets or sets a value indicating whether the user is allowed to manage live TV. /// public bool EnableLiveTvManagement { get; set; } /// /// Gets or sets the user avatar url. /// public string AvatarURL { get; set; } /// /// Projects a stored state onto its redacted view. /// /// The stored state. /// The redacted view. public static SsoStateInfo FromState(TimedAuthorizeState state) { ArgumentNullException.ThrowIfNull(state); return new SsoStateInfo { State = state.State?.State, RedirectUri = state.State?.RedirectUri, Created = state.Created, Valid = state.Valid, Username = state.Username, Admin = state.Admin, IsLinking = state.IsLinking, Folders = state.Folders, EnableLiveTv = state.EnableLiveTv, EnableLiveTvManagement = state.EnableLiveTvManagement, AvatarURL = state.AvatarURL }; } }