/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
* the license and the contributors participating to this project.
*/
namespace OpenIddict.Client.AspNetCore.Bff;
///
/// Provides various settings needed to configure the OpenIddict backend-for-frontend (BFF) components.
///
public sealed class OpenIddictClientAspNetCoreBffOptions
{
///
/// Gets or sets the name of the cookie authentication scheme storing the user session and tokens.
/// If set to , the default authentication/sign-in schemes are used and the
/// automatic token refresh logic is attached to all the cookie authentication schemes.
///
public string? CookieScheme { get; set; }
///
/// Gets or sets a boolean indicating whether the access tokens stored in the authentication cookie
/// should NOT be automatically refreshed when they are about to expire.
///
public bool DisableAutomaticTokenRefresh { get; set; }
///
/// Gets or sets the margin applied to the expiration date of access tokens when determining
/// whether they must be refreshed or renewed. By default, tokens are refreshed 1 minute before they expire.
///
public TimeSpan AccessTokenRefreshMargin { get; set; } = TimeSpan.FromMinutes(1);
///
/// Gets or sets the period during which the result of a refresh token request is kept in memory
/// and returned to concurrent or subsequent requests still carrying the same refresh token
/// (e.g requests sent by the browser before the renewed authentication cookie was received).
/// By default, results are retained for 30 seconds. disables retention.
///
public TimeSpan TokenRefreshResultRetentionPeriod { get; set; } = TimeSpan.FromSeconds(30);
///
/// Gets or sets the name of the header that must be sent by the frontend application
/// when calling the user endpoint and the API endpoints (as an antiforgery measure).
///
public string AntiforgeryHeaderName { get; set; } = OpenIddictClientAspNetCoreBffConstants.Headers.Antiforgery;
///
/// Gets or sets the value of the antiforgery header.
///
public string AntiforgeryHeaderValue { get; set; } = "1";
///
/// Gets or sets the path of the login endpoint.
///
public PathString LoginPath { get; set; } = "/bff/login";
///
/// Gets or sets the path of the logout endpoint.
///
public PathString LogoutPath { get; set; } = "/bff/logout";
///
/// Gets or sets the path of the user endpoint.
///
public PathString UserPath { get; set; } = "/bff/user";
///
/// Gets or sets the path of the back-channel logout endpoint.
///
public PathString BackchannelLogoutPath { get; set; } = "/bff/backchannel-logout";
///
/// Gets or sets the path of the redirection endpoint (login callback). Unless automatic
/// endpoint registration is disabled, this path is added to the redirection endpoint URIs.
///
public PathString RedirectionPath { get; set; } = "/bff/callback/login";
///
/// Gets or sets the path of the post-logout redirection endpoint (logout callback). Unless automatic
/// endpoint registration is disabled, this path is added to the post-logout redirection endpoint URIs.
///
public PathString PostLogoutRedirectionPath { get; set; } = "/bff/callback/logout";
///
/// Gets or sets a boolean indicating whether the redirection and post-logout redirection paths should NOT be
/// automatically added to the OpenIddict client options (and their pass-through mode automatically enabled).
///
public bool DisableAutomaticEndpointRegistration { get; set; }
///
/// Gets or sets the default return URL used when no local return URL was specified.
///
public string DefaultReturnUrl { get; set; } = "/";
///
/// Gets or sets the lifetime of the logout token identifiers kept in memory to prevent replay attacks.
///
public TimeSpan LogoutTokenReplayCacheLifetime { get; set; } = TimeSpan.FromMinutes(5);
}