using OTSSignsOrchestrator.Core.Models.DTOs; namespace OTSSignsOrchestrator.Core.Services; /// /// Provisions SAML applications in Authentik and retrieves IdP metadata /// needed to render the Xibo SAML settings-custom.php template. /// public interface IAuthentikService { /// /// Creates an Authentik SAML provider and application for the given Xibo instance, /// then fetches the IdP metadata (entity ID, x509 cert, SSO/SLO URLs). /// If the application already exists (by slug), returns its existing metadata. /// Task ProvisionSamlAsync( string instanceAbbrev, string instanceBaseUrl, CancellationToken ct = default); /// /// Tests the connection to Authentik by fetching the current user. /// Optionally accepts override URL/key for testing before saving. /// Task<(bool Success, string Message)> TestConnectionAsync( string? overrideUrl = null, string? overrideApiKey = null, CancellationToken ct = default); /// /// Returns all available flows from Authentik. /// Task> ListFlowsAsync( string? overrideUrl = null, string? overrideApiKey = null, CancellationToken ct = default); /// /// Returns all certificate keypairs from Authentik. /// Task> ListKeypairsAsync( string? overrideUrl = null, string? overrideApiKey = null, CancellationToken ct = default); /// /// Returns all groups from Authentik, optionally filtered to those with /// at least one member. Used for syncing groups to Xibo instances. /// Task> ListGroupsAsync( string? overrideUrl = null, string? overrideApiKey = null, CancellationToken ct = default); // ───────────────────────────────────────────────────────────────────────── // Customer invitation infrastructure // ───────────────────────────────────────────────────────────────────────── /// /// Creates a group in Authentik with the given name. /// Returns the group PK (UUID string). If a group with that name already exists, returns its PK. /// Task CreateGroupAsync(string groupName, CancellationToken ct = default); /// /// Creates an invitation stage in Authentik. /// Returns the stage PK. If a stage with that name already exists, returns its PK. /// Task CreateInvitationStageAsync(string stageName, bool continueWithoutInvitation = false, CancellationToken ct = default); /// /// Creates an enrollment flow in Authentik with the given name and slug. /// Returns the flow PK (UUID string). If a flow with that slug already exists, returns its PK. /// Task CreateEnrollmentFlowAsync(string name, string slug, CancellationToken ct = default); /// /// Binds a stage to a flow at the specified order. /// Task BindStageToFlowAsync(string flowSlug, string stagePk, int order, CancellationToken ct = default); /// /// Creates an expression policy in Authentik. /// Returns the policy PK. If a policy with that name already exists, returns its PK. /// Task CreateExpressionPolicyAsync(string name, string expression, CancellationToken ct = default); /// /// Binds a policy to a flow stage binding (so it executes when that stage runs). /// Task BindPolicyToFlowStageBoundAsync(string flowStageBindingPk, string policyPk, CancellationToken ct = default); /// /// Binds a policy to a flow (policy/group/user binding tab). /// Task BindPolicyToFlowAsync(string flowSlug, string policyPk, CancellationToken ct = default); /// /// Creates a role in Authentik with the given name. /// Returns the role PK. If a role with that name already exists, returns its PK. /// Task CreateRoleAsync(string roleName, CancellationToken ct = default); /// /// Assigns a set of permissions to a role. /// Permission codenames follow Django format, e.g. "add_invitation", "view_invitation". /// Task AssignPermissionsToRoleAsync(string rolePk, IEnumerable permissionCodenames, CancellationToken ct = default); /// /// Assigns a role to a group so all members of the group inherit the role's permissions. /// Task AssignRoleToGroupAsync(string rolePk, string groupPk, CancellationToken ct = default); /// /// Finds the flow-stage binding PK for a specific stage bound to a flow at a given order. /// Returns null if not found. /// Task GetFlowStageBindingPkAsync(string flowSlug, int order, CancellationToken ct = default); /// /// Looks up a built-in Authentik stage by partial name match (e.g. "default-enrollment-prompt"). /// Returns the stage PK, or null if not found. /// Task FindStageByNameAsync(string nameContains, CancellationToken ct = default); }