string CssClassPrefix { get; set; }
Source
Gets or sets the CSS class prefix used for every marker element.
Authenticates the configured DevAuth scheme from the local persona cookie.
The handler reads only the protected persona id cookie, resolves that id against seeded personas, and returns AuthenticateResult.NoResult() for blank, tampered, stale, or unknown state. It does not issue challenges, sign users in, or validate production identity tokens.
Task<AuthenticateResult> HandleAuthenticateAsync()
Source
Attempts to authenticate the selected local persona.
Success with a claims principal for a known protected persona id, or no result when no trustworthy persona is selected.
string ProtectPersonaId(string personaId)
Source
Protects a persona id with the same data-protection purpose as the endpoint cookie writer.
personaIdConfigured persona id to protect for tests.A protected cookie payload containing only the persona id.
Controls how the AppSurface DevAuth marker renders inside a local development host page.
The marker is an explicit opt-in snippet for Development pages. It never injects itself into host HTML. Consumers can disable the default inline styles and provide their own classes when the marker needs to match a local design system.
string CssClassPrefix { get; set; }
Source
Gets or sets the CSS class prefix used for every marker element.
string? AdditionalCssClass { get; set; }
Source
Gets or sets an extra CSS class appended to the marker root element.
bool IncludeDefaultStyles { get; set; }
Source
Gets or sets a value indicating whether the marker includes package-provided default styles.
Set this to false when the host wants to skin the marker entirely with its own CSS.
bool ShowPersonaControls { get; set; }
Source
Gets or sets a value indicating whether persona select and clear controls are rendered in the marker.
When enabled, controls use POST-only DevAuth endpoints and include a safe local return URL so the browser returns to the host page after changing personas.
string? ReturnUrl { get; set; }
Source
Gets or sets the local URL to return to after a marker persona mutation.
Leave this unset to return to the current request path and query. External URLs, protocol-relative URLs, and backslash-prefixed URLs are ignored by the DevAuth endpoints.
Detects sensitive-looking local persona ids and preview values without rejecting innocent words such as monkey or mailbox.
DevAuth diagnostics and control pages must not render obvious secrets, tokens, passwords, keys, credentials, or email-shaped values. This helper treats separators, PascalCase, and camelCase as token boundaries so names such as apiKey, passwordHash, access_token, and secret-token are hidden.
bool ContainsSensitiveToken(string value)
Source
Determines whether a value looks too sensitive to expose in DevAuth diagnostics or route-visible persona ids.
valueCandidate local value, claim type, claim value, display name, subject, or persona id.true when the value contains an email marker or sensitive word boundary.
Performs DevAuth startup validation after the host service provider has been built.
Registration validates the caller-supplied Development environment early, but this hosted service re-checks the real environment resolved from dependency injection and inspects the final authentication defaults and schemes. It rejects non-Development hosts and real authentication scheme conflicts unless the consumer explicitly enabled the local-proof override. This service is internal infrastructure for AppSurfaceDevAuthServiceCollectionExtensions.
Task StartAsync(CancellationToken cancellationToken)
Source
Validates that DevAuth is running in Development and is not silently coexisting with real authentication.
cancellationTokenStartup cancellation token; validation performs only in-memory inspection.A completed task when the final host configuration is safe for local DevAuth.
AppSurfaceDevAuthExceptionThrown with ASDEV001 outside Development, with option diagnostics when materialized options are invalid, or with ASDEV002 when real schemes/defaults are present without the explicit override.Task StopAsync(CancellationToken cancellationToken)
Source
Stops the validator.
cancellationTokenStop cancellation token.A completed task because the validator does not own background work.
Renders an explicit AppSurface DevAuth state marker for host pages.
Use this helper from a Development-only page or layout when the selected fake persona should stay visible while navigating the app. The returned HTML contains only safe persona display values and POST-only controls that target the mapped DevAuth endpoints. DevAuth does not automatically inject this marker into host output.
string Render(HttpContext httpContext, IHostEnvironment environment, IOptions<AppSurfaceDevAuthOptions> options, IDataProtectionProvider dataProtectionProvider, Action<AppSurfaceDevAuthMarkerOptions>? configure = null)
Source
Renders a local DevAuth marker using the current request state.
httpContextCurrent HTTP context, used to read the protected persona cookie and build return URLs.environmentHost environment used for marker status.optionsConfigured DevAuth options.dataProtectionProviderData protection provider used to read the selected persona cookie.configureOptional marker rendering customization.HTML that can be embedded in a host page.
Represents a seeded local-development persona that can be selected by AppSurface DevAuth.
string Id { get; }
Source
Gets the stable local persona id used by the DevAuth selection cookie.
string DisplayName { get; }
Source
Gets the display name shown on the local-only DevAuth control page.
string SubjectClaimType { get; }
Source
Gets the claim type used to expose the stable local subject.
string Subject { get; }
Source
Gets the stable local subject value for this persona.
IReadOnlyList<Claim> Claims { get; }
Source
Gets safe local-development claims issued for this persona.
Exception thrown when AppSurface DevAuth detects unsafe or invalid development-auth configuration.
string DiagnosticCode { get; }
Source
Gets the stable AppSurface DevAuth diagnostic code.
Maps AppSurface DevAuth local-only control and status endpoints.
IEndpointRouteBuilder MapAppSurfaceDevAuth(this IEndpointRouteBuilder endpoints)
Source
Maps the AppSurface DevAuth control page, status JSON, select persona, and clear persona endpoints.
endpointsEndpoint route builder that receives the local-only endpoints.The same endpoint route builder for chaining.
Map this after building the app and before relying on the persona lab in a local proof host. The method validates the same materialized options used by the authentication handler, reserves the configured path prefix, and rejects existing endpoints whose route templates are equivalent to DevAuth control routes even when parameter names differ. Control endpoints stay loopback-only by default and set no-store headers on every response.
AppSurfaceDevAuthStatus BuildStatus(HttpContext httpContext, IHostEnvironment environment, AppSurfaceDevAuthOptions options, IDataProtectionProvider dataProtectionProvider)
Source
Builds safe DevAuth status from the selected persona cookie for endpoint and marker rendering.
string DisplayPersonaName(AppSurfaceDevAuthPersona persona)
Source
Returns a safe display name for a configured persona.
string DisplayStatusPersonaName(AppSurfaceDevAuthStatus status)
Source
Returns a safe display name for the current status.
string DisplayStatusSubject(AppSurfaceDevAuthStatus status)
Source
Returns a safe subject value for the current status.
string NormalizeLocalReturnUrl(string? value)
Source
Normalizes a local marker return URL and falls back to the site root for unsafe values.
Marker metadata applied to endpoints mapped by AppSurface DevAuth.
Builds a seeded local-development persona for AppSurface DevAuth.
AppSurfaceDevAuthUserBuilder DisplayName(string displayName)
Source
Sets the display name shown on the DevAuth control page.
displayNameNon-blank display name.The same builder for chaining.
AppSurfaceDevAuthUserBuilder Subject(string subject, string claimType = AppSurfaceDevAuthDefaults.SubjectClaimType)
Source
Sets the stable subject claim for the local persona.
subjectNon-blank subject value.claimTypeNon-blank subject claim type. Defaults to sub.The same builder for chaining.
AppSurfaceDevAuthUserBuilder Claim(string type, string value)
Source
Adds a safe local-development claim to the persona.
typeNon-blank claim type.valueNon-blank claim value.The same builder for chaining.
Claims added here are local test inputs. They are not durable identity, tenant authority, or permission truth. Keep secrets, tokens, passwords, raw emails, and production identity payloads out of DevAuth personas.
AppSurfaceDevAuthPersona Build()
Source
Builds the immutable persona that will be stored in AppSurfaceDevAuthOptions.Users.
A persona with a default display name of the persona id when no display name was supplied.
The configured subject claim is prepended when Subject(string, string) was called. Any previously added claim with the same subject claim type is replaced so the persona has one stable subject value. Registration validation rejects personas that were built without an explicit subject.
string NormalizePersonaId(string id)
Source
Validates and returns a route-safe local persona id.
idCandidate persona id, such as admin, viewer, or qa.local_1.The original id when it is safe for route values and local cookie payloads.
AppSurfaceDevAuthExceptionThrown with ASDEV006 when the id is blank, a URI dot segment, contains unsupported characters, or includes a sensitive-looking token segment such as secret, token, key, or email.Use this before accepting route-supplied persona ids. The validation is intentionally strict because persona ids are visible in the local selection URL and are the only payload stored in the protected persona cookie.
string Id { get; }
Source
Gets the local persona id.
Options for AppSurface development-only authentication.
AppSurfaceDevAuthPersonaCollection Users { get; }
Source
Gets the seeded local-development personas.
string SchemeName { get; set; }
Source
Gets or sets the authentication scheme registered for DevAuth.
string PathPrefix { get; set; }
Source
Gets or sets the local-only path prefix for the control page and status endpoints.
string CookieName { get; set; }
Source
Gets or sets the cookie name that stores the selected local persona id.
bool UseAsDefaultSchemeForLocalProof { get; set; }
Source
Gets or sets a value indicating whether DevAuth may become the default scheme for local proof apps.
Leave this disabled for package consumers that already have real authentication. Enable it only in throwaway local proof hosts where DevAuth is intentionally the whole authentication stack.
bool AllowDevAuthOverrideForLocalProof { get; set; }
Source
Gets or sets a value indicating whether DevAuth may coexist with other registered authentication schemes.
This is a loud local-only override for demos that intentionally compose real and fake schemes. It must not be used to hide production authentication conflicts.
bool RequireLoopbackControlRequests { get; set; }
Source
Gets or sets a value indicating whether control endpoints reject non-loopback requests.
ISet<string> DisplayClaimTypes { get; }
Source
Gets claim types that may appear in the local-only control page claims preview.
The authentication handler still issues every seeded persona claim. This allowlist affects only the HTML preview. Sensitive claim names such as tokens, secrets, passwords, keys, and emails are never rendered even when added here.
Registers AppSurface development-only authentication for ASP.NET Core hosts.
IServiceCollection AddAppSurfaceDevAuth(this IServiceCollection services, IHostEnvironment environment, Action<AppSurfaceDevAuthOptions> configure)
Source
Adds the AppSurface DevAuth named authentication scheme and startup safety validation.
servicesService collection that receives DevAuth registrations.environmentHost environment used to enforce Development-only startup.configureCallback that configures seeded local personas and DevAuth options once during registration.The same service collection for chaining.
AppSurfaceDevAuthExceptionThrown when DevAuth is enabled outside Development or the supplied options are invalid.DevAuth is fake local authentication. It registers a normal ASP.NET Core authentication handler, but it must not be used as a production identity provider, user store, OIDC replacement, or durable app-user mapping layer.
AppSurfaceDevAuthException CreateNonDevelopmentException(string environmentName)
Source
Creates the stable AppSurfaceDevAuthDiagnostics.NonDevelopmentEnvironment exception.
environmentNameHost environment name used only in the safe diagnostic message. Blank values are rendered as (unknown).An exception that tells consumers to run DevAuth only in Development or remove it.
void ValidateOptions(AppSurfaceDevAuthOptions options)
Source
Validates the materialized DevAuth options before endpoint mapping and startup safety checks run.
optionsOptions instance populated once by the consumer registration callback.ArgumentExceptionThrown when AppSurfaceDevAuthOptions.SchemeName, AppSurfaceDevAuthOptions.PathPrefix, or AppSurfaceDevAuthOptions.CookieName is blank.AppSurfaceDevAuthExceptionThrown with ASDEV003 when no personas are configured, ASDEV004 when a persona lacks its configured subject claim, or ASDEV005 when the path prefix is not an absolute path without a trailing slash.bool IsMissingSubjectClaim(AppSurfaceDevAuthPersona persona)
Source
Determines whether a seeded persona is missing the non-blank subject claim required by Auth.AspNetCore mapping.
personaPersona to inspect after it has been built from the local seed callback.true when the persona lacks its configured subject claim.
Stable AppSurface DevAuth diagnostic codes and safe metadata keys.
Collection of seeded local-development personas for AppSurface DevAuth.
AppSurfaceDevAuthPersonaCollection Add(string id, Action<AppSurfaceDevAuthUserBuilder> configure)
Source
Adds a local-development persona.
idURL-safe local persona id.configureCallback that configures the persona.The same collection for chaining.
IReadOnlyDictionary<string, AppSurfaceDevAuthPersona> Personas { get; }
Source
Gets the configured local-development personas.
Defines default names and paths for AppSurface development authentication.