Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
builder.Services.AddUltimateAuthServer(o =>
{
o.Cryptography.TokenHashingKey = builder.Configuration["UltimateAuth:Cryptography:TokenHashingKey"]
?? throw new InvalidOperationException("UltimateAuth token hashing key is missing.");
?? o.Cryptography.TokenHashingKey;

o.Cryptography.JwtSigningKey = builder.Configuration["UltimateAuth:Cryptography:JwtSigningKey"]
?? throw new InvalidOperationException("UltimateAuth JWT signing key is missing.");
?? o.Cryptography.JwtSigningKey;

// Identity Lab uses its own trusted creation align with Sandbox management.
o.Endpoints.DisabledActions.Add(UAuthActions.Users.CreateAnonymous);
Expand Down
11 changes: 0 additions & 11 deletions docs/content/auth-flows/refresh-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,6 @@ No access token or refresh token is issued. The existing session ID remains the

The order is important: **session touch happens before token rotation** in the current implementation. These operations are not presented as one cross-store transaction. If rotation subsequently fails, the refresh response fails, although a preceding session touch may already have been persisted. This should not be described as an all-or-nothing operation.

### SemiHybrid and PureJwt: implementation branches

The current service includes branches for two additional modes:

- `SemiHybrid` requires a session ID and refresh token, validates the session and rotates the token, but does not touch the session.
- `PureJwt` uses the refresh token for rotation without a session touch step in `RefreshFlowService`.

These describe the existing code paths, **not a promise of v0.1.0 production support**. Configuration validation and supported-mode documentation remain authoritative for which modes applications can enable.

## Request resolution and response delivery

The refresh endpoint uses the server's `AuthFlowContext`. It obtains the session ID from `flow.Session`, the device from `flow.Device`, and the refresh token through `RefreshTokenResolver`.
Expand All @@ -151,8 +142,6 @@ On success, the endpoint chooses a **primary credential** according to the refre

The HTTP endpoint returns **`204 No Content`** on successful refresh and **`401 Unauthorized`** when continuation fails. Clients should obtain credentials from the configured response delivery mechanism rather than expecting a JSON token payload. When `Diagnostics.EnableRefreshDetails` is enabled, the endpoint also writes the refresh outcome through its diagnostic response writer.

> Response delivery customization is not fully independent in v0.1.0: mode templates and application-profile adaptation constrain the effective behavior. Do not assume every configured credential-delivery override is honored.

## Outcomes and client expectations

| Outcome | Meaning | Client interpretation |
Expand Down
89 changes: 85 additions & 4 deletions docs/content/client-sdk/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,62 @@ var request = new LoginRequest
await UAuthClient.Flows.LoginAsync(request);
```

The method returns `Task`, not a structured login result.
`LoginAsync` returns a structured login result describing the outcome of the submission.

It submits the login payload through the configured navigation-based transport.
The client discovers the effective login transport supported by the server.

Depending on the hosting environment, this may initiate navigation or redirect behavior.
Depending on the authentication mode, credential delivery configuration, and return URL, login may use browser navigation or a fetch-based request.

A navigation submission does not itself confirm successful server-side authentication. A fetch-based submission allows the client to observe the server response and process delivered credentials.

### Login Transport Selection

UltimateAuth supports three login transport strategies:

| Transport | Behavior |
|---|---|
| `Auto` | Automatically selects a compatible transport |
| `Navigation` | Submits the login through browser navigation |
| `Fetch` | Submits the login through an HTTP request and processes the response |

`Auto` is the default and recommended strategy.

```csharp
var result = await UAuthClient.Flows.LoginAsync(
request,
returnUrl: "/dashboard",
transport: UAuthLoginTransport.Auto);
```

Navigation is suitable when the effective credential delivery configuration supports browser-managed authentication credentials.

Fetch is required when the client must observe a header-delivered access token.

Applications can explicitly request fetch-based login:

```csharp
var result = await UAuthClient.Flows.LoginAsync(
request,
transport: UAuthLoginTransport.Fetch);
```

An explicitly requested transport must be compatible with the effective server configuration.

The client does not silently downgrade an incompatible explicit navigation request.

### Processing Header-Delivered Access Tokens

When login delivers an access token through a response header, UltimateAuth processes the token and stores it in the client-side token store.

The default token store is in-memory.

Applications using the UltimateAuth client do not need to manually extract JWTs from login responses or construct authorization headers.

The client attaches the access token to supported authenticated requests and clears expired credentials from the token store.

In-memory storage does not persist access tokens across a full application reload.

Authentication continuation after a reload depends on the available refresh credential and the effective server configuration.

### LoginRequest Properties

Expand Down Expand Up @@ -479,6 +530,32 @@ This is useful when the current PKCE context can no longer be used.

The application should not repeatedly resubmit the same invalid authorization code and verifier.

### UAuthHub Handoff and Credential Ownership

A PKCE flow initiated by an application retains the initiating application's authentication context.

When the user completes login through UAuthHub, the resulting credentials belong to the initiating application, not to the Hub's interactive login interface.

The Hub completes the authentication flow and returns the user to the validated application return URL.

Header-delivered access tokens associated with the initiating application must not be installed into the Hub's local authentication state.

After returning to the initiating application, the client can restore authentication through the available session or refresh credentials.

This behavior preserves the original application and device context throughout the authentication journey.

### Authentication Recovery

The client may recover a header-delivered access token when the application starts without a usable token but a compatible refresh credential remains available.

This allows authentication to continue after a full application reload or a supported UAuthHub handoff.

Recovery does not bypass refresh-token validation, device binding, expiration, rotation, or server-side authentication policies.

Recovery can fail when the refresh credential has expired, has been revoked, or is unavailable because of browser cookie restrictions.

Cross-site browser deployments must not assume that refresh cookies will always be available.

## 8. Direct Credential Posting Restrictions

UltimateAuth restricts direct credential posting according to the configured application profile.
Expand Down Expand Up @@ -741,7 +818,11 @@ Explicit validation is useful when an application needs to check current server-
await UAuthClient.Flows.LogoutAsync();
```

The method uses the configured logout endpoint and navigation transport.
The method submits logout to the configured endpoint and observes the server response before clearing the local access token and publishing the logout event.

Automatic navigation can be disabled without disabling server-side logout.

A failed logout response does not represent a successfully terminated authentication context.

Depending on the application profile and configuration, logout may involve navigation and authentication state changes.

Expand Down
40 changes: 36 additions & 4 deletions docs/content/client-sdk/resource-api-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -591,13 +591,45 @@ Likewise, configuring a Resource API URL in the client SDK does not automaticall

### Credential Delivery

The client and Resource API must agree on how the credential is transported.
The client and Resource API must agree on the credential used for authentication and its transport.

For header delivery, the API must read the configured access-token header and format.
#### Session-based Resource APIs

For cookie delivery, the API must read the configured access-token cookie. Browser origin, cookie scope, SameSite, Secure, and CORS settings must permit the credential to reach the API.
PureOpaque and Hybrid Resource APIs use opaque session credentials.

The Resource API must independently validate the credential and enforce authorization policies.
Cookie delivery is the default for incoming session credentials.

The Resource API validates the selected session through UAuthHub using the configured Hub address.

The browser must be able to send the session cookie to the Resource API.

#### JWT-based Resource APIs

PureJwt Resource APIs use JWT access tokens.

The default Blazor Resource Client attaches the current access token using:

```http
Authorization: Bearer <access-token>
```

For a Resource API that exclusively uses header-based JWT authentication, browser cookies can be omitted:

```csharp
options.Resource.Credentials = UAuthResourceCredentialsMode.Omit;
```

Omitting browser cookies does not prevent the client from attaching its access-token authorization header.

This option affects Resource API requests, not authentication or refresh requests sent to UAuthHub.

#### Credential compatibility

A JWT issued in Hybrid mode is not interchangeable with a PureJwt access token.

Hybrid-aware JWT validation in separate Resource APIs is not currently implemented.

Authentication mode selection and credential compatibility remain explicit configuration responsibilities.

### PureJwt and UAuthHub Connectivity

Expand Down
17 changes: 4 additions & 13 deletions docs/content/configuration/advanced-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,21 @@ Applications should not assume that per-tenant options customization exists auto

The default `EffectiveAuthModeResolver` maps application profiles to authentication modes.

| Application profile | Resolved mode |
| Application Profile | Default Mode |
|---|---|
| `BlazorServer` | `PureOpaque` |
| `WebServer` | `Hybrid` |
| `BlazorWasm` | `Hybrid` |
| `Maui` | `Hybrid` |
| `ResourceApi` | `PureJwt` |
| `Api` | `PureJwt` |
| `UAuthHub` | `Hybrid` |
| `ResourceApi` | `Hybrid` |
| `Api` | `Hybrid` |
| Other / unknown | `Hybrid` |

These mappings describe the current default resolver.

They do not imply that every resolved mode is fully supported in the current release.

In particular, the current server options validator rejects explicit activation of `SemiHybrid` and `PureJwt` through `AllowedModes`.

Applications should verify that their application profiles resolve to a supported authentication mode before deploying.

### AllowedModes Is Not a Mode Selector
Expand Down Expand Up @@ -345,14 +344,6 @@ Token.RefreshTokenLifetime = TimeSpan.FromDays(7);

Hybrid also configures refresh-token delivery through a cookie.

### Unsupported Modes

Although default templates exist for `SemiHybrid` and `PureJwt`, their presence does not mean those modes are ready for production use.

The server's current validator explicitly rejects these modes when they are enabled through `AllowedModes`.

Only use modes supported by the current release.

## 7. Inspect Effective Options

Advanced integrations can use `IEffectiveServerOptionsProvider` to inspect configured and effective server options.
Expand Down
7 changes: 7 additions & 0 deletions docs/content/configuration/client-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,13 @@ Changing a client endpoint does not create or expose the corresponding server en
| `PkceTryComplete` | `/pkce/try-complete` |
| `PkceComplete` | `/pkce/complete` |
| `HubLoginPath` | `/uauthhub/entry` |
| `LoginTransport` | `/login/transport` |

> The `LoginTransport` endpoint exposes the effective login transport capabilities of the authentication server.
>
>The client uses this information to determine whether navigation-based login is supported and whether the authentication response requires access-token processing.
>
>This endpoint does not select an authentication mode or negotiate the server's authentication configuration.

### Customize Individual Paths

Expand Down
92 changes: 71 additions & 21 deletions docs/content/configuration/server-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,17 +403,16 @@ UltimateAuth resolves the effective authentication mode using the application pr
| WebServer | Hybrid |
| BlazorWasm | Hybrid |
| Maui | Hybrid |
| Api | PureJwt |
| ResourceApi | PureJwt |
| UAuthHub | Hybrid |
| Api | Hybrid |
| ResourceApi | Hybrid |

The server controls the effective authentication mode. Application profile metadata is not an authorization boundary.

`AuthMode` forces a single mode for the server, while `ApplicationProfileModes` provides explicit profile-specific mappings. These configuration mechanisms cannot be combined.

`AllowedModes` restricts permitted modes but does not select a mode.

PureJwt is implemented. SemiHybrid remains unavailable.

### Explicit PureJwt Configuration

```csharp
Expand Down Expand Up @@ -1191,40 +1190,91 @@ The application should return valid, trusted navigation destinations.

Avoid constructing redirects from unvalidated user-controlled URLs.

## 22. Authentication Response Options
## 22. Credential Delivery and Authentication Responses

UltimateAuth separates credential delivery from navigation behavior.

Credential delivery is configured through `options.GrantDelivery`:

```csharp
options.GrantDelivery.Default
options.GrantDelivery.Session
options.GrantDelivery.AccessToken
options.GrantDelivery.RefreshToken
```

Each grant can have its own delivery configuration.

### Mode-Specific Delivery Defaults

`options.AuthResponse` controls how authentication credentials and redirect behavior are represented in responses.
| Authentication Mode | Session | Access Token | Refresh Token |
|---|---|---|---|
| PureOpaque | Cookie | Not issued | Not issued |
| Hybrid | Cookie | Header | Cookie |
| PureJwt | Not issued | Header | Cookie |

These are the built-in defaults before application-profile adaptation and explicit configuration.

The available groups are:
For MAUI, grants that would otherwise use cookie delivery default to header delivery.

### Configure Grant Delivery

```csharp
options.AuthResponse.SessionIdDelivery
options.AuthResponse.AccessTokenDelivery
options.AuthResponse.RefreshTokenDelivery
builder.Services.AddUltimateAuthServer(options =>
{
options.AuthMode = UAuthMode.PureJwt;

options.AuthResponse.Login
options.AuthResponse.Logout
options.GrantDelivery.AccessToken.Mode = GrantDeliveryMode.Header;
options.GrantDelivery.RefreshToken.Mode = GrantDeliveryMode.Cookie;
});
```

These settings govern credential delivery and authentication response behavior.
An explicit per-grant delivery mode takes precedence over the global delivery default and the built-in mode-specific default.

Only credentials available in the selected authentication mode can be configured for delivery.

### Credential Delivery Versus Request Authentication

Response headers deliver newly issued credentials to the client.

The default credential response header names are:

| Credential | Response Header |
|---|---|
| Session | `uas` |
| Access token | `uat` |
| Refresh token | `uar` |

These response headers must not be confused with the headers used to authenticate subsequent requests.

For example, the Blazor client receives an access token through the configured response header and sends it on subsequent authenticated requests using `Authorization: Bearer`.

### Redirect Configuration

Login and logout redirect behavior is configured separately:

```csharp
options.Redirect.Login
options.Redirect.Logout
```

### Important: Mode-Specific Response Defaults
A redirect is a navigation concern, not an authentication credential.

UltimateAuth provides response templates for authentication modes.
### Login Transport Discovery

For example, `PureOpaque` uses a session-oriented cookie response, while `Hybrid` combines session and token delivery behavior.
The client discovers whether the effective server configuration supports navigation-based login or requires fetch-based submission.

The effective response may therefore depend on the resolved authentication mode and flow.
Header-delivered access tokens require a transport that allows the client to observe and process the authentication response.

Do not assume that a single globally configured response delivery setting applies unchanged to every authentication mode.
Applications should normally allow the client to select the appropriate login transport automatically.

### Security Considerations

Credential delivery settings determine whether sensitive authentication material is exposed through cookies, headers, or other response mechanisms.
Credential delivery must be compatible with the selected authentication mode, application profile, and deployment topology.

Only customize them when the application has a clear requirement and the selected transport is appropriate for the client platform.
Browser cookie restrictions, CORS policies, trusted origins, and token storage behavior remain relevant regardless of the selected transport.

For advanced response customization, see [Advanced Configuration](/docs/configuration/advanced-configuration).
For additional client-side behavior, see [Authentication](/docs/client-sdk/authentication).

## 23. Diagnostics Options

Expand Down
2 changes: 1 addition & 1 deletion docs/content/fundamentals/application-profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ A Blazor WebAssembly application communicating with a separate API may benefit f

These are architectural recommendations, not inherent limitations of the runtimes.

### Recommended defaults
### Recommended Authentication Modes

| Application environment | Recommended mode | Reason |
|---|---|---|
Expand Down
Loading
Loading