Skip to content

SignInManager.AuthenticationScheme rename #50169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2023
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 @@ -96,7 +96,7 @@ public static IEndpointConventionBuilder MapIdentityApi<TUser>(this IEndpointRou

var useCookieScheme = (useCookies == true) || (useSessionCookies == true);
var isPersistent = (useCookies == true) && (useSessionCookies != true);
signInManager.PrimaryAuthenticationScheme = useCookieScheme ? IdentityConstants.ApplicationScheme : IdentityConstants.BearerScheme;
signInManager.AuthenticationScheme = useCookieScheme ? IdentityConstants.ApplicationScheme : IdentityConstants.BearerScheme;

var result = await signInManager.PasswordSignInAsync(login.Email, login.Password, isPersistent, lockoutOnFailure: true);

Expand Down
4 changes: 2 additions & 2 deletions src/Identity/Core/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Microsoft.AspNetCore.Identity.SecurityStampValidator<TUser>.SecurityStampValidat
Microsoft.AspNetCore.Identity.SecurityStampValidator<TUser>.TimeProvider.get -> System.TimeProvider!
Microsoft.AspNetCore.Identity.SecurityStampValidatorOptions.TimeProvider.get -> System.TimeProvider?
Microsoft.AspNetCore.Identity.SecurityStampValidatorOptions.TimeProvider.set -> void
Microsoft.AspNetCore.Identity.SignInManager<TUser>.PrimaryAuthenticationScheme.get -> string!
Microsoft.AspNetCore.Identity.SignInManager<TUser>.PrimaryAuthenticationScheme.set -> void
Microsoft.AspNetCore.Identity.SignInManager<TUser>.AuthenticationScheme.get -> string!
Microsoft.AspNetCore.Identity.SignInManager<TUser>.AuthenticationScheme.set -> void
Microsoft.AspNetCore.Identity.TwoFactorSecurityStampValidator<TUser>.TwoFactorSecurityStampValidator(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Identity.SecurityStampValidatorOptions!>! options, Microsoft.AspNetCore.Identity.SignInManager<TUser!>! signInManager, Microsoft.Extensions.Logging.ILoggerFactory! logger) -> void
Microsoft.AspNetCore.Routing.IdentityApiEndpointRouteBuilderExtensions
static Microsoft.AspNetCore.Identity.IdentityBuilderExtensions.AddApiEndpoints(this Microsoft.AspNetCore.Identity.IdentityBuilder! builder) -> Microsoft.AspNetCore.Identity.IdentityBuilder!
Expand Down
14 changes: 7 additions & 7 deletions src/Identity/Core/src/SignInManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public SignInManager(UserManager<TUser> userManager,
/// <summary>
/// The authentication scheme to sign in with. Defaults to <see cref="IdentityConstants.ApplicationScheme"/>.
/// </summary>
public string PrimaryAuthenticationScheme { get; set; } = IdentityConstants.ApplicationScheme;
public string AuthenticationScheme { get; set; } = IdentityConstants.ApplicationScheme;

/// <summary>
/// The <see cref="HttpContext"/> used.
Expand Down Expand Up @@ -122,7 +122,7 @@ public virtual bool IsSignedIn(ClaimsPrincipal principal)
{
ArgumentNullException.ThrowIfNull(principal);
return principal.Identities != null &&
principal.Identities.Any(i => i.AuthenticationType == PrimaryAuthenticationScheme);
principal.Identities.Any(i => i.AuthenticationType == AuthenticationScheme);
}

/// <summary>
Expand Down Expand Up @@ -161,7 +161,7 @@ public virtual async Task<bool> CanSignInAsync(TUser user)
/// <returns>The task object representing the asynchronous operation.</returns>
public virtual async Task RefreshSignInAsync(TUser user)
{
var auth = await Context.AuthenticateAsync(PrimaryAuthenticationScheme);
var auth = await Context.AuthenticateAsync(AuthenticationScheme);
IList<Claim> claims = Array.Empty<Claim>();

var authenticationMethod = auth?.Principal?.FindFirst(ClaimTypes.AuthenticationMethod);
Expand Down Expand Up @@ -237,7 +237,7 @@ public virtual async Task SignInWithClaimsAsync(TUser user, AuthenticationProper
{
userPrincipal.Identities.First().AddClaim(claim);
}
await Context.SignInAsync(PrimaryAuthenticationScheme,
await Context.SignInAsync(AuthenticationScheme,
userPrincipal,
authenticationProperties ?? new AuthenticationProperties());

Expand All @@ -250,7 +250,7 @@ await Context.SignInAsync(PrimaryAuthenticationScheme,
/// </summary>
public virtual async Task SignOutAsync()
{
await Context.SignOutAsync(PrimaryAuthenticationScheme);
await Context.SignOutAsync(AuthenticationScheme);

if (await _schemes.GetSchemeAsync(IdentityConstants.ExternalScheme) != null)
{
Expand Down Expand Up @@ -669,9 +669,9 @@ public virtual async Task<SignInResult> ExternalLoginSignInAsync(string loginPro
}

/// <summary>
/// Gets a collection of <see cref="AuthenticationScheme"/>s for the known external login providers.
/// Gets a collection of <see cref="Authentication.AuthenticationScheme"/>s for the known external login providers.
/// </summary>
/// <returns>A collection of <see cref="AuthenticationScheme"/>s for the known external login providers.</returns>
/// <returns>A collection of <see cref="Authentication.AuthenticationScheme"/>s for the known external login providers.</returns>
public virtual async Task<IEnumerable<AuthenticationScheme>> GetExternalAuthenticationSchemesAsync()
{
var schemes = await _schemes.GetAllSchemesAsync();
Expand Down