191 references to IdentityConstants
IdentitySample.Mvc (2)
Startup.cs (2)
45o.DefaultScheme = IdentityConstants.ApplicationScheme; 46o.DefaultSignInScheme = IdentityConstants.ExternalScheme;
IdentitySample.PasskeyConformance (2)
Program.cs (2)
17options.DefaultScheme = IdentityConstants.ApplicationScheme; 18options.DefaultSignInScheme = IdentityConstants.ExternalScheme;
IdentitySample.PasskeyUI (2)
Program.cs (2)
17options.DefaultScheme = IdentityConstants.ApplicationScheme; 18options.DefaultSignInScheme = IdentityConstants.ExternalScheme;
Microsoft.AspNetCore.Identity (66)
IdentityApiEndpointRouteBuilderExtensions.cs (4)
97signInManager.AuthenticationScheme = useCookieScheme ? IdentityConstants.ApplicationScheme : IdentityConstants.BearerScheme; 126var refreshTokenProtector = bearerTokenOptions.Get(IdentityConstants.BearerScheme).RefreshTokenProtector; 139return TypedResults.SignIn(newPrincipal, authenticationScheme: IdentityConstants.BearerScheme);
IdentityCookiesBuilderExtensions.cs (11)
49builder.AddCookie(IdentityConstants.ApplicationScheme, o => 57return new OptionsBuilder<CookieAuthenticationOptions>(builder.Services, IdentityConstants.ApplicationScheme); 67builder.AddCookie(IdentityConstants.ExternalScheme, o => 69o.Cookie.Name = IdentityConstants.ExternalScheme; 72return new OptionsBuilder<CookieAuthenticationOptions>(builder.Services, IdentityConstants.ExternalScheme); 82builder.AddCookie(IdentityConstants.TwoFactorRememberMeScheme, o => 84o.Cookie.Name = IdentityConstants.TwoFactorRememberMeScheme; 90return new OptionsBuilder<CookieAuthenticationOptions>(builder.Services, IdentityConstants.TwoFactorRememberMeScheme); 100builder.AddCookie(IdentityConstants.TwoFactorUserIdScheme, o => 102o.Cookie.Name = IdentityConstants.TwoFactorUserIdScheme; 109return new OptionsBuilder<CookieAuthenticationOptions>(builder.Services, IdentityConstants.TwoFactorUserIdScheme);
IdentityServiceCollectionExtensions.cs (19)
55options.DefaultAuthenticateScheme = IdentityConstants.ApplicationScheme; 56options.DefaultChallengeScheme = IdentityConstants.ApplicationScheme; 57options.DefaultSignInScheme = IdentityConstants.ExternalScheme; 59.AddCookie(IdentityConstants.ApplicationScheme, o => 67.AddCookie(IdentityConstants.ExternalScheme, o => 69o.Cookie.Name = IdentityConstants.ExternalScheme; 72.AddCookie(IdentityConstants.TwoFactorRememberMeScheme, o => 74o.Cookie.Name = IdentityConstants.TwoFactorRememberMeScheme; 80.AddCookie(IdentityConstants.TwoFactorUserIdScheme, o => 82o.Cookie.Name = IdentityConstants.TwoFactorUserIdScheme; 143.AddAuthentication(IdentityConstants.BearerAndApplicationScheme) 144.AddScheme<AuthenticationSchemeOptions, CompositeIdentityHandler>(IdentityConstants.BearerAndApplicationScheme, null, compositeOptions => 146compositeOptions.ForwardDefault = IdentityConstants.BearerScheme; 147compositeOptions.ForwardAuthenticate = IdentityConstants.BearerAndApplicationScheme; 149.AddBearerToken(IdentityConstants.BearerScheme) 163=> services.Configure(IdentityConstants.ApplicationScheme, configure); 172=> services.Configure(IdentityConstants.ExternalScheme, configure); 196var bearerResult = await Context.AuthenticateAsync(IdentityConstants.BearerScheme); 205return await Context.AuthenticateAsync(IdentityConstants.ApplicationScheme);
SecurityStampValidator.cs (3)
160await SignInManager.Context.SignOutAsync(IdentityConstants.TwoFactorRememberMeScheme); 182/// Used to validate the <see cref="IdentityConstants.TwoFactorUserIdScheme"/> and 183/// <see cref="IdentityConstants.TwoFactorRememberMeScheme"/> cookies against the user's
SignInManager.cs (29)
96/// The authentication scheme to sign in with. Defaults to <see cref="IdentityConstants.ApplicationScheme"/>. 98public string AuthenticationScheme { get; set; } = IdentityConstants.ApplicationScheme; 310if (await _schemes.GetSchemeAsync(IdentityConstants.ExternalScheme) != null) 312await Context.SignOutAsync(IdentityConstants.ExternalScheme); 314if (await _schemes.GetSchemeAsync(IdentityConstants.TwoFactorUserIdScheme) != null) 316await Context.SignOutAsync(IdentityConstants.TwoFactorUserIdScheme); 701var claimsIdentity = new ClaimsIdentity(IdentityConstants.TwoFactorUserIdScheme); 703await Context.SignInAsync(IdentityConstants.TwoFactorUserIdScheme, claimsPrincipal, props); 712var result = await Context.AuthenticateAsync(IdentityConstants.TwoFactorUserIdScheme); 713await Context.SignOutAsync(IdentityConstants.TwoFactorUserIdScheme); 745if (await _schemes.GetSchemeAsync(IdentityConstants.TwoFactorRememberMeScheme) == null) 751var result = await Context.AuthenticateAsync(IdentityConstants.TwoFactorRememberMeScheme); 766await Context.SignInAsync(IdentityConstants.TwoFactorRememberMeScheme, 769_metrics?.RememberTwoFactorClient(typeof(TUser).FullName!, IdentityConstants.TwoFactorRememberMeScheme); 773_metrics?.RememberTwoFactorClient(typeof(TUser).FullName!, IdentityConstants.TwoFactorRememberMeScheme, ex); 786await Context.SignOutAsync(IdentityConstants.TwoFactorRememberMeScheme); 787_metrics?.ForgetTwoFactorClient(typeof(TUser).FullName!, IdentityConstants.TwoFactorRememberMeScheme); 791_metrics?.ForgetTwoFactorClient(typeof(TUser).FullName!, IdentityConstants.TwoFactorRememberMeScheme, ex); 857if (await _schemes.GetSchemeAsync(IdentityConstants.ExternalScheme) != null) 859await Context.SignOutAsync(IdentityConstants.ExternalScheme); 862if (await _schemes.GetSchemeAsync(IdentityConstants.TwoFactorUserIdScheme) != null) 864await Context.SignOutAsync(IdentityConstants.TwoFactorUserIdScheme); 1089var auth = await Context.AuthenticateAsync(IdentityConstants.ExternalScheme); 1176var identity = new ClaimsIdentity(IdentityConstants.TwoFactorUserIdScheme); 1188var rememberBrowserIdentity = new ClaimsIdentity(IdentityConstants.TwoFactorRememberMeScheme); 1233if (await _schemes.GetSchemeAsync(IdentityConstants.TwoFactorUserIdScheme) != null) 1237await Context.SignInAsync(IdentityConstants.TwoFactorUserIdScheme, StoreTwoFactorInfo(userId, loginProvider)); 1246await Context.SignOutAsync(IdentityConstants.ExternalScheme); 1266var result = await Context.AuthenticateAsync(IdentityConstants.TwoFactorUserIdScheme);
Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test (1)
SqlStoreTestBase.cs (1)
46services.AddAuthentication(IdentityConstants.ApplicationScheme).AddIdentityCookies();
Microsoft.AspNetCore.Identity.FunctionalTests (10)
Infrastructure\FunctionalTestsServiceCollectionExtensions.cs (1)
28.AddContosoAuthentication(o => o.SignInScheme = IdentityConstants.ExternalScheme)
ManagementTests.cs (4)
117services.SetupGetUserClaimsPrincipal(user => principals.Add(user), IdentityConstants.ApplicationScheme); 154.SetupGetUserClaimsPrincipal(user => principals.Add(user), IdentityConstants.ApplicationScheme); 194.SetupGetUserClaimsPrincipal(user => principals.Add(user), IdentityConstants.ApplicationScheme); 244.SetupGetUserClaimsPrincipal(user => principals.Add(user), IdentityConstants.ApplicationScheme);
MapIdentityApiTests.cs (4)
174services.AddAuthentication().AddBearerToken(IdentityConstants.BearerScheme, options => 249services.AddAuthentication().AddBearerToken(IdentityConstants.BearerScheme, options => 334services.AddAuthentication().AddBearerToken(IdentityConstants.BearerScheme, options => 1376.AddBearerToken(IdentityConstants.BearerScheme);
RegistrationTests.cs (1)
231authenticationMethod = user.FindFirstValue(ClaimTypes.AuthenticationMethod), IdentityConstants.ApplicationScheme);
Microsoft.AspNetCore.Identity.InMemory.Test (5)
ControllerTest.cs (1)
24auth.Setup(a => a.SignInAsync(context, IdentityConstants.ApplicationScheme,
FunctionalTest.cs (4)
232Assert.Contains(IdentityConstants.TwoFactorRememberMeScheme + "=", setCookie); 261Assert.Contains(IdentityConstants.TwoFactorRememberMeScheme + "=", setCookie); 355var result = await context.AuthenticateAsync(IdentityConstants.TwoFactorUserIdScheme); 385services.AddAuthentication(IdentityConstants.ApplicationScheme).AddIdentityCookies();
Microsoft.AspNetCore.Identity.Test (94)
IdentityOptionsTest.cs (4)
87Assert.Equal("a", options.Get(IdentityConstants.ApplicationScheme).Cookie.Name); 88Assert.Equal("b", options.Get(IdentityConstants.ExternalScheme).Cookie.Name); 89Assert.Equal("c", options.Get(IdentityConstants.TwoFactorRememberMeScheme).Cookie.Name); 90Assert.Equal("d", options.Get(IdentityConstants.TwoFactorUserIdScheme).Cookie.Name);
SecurityStampValidatorTest.cs (27)
62var id = new ClaimsPrincipal(new ClaimsIdentity(IdentityConstants.ApplicationScheme)); 63var ticket = new AuthenticationTicket(id, new AuthenticationProperties { IssuedUtc = DateTimeOffset.UtcNow }, IdentityConstants.ApplicationScheme); 64var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket); 78var id = new ClaimsIdentity(IdentityConstants.ApplicationScheme); 84IdentityConstants.ApplicationScheme); 86var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket); 111var id = new ClaimsIdentity(IdentityConstants.ApplicationScheme); 118authService.Setup(c => c.SignOutAsync(httpContext.Object, IdentityConstants.TwoFactorRememberMeScheme, /*properties*/null)).Returns(Task.CompletedTask).Verifiable(); 138var id = new ClaimsIdentity(IdentityConstants.ApplicationScheme); 142IdentityConstants.ApplicationScheme); 144var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket); 179var tid = new ClaimsIdentity(IdentityConstants.ApplicationScheme); 183IdentityConstants.ApplicationScheme); 185var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket); 213authService.Setup(c => c.SignOutAsync(httpContext.Object, IdentityConstants.TwoFactorRememberMeScheme, /*properties*/null)).Returns(Task.CompletedTask).Verifiable(); 220var id = new ClaimsIdentity(IdentityConstants.ApplicationScheme); 225IdentityConstants.ApplicationScheme); 226var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket); 257var id = new ClaimsIdentity(IdentityConstants.ApplicationScheme); 262IdentityConstants.ApplicationScheme); 263var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket); 295var id = new ClaimsIdentity(IdentityConstants.ApplicationScheme); 304IdentityConstants.ApplicationScheme); 305var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), 338authService.Setup(c => c.SignOutAsync(httpContext.Object, IdentityConstants.TwoFactorRememberMeScheme, /*properties*/null)).Returns(Task.CompletedTask).Verifiable(); 349IdentityConstants.TwoFactorRememberMeScheme); 350var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket);
SignInManagerTest.cs (62)
261var id = new ClaimsIdentity(IdentityConstants.TwoFactorRememberMeScheme); 263auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.TwoFactorRememberMeScheme)) 264.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(id), null, IdentityConstants.TwoFactorRememberMeScheme))).Verifiable(); 330auth.Setup(a => a.SignInAsync(context, IdentityConstants.TwoFactorUserIdScheme, 378auth.Setup(a => a.SignInAsync(context, IdentityConstants.TwoFactorUserIdScheme, 660IdentityConstants.TwoFactorUserIdScheme, 668IdentityConstants.TwoFactorUserIdScheme); 676IdentityConstants.TwoFactorUserIdScheme, 685auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.TwoFactorUserIdScheme)) 723auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.TwoFactorUserIdScheme)) 724.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null, IdentityConstants.TwoFactorUserIdScheme))).Verifiable(); 728IdentityConstants.TwoFactorRememberMeScheme, 730&& i.Identities.First().AuthenticationType == IdentityConstants.TwoFactorRememberMeScheme), 764auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.TwoFactorUserIdScheme)) 765.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null, IdentityConstants.TwoFactorUserIdScheme))).Verifiable(); 803auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.TwoFactorUserIdScheme)) 804.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null, IdentityConstants.TwoFactorUserIdScheme))).Verifiable(); 882IdentityConstants.ApplicationScheme, 886auth.Setup(a => a.SignOutAsync(context, IdentityConstants.ExternalScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable(); 887auth.Setup(a => a.SignOutAsync(context, IdentityConstants.TwoFactorUserIdScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable(); 893auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.TwoFactorUserIdScheme)) 894.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null, IdentityConstants.TwoFactorUserIdScheme))).Verifiable(); 951auth.Setup(a => a.SignInAsync(context, IdentityConstants.ApplicationScheme, It.IsAny<ClaimsPrincipal>(), It.IsAny<AuthenticationProperties>())) 994auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.ApplicationScheme)) 1046auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.ApplicationScheme)) 1082auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.ApplicationScheme)) 1134IdentityConstants.ApplicationScheme, 1141auth.Setup(a => a.SignOutAsync(context, IdentityConstants.ExternalScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable(); 1142auth.Setup(a => a.SignOutAsync(context, IdentityConstants.TwoFactorUserIdScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable(); 1151IdentityConstants.TwoFactorRememberMeScheme, 1153&& i.Identities.First().AuthenticationType == IdentityConstants.TwoFactorRememberMeScheme), 1157auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.TwoFactorUserIdScheme)) 1158.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null, IdentityConstants.TwoFactorUserIdScheme))).Verifiable(); 1192auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.TwoFactorUserIdScheme)) 1193.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null, IdentityConstants.TwoFactorUserIdScheme))).Verifiable(); 1218IdentityConstants.TwoFactorRememberMeScheme, 1220&& i.Identities.First().AuthenticationType == IdentityConstants.TwoFactorRememberMeScheme), 1252IdentityConstants.TwoFactorRememberMeScheme, 1290var id = new ClaimsIdentity(IdentityConstants.TwoFactorRememberMeScheme); 1292auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.TwoFactorRememberMeScheme)) 1293.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(id), null, IdentityConstants.TwoFactorRememberMeScheme))).Verifiable(); 1322auth.Setup(a => a.SignOutAsync(context, IdentityConstants.ApplicationScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable(); 1323auth.Setup(a => a.SignOutAsync(context, IdentityConstants.TwoFactorUserIdScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable(); 1324auth.Setup(a => a.SignOutAsync(context, IdentityConstants.ExternalScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable(); 1351auth.Setup(a => a.SignOutAsync(context, IdentityConstants.ApplicationScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromException(new InvalidOperationException("error!"))).Verifiable(); 1527IdentityConstants.ApplicationScheme, 1592auth.Setup(s => s.AuthenticateAsync(context, IdentityConstants.ExternalScheme)).ReturnsAsync(authResult); 1623auth.Setup(s => s.AuthenticateAsync(context, IdentityConstants.ExternalScheme)).ReturnsAsync(authResult); 1655auth.Setup(s => s.AuthenticateAsync(context, IdentityConstants.ExternalScheme)).ReturnsAsync(authResult); 1750auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.TwoFactorUserIdScheme)) 1751.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null, IdentityConstants.TwoFactorUserIdScheme))).Verifiable(); 1816auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.TwoFactorUserIdScheme)) 1817.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null, IdentityConstants.TwoFactorUserIdScheme))).Verifiable(); 1899private static AuthenticationScheme CreateCookieScheme(string name) => new(IdentityConstants.ApplicationScheme, displayName: null, typeof(CookieAuthenticationHandler)); 1903[IdentityConstants.ApplicationScheme] = CreateCookieScheme(IdentityConstants.ApplicationScheme), 1904[IdentityConstants.ExternalScheme] = CreateCookieScheme(IdentityConstants.ExternalScheme), 1905[IdentityConstants.TwoFactorRememberMeScheme] = CreateCookieScheme(IdentityConstants.TwoFactorRememberMeScheme), 1906[IdentityConstants.TwoFactorUserIdScheme] = CreateCookieScheme(IdentityConstants.TwoFactorUserIdScheme),
UserClaimsPrincipalFactoryTest.cs (1)
93Assert.Equal(IdentityConstants.ApplicationScheme, identity.AuthenticationType);
Microsoft.AspNetCore.Identity.UI (9)
Areas\Identity\Pages\V4\Account\Login.cshtml.cs (1)
113await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);
Areas\Identity\Pages\V4\Account\Manage\ExternalLogins.cshtml.cs (2)
130await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); 161await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);
Areas\Identity\Pages\V5\Account\Login.cshtml.cs (1)
113await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);
Areas\Identity\Pages\V5\Account\Manage\ExternalLogins.cshtml.cs (2)
130await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); 161await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);
IdentityDefaultUIConfigureOptions.cs (1)
53if (string.Equals(IdentityConstants.ApplicationScheme, name, StringComparison.Ordinal))
IdentityServiceCollectionUIExtensions.cs (2)
43o.DefaultScheme = IdentityConstants.ApplicationScheme; 44o.DefaultSignInScheme = IdentityConstants.ExternalScheme;