Class ExternalLoginProvisioningService<TUser>
- Namespace
- Stratara.Identity.AspNetCore.Services
- Assembly
- Stratara.Identity.AspNetCore.dll
Just-in-time provisioning for external (OpenID Connect) sign-ins: on a first external sign-in it creates a local ASP.NET Identity account and links the external login, or links to an existing account — enforcing the security invariants as hard defaults.
public sealed class ExternalLoginProvisioningService<TUser> where TUser : IdentityUser, new()
Type Parameters
TUserThe host's ASP.NET Identity user entity.
- Inheritance
-
ExternalLoginProvisioningService<TUser>
- Inherited Members
- Extension Methods
Remarks
This is a channel-agnostic callable service; the sign-in callback endpoint that invokes it stays
in the consumer app. The invariants it enforces: link on the issuer's (provider, sub),
never on email; auto-link to a pre-existing account only when the email is verified by the
provider and confirmed locally (otherwise RequiresInteractiveLinking,
never a silent merge); honor the invitation gate and the auto-provision switch; and fail closed
whenever a check cannot be satisfied.
Constructors
ExternalLoginProvisioningService(UserManager<TUser>, IOptions<ExternalLoginProvisioningOptions>, ILogger<ExternalLoginProvisioningService<TUser>>)
Just-in-time provisioning for external (OpenID Connect) sign-ins: on a first external sign-in it creates a local ASP.NET Identity account and links the external login, or links to an existing account — enforcing the security invariants as hard defaults.
public ExternalLoginProvisioningService(UserManager<TUser> userManager, IOptions<ExternalLoginProvisioningOptions> options, ILogger<ExternalLoginProvisioningService<TUser>> logger)
Parameters
userManagerUserManager<TUser>The ASP.NET Identity user manager backing local accounts.
optionsIOptions<ExternalLoginProvisioningOptions>The provisioning options (security invariants).
loggerILogger<ExternalLoginProvisioningService<TUser>>The logger for provisioning outcomes.
Remarks
This is a channel-agnostic callable service; the sign-in callback endpoint that invokes it stays
in the consumer app. The invariants it enforces: link on the issuer's (provider, sub),
never on email; auto-link to a pre-existing account only when the email is verified by the
provider and confirmed locally (otherwise RequiresInteractiveLinking,
never a silent merge); honor the invitation gate and the auto-provision switch; and fail closed
whenever a check cannot be satisfied.
Methods
ProvisionAsync(ExternalLoginInfo, CancellationToken)
Resolves the local account for an external sign-in, provisioning or linking as policy allows.
public Task<ExternalLoginProvisioningResult<TUser>> ProvisionAsync(ExternalLoginInfo loginInfo, CancellationToken cancellationToken = default)
Parameters
loginInfoExternalLoginInfoThe external login info from
SignInManager.GetExternalLoginInfoAsync().cancellationTokenCancellationTokenA token to observe for cancellation.
Returns
- Task<ExternalLoginProvisioningResult<TUser>>
The provisioning outcome and, when available, the resolved local account.
Exceptions
- ArgumentNullException
loginInfoisnull.