Select the dual authentication scheme¶
Selects which concrete authentication scheme handles an incoming request under the "dual" policy scheme, based on the Authorization header.
| Field | Value |
|---|---|
| Operation ID | OP-11 |
| Trigger | The "dual" policy scheme (registered by AddDualAuthentication) needs to forward an incoming request to a concrete authentication handler. |
| Inputs | The current HttpContext and its Authorization request header. |
| Outputs | JwtBearerDefaults.AuthenticationScheme or IISServerDefaults.AuthenticationScheme. |
| Primary components | AuthenticationServiceExtensions.AuthenticationSchemeSelector |
| Entry point | src/SAIF.NetCore.AuthService/SAIF.NetCore.AuthService/SAIF.NetCore.AuthService/Extensions/AuthenticationServiceExtensions.cs |
Steps¶
- Read the
Authorizationrequest header value. - If it starts with the literal
"Bearer "(case-sensitive, trailing space), returnJwtBearerDefaults.AuthenticationScheme; otherwise returnIISServerDefaults.AuthenticationScheme(BR-AUTH-015) - Used by the
"dual"policy scheme'sForwardDefaultSelectorand byMultiIdentityServiceAccessor— see Resolve the current identity service (OP-12).
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([Request arrives under dual scheme]) --> Header[Read Authorization header]
Header --> Check{"Starts with Bearer prefix?"}
Check -->|Yes| Jwt([Forward to JwtBearer scheme])
Check -->|No| Iis([Forward to IIS/Windows scheme])
Failure and edge-case behavior¶
AuthenticationSchemeSelectoris apublic staticmutable field — any consumer can reassign it, changing scheme selection process-wide*.
Related documentation¶
Note: Statements marked with
*were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with**could not be confirmed; treat as unknown until verified.
Sources¶
src/SAIF.NetCore.AuthService/SAIF.NetCore.AuthService/SAIF.NetCore.AuthService/Extensions/AuthenticationServiceExtensions.cs