string CookieScheme { get; set; }
Source
Gets or sets the cookie authentication scheme name.
Configures return-url validation for AppSurface OIDC passive prompt helpers.
The initial package only allows local app-relative return targets. It does not URL-decode, redirect, challenge, or call an identity provider.
AppSurfaceOidcReturnUrlOptions AllowLocalOnly()
Requires prompt targets to be local app-relative paths.
The current options instance for chaining.
string? Normalize(string? targetPath, string parameterName)
Normalizes an optional passive prompt target path according to the configured return-url policy.
targetPath
parameterName
null
when targetPath
is null, empty, or whitespace; otherwise the original target path after validation.
ArgumentException
targetPath
is not a safe app-relative path. bool IsSafeAppRelativePath(string targetPath)
Determines whether a target path is safe for local app-relative prompt metadata.
targetPath
true
when the path starts with a single forward slash, contains no backslashes, and contains no control characters; otherwise false
.
Protocol-relative paths such as //example.com
, backslash-prefixed paths, and paths containing backslashes are rejected because browsers and proxies can interpret them as cross-origin redirects.
Composes OpenID Connect event handlers so AppSurface can attach safe diagnostics without replacing host behavior.
The composer installs a new OpenIdConnectEvents
instance on the handler options. Existing handlers are copied or invoked first, then AppSurface adds diagnostics for missing subject claims, remote failures, and optional token persistence.
void Compose(OpenIdConnectOptions options, AppSurfaceOidcAuthOptions appSurfaceOptions)
Rebuilds the OIDC event set with AppSurface diagnostic wrappers.
options
appSurfaceOptions
This method overwrites OpenIdConnectOptions.Events
. Existing event delegates are preserved by copying pass-through handlers and by invoking host handlers first for OnTokenValidated
, OnRemoteFailure
, and, when AppSurfaceOidcAuthOptions.SaveTokens
is enabled, OnTicketReceived
.
Configures AppSurface conventions for ASP.NET Core cookie and OpenID Connect authentication registration.
These options name schemes, configure safe AppSurface defaults, and provide callbacks for host-owned ASP.NET Core handler options. They do not insert middleware, execute challenges, execute redirects, store users, provision app users, replace ASP.NET Identity, or configure provider-specific SDKs.
AppSurfaceOidcAuthOptions ConfigureCookie(Action<CookieAuthenticationOptions> configure)
Adds host-owned cookie handler configuration.
configure
The current options instance for chaining.
AppSurfaceOidcAuthOptions ConfigureOpenIdConnect(Action<OpenIdConnectOptions> configure)
Adds host-owned OpenID Connect handler configuration.
configure
The current options instance for chaining.
Provider values such as authority, client id, and client secret should be applied here. AppSurface diagnostics never copy those values into metadata.
AppSurfaceLoginPrompt CreateLoginPrompt(string? targetPath = null, string? displayText = null)
Creates a passive login prompt for host-owned login UI.
targetPath
displayText
A passive login prompt that does not execute a redirect or challenge.
AppSurfaceLogoutPrompt CreateLogoutPrompt(string? targetPath = null, string? displayText = null)
Creates a passive logout prompt for host-owned logout UI.
targetPath
displayText
A passive logout prompt that does not execute a redirect or sign-out.
void ApplyCookie(CookieAuthenticationOptions options)
Applies registered cookie configurators to the AppSurface cookie handler options.
options
CookieScheme
.
Configurators run in the order they were added through ConfigureCookie(Action{CookieAuthenticationOptions})
. Host values assigned by later configurators can therefore replace values assigned by earlier configurators.
void ApplyOpenIdConnect(OpenIdConnectOptions options)
Applies registered OpenID Connect configurators to the AppSurface OIDC handler options.
options
OidcScheme
.
Configurators run in the order they were added through ConfigureOpenIdConnect(Action{OpenIdConnectOptions})
after package defaults are assigned, so host configuration can intentionally override default handler values.
void Validate()
Validates AppSurface OIDC scheme names, subject mapping, and callback paths before registration.
ArgumentException
CookieScheme
and OidcScheme
use the same value.
Callback paths must be safe app-relative paths accepted by AppSurfaceOidcReturnUrlOptions.IsSafeAppRelativePath(string)
.
string CookieScheme { get; set; }
Source
Gets or sets the cookie authentication scheme name.
string OidcScheme { get; set; }
Source
Gets or sets the OpenID Connect authentication scheme name.
string SubjectClaim { get; set; }
Source
Gets or sets the stable subject claim that should be mapped into AppSurface auth context.
The OIDC package defaults this to sub
, then delegates to AppSurfaceAspNetCoreAuthOptions.MapSubjectClaim(string)
. This keeps subject mapping in the existing ASP.NET Core adapter instead of adding a parallel mapper.
PathString CallbackPath { get; set; }
Source
Gets or sets the callback path assigned to the OpenID Connect handler.
PathString SignedOutCallbackPath { get; set; }
Source
Gets or sets the signed-out callback path assigned to the OpenID Connect handler.
bool SaveTokens { get; set; }
Source
Gets or sets a value indicating whether tokens should be saved into the authentication ticket.
The default is false
. Enabling token storage can increase cookie size and persist sensitive token material in host-owned authentication state.
bool RequireClientSecret { get; set; }
Source
Gets or sets a value indicating whether the OpenID Connect handler must have a client secret configured.
The default is true
for confidential ASP.NET Core web applications. Hosts using a provider flow that does not require a client secret can disable this validation explicitly.
AppSurfaceOidcReturnUrlOptions ReturnUrls { get; }
Source
Gets the return-url policy helper used by passive prompt helpers.
Registers AppSurface-safe ASP.NET Core cookie and OpenID Connect authentication conventions.
IServiceCollection AddAppSurfaceOidcAuth(this IServiceCollection services, Action<AppSurfaceOidcAuthOptions>? configure = null)
Adds named cookie and OpenID Connect authentication schemes with AppSurface-safe defaults.
services
configure
The same service collection for chaining.
The method registers named schemes only. It does not set global default schemes, insert middleware, execute challenges, execute redirects, execute sign-in or sign-out, provision users, or configure provider-specific SDKs. Hosts must still call UseAuthentication()
and UseAuthorization()
in the ASP.NET Core pipeline.
Stable diagnostic codes emitted by the AppSurface OIDC convenience package.
Validates OpenID Connect handler options for the AppSurface-owned OIDC scheme.
Validation is scoped to AppSurfaceOidcAuthOptions.OidcScheme
so other host-owned OIDC schemes remain untouched. The client-secret requirement follows AppSurfaceOidcAuthOptions.RequireClientSecret
.
ValidateOptionsResult Validate(string? name, OpenIdConnectOptions options)
Validates required OIDC handler fields for the matching AppSurface scheme.
name
options
ValidateOptionsResult.Skip
for non-AppSurface schemes, success when authority, client id, and any required client secret are present, or a failure result with stable AppSurface diagnostic messages.
void ThrowIfInvalid(string name, OpenIdConnectOptions options, AppSurfaceOidcAuthOptions appSurfaceOptions)
Fails fast with OptionsValidationException
when the AppSurface OIDC handler is invalid.
name
options
appSurfaceOptions
This helper is intended for post-configuration paths that need the same validation semantics as Validate(string?, OpenIdConnectOptions)
.
Defines safe diagnostic metadata keys emitted by the AppSurface OIDC convenience package.
These keys identify setup and handler-state diagnostics only. They must not carry raw tokens, raw claims, emails, display names, client secrets, ID-token payloads, or provider response bodies.