Skip to content

Register client-side services

Registers the ICurrentUserService implementation a client app needs to resolve the current user's name for outbound OnBehalfOfUser header configuration.

Field Value
Operation ID OP-03
Trigger Consumer ConfigureServices (client application)
Inputs ClientAppType (default Mvc)
Outputs ICurrentUserService registered
Primary components IServiceCollectionExtensions.AddNtmlApiAuthorizationClientServices(ClientAppType)
Entry point src/SAIF.NetCore.NtlmApiAuth/src/SAIF.NetCore.NtlmApiAuth/Extensions/IServiceCollectionExtensions.cs

Steps

  1. If appType == Mvc (default), register ICurrentUserService → MvcCurrentUserService (Scoped); otherwise register ICurrentUserService → BlazorCurrentUserService (Scoped). (BR-NTLM-013)

Process flow

flowchart TD
    Start([ConfigureServices]) --> D{appType?}
    D -->|Mvc default| S1[Register MvcCurrentUserService]
    D -->|Blazor| S2[Register BlazorCurrentUserService]
    S1 --> End([ICurrentUserService registered])
    S2 --> End

Failure and edge-case behavior

  • Calling this method after AddNtlmApiAuthorization<T>() (or vice versa) re-registers ICurrentUserService; the last call wins because registrations use Add*, not TryAdd*.

Sources

  • src/SAIF.NetCore.NtlmApiAuth/src/SAIF.NetCore.NtlmApiAuth/Extensions/IServiceCollectionExtensions.cs