194 references to IdentityConstants
Identity.ExternalClaims (3)
Pages\Account\Login.cshtml.cs (1)
61
await HttpContext.SignOutAsync(
IdentityConstants
.ExternalScheme);
Pages\Account\Manage\ExternalLogins.cshtml.cs (2)
76
await HttpContext.SignOutAsync(
IdentityConstants
.ExternalScheme);
105
await HttpContext.SignOutAsync(
IdentityConstants
.ExternalScheme);
IdentitySample.Mvc (2)
Startup.cs (2)
45
o.DefaultScheme =
IdentityConstants
.ApplicationScheme;
46
o.DefaultSignInScheme =
IdentityConstants
.ExternalScheme;
IdentitySample.PasskeyConformance (2)
Program.cs (2)
17
options.DefaultScheme =
IdentityConstants
.ApplicationScheme;
18
options.DefaultSignInScheme =
IdentityConstants
.ExternalScheme;
IdentitySample.PasskeyUI (2)
Program.cs (2)
17
options.DefaultScheme =
IdentityConstants
.ApplicationScheme;
18
options.DefaultSignInScheme =
IdentityConstants
.ExternalScheme;
Microsoft.AspNetCore.Identity (66)
IdentityApiEndpointRouteBuilderExtensions.cs (4)
97
signInManager.AuthenticationScheme = useCookieScheme ?
IdentityConstants
.ApplicationScheme :
IdentityConstants
.BearerScheme;
126
var refreshTokenProtector = bearerTokenOptions.Get(
IdentityConstants
.BearerScheme).RefreshTokenProtector;
139
return TypedResults.SignIn(newPrincipal, authenticationScheme:
IdentityConstants
.BearerScheme);
IdentityCookiesBuilderExtensions.cs (11)
49
builder.AddCookie(
IdentityConstants
.ApplicationScheme, o =>
57
return new OptionsBuilder<CookieAuthenticationOptions>(builder.Services,
IdentityConstants
.ApplicationScheme);
67
builder.AddCookie(
IdentityConstants
.ExternalScheme, o =>
69
o.Cookie.Name =
IdentityConstants
.ExternalScheme;
72
return new OptionsBuilder<CookieAuthenticationOptions>(builder.Services,
IdentityConstants
.ExternalScheme);
82
builder.AddCookie(
IdentityConstants
.TwoFactorRememberMeScheme, o =>
84
o.Cookie.Name =
IdentityConstants
.TwoFactorRememberMeScheme;
90
return new OptionsBuilder<CookieAuthenticationOptions>(builder.Services,
IdentityConstants
.TwoFactorRememberMeScheme);
100
builder.AddCookie(
IdentityConstants
.TwoFactorUserIdScheme, o =>
102
o.Cookie.Name =
IdentityConstants
.TwoFactorUserIdScheme;
109
return new OptionsBuilder<CookieAuthenticationOptions>(builder.Services,
IdentityConstants
.TwoFactorUserIdScheme);
IdentityServiceCollectionExtensions.cs (19)
55
options.DefaultAuthenticateScheme =
IdentityConstants
.ApplicationScheme;
56
options.DefaultChallengeScheme =
IdentityConstants
.ApplicationScheme;
57
options.DefaultSignInScheme =
IdentityConstants
.ExternalScheme;
59
.AddCookie(
IdentityConstants
.ApplicationScheme, o =>
67
.AddCookie(
IdentityConstants
.ExternalScheme, o =>
69
o.Cookie.Name =
IdentityConstants
.ExternalScheme;
72
.AddCookie(
IdentityConstants
.TwoFactorRememberMeScheme, o =>
74
o.Cookie.Name =
IdentityConstants
.TwoFactorRememberMeScheme;
80
.AddCookie(
IdentityConstants
.TwoFactorUserIdScheme, o =>
82
o.Cookie.Name =
IdentityConstants
.TwoFactorUserIdScheme;
142
.AddAuthentication(
IdentityConstants
.BearerAndApplicationScheme)
143
.AddScheme<AuthenticationSchemeOptions, CompositeIdentityHandler>(
IdentityConstants
.BearerAndApplicationScheme, null, compositeOptions =>
145
compositeOptions.ForwardDefault =
IdentityConstants
.BearerScheme;
146
compositeOptions.ForwardAuthenticate =
IdentityConstants
.BearerAndApplicationScheme;
148
.AddBearerToken(
IdentityConstants
.BearerScheme)
162
=> services.Configure(
IdentityConstants
.ApplicationScheme, configure);
171
=> services.Configure(
IdentityConstants
.ExternalScheme, configure);
195
var bearerResult = await Context.AuthenticateAsync(
IdentityConstants
.BearerScheme);
204
return await Context.AuthenticateAsync(
IdentityConstants
.ApplicationScheme);
SecurityStampValidator.cs (3)
160
await 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)
93
/// The authentication scheme to sign in with. Defaults to <see cref="
IdentityConstants
.ApplicationScheme"/>.
95
public string AuthenticationScheme { get; set; } =
IdentityConstants
.ApplicationScheme;
306
if (await _schemes.GetSchemeAsync(
IdentityConstants
.ExternalScheme) != null)
308
await Context.SignOutAsync(
IdentityConstants
.ExternalScheme);
310
if (await _schemes.GetSchemeAsync(
IdentityConstants
.TwoFactorUserIdScheme) != null)
312
await Context.SignOutAsync(
IdentityConstants
.TwoFactorUserIdScheme);
688
var claimsIdentity = new ClaimsIdentity(
IdentityConstants
.TwoFactorUserIdScheme);
690
await Context.SignInAsync(
IdentityConstants
.TwoFactorUserIdScheme, claimsPrincipal, props);
699
var result = await Context.AuthenticateAsync(
IdentityConstants
.TwoFactorUserIdScheme);
700
await Context.SignOutAsync(
IdentityConstants
.TwoFactorUserIdScheme);
732
if (await _schemes.GetSchemeAsync(
IdentityConstants
.TwoFactorRememberMeScheme) == null)
738
var result = await Context.AuthenticateAsync(
IdentityConstants
.TwoFactorRememberMeScheme);
753
await Context.SignInAsync(
IdentityConstants
.TwoFactorRememberMeScheme,
756
_metrics?.RememberTwoFactorClient(typeof(TUser).FullName!,
IdentityConstants
.TwoFactorRememberMeScheme);
760
_metrics?.RememberTwoFactorClient(typeof(TUser).FullName!,
IdentityConstants
.TwoFactorRememberMeScheme, ex);
773
await Context.SignOutAsync(
IdentityConstants
.TwoFactorRememberMeScheme);
774
_metrics?.ForgetTwoFactorClient(typeof(TUser).FullName!,
IdentityConstants
.TwoFactorRememberMeScheme);
778
_metrics?.ForgetTwoFactorClient(typeof(TUser).FullName!,
IdentityConstants
.TwoFactorRememberMeScheme, ex);
843
if (await _schemes.GetSchemeAsync(
IdentityConstants
.ExternalScheme) != null)
845
await Context.SignOutAsync(
IdentityConstants
.ExternalScheme);
848
if (await _schemes.GetSchemeAsync(
IdentityConstants
.TwoFactorUserIdScheme) != null)
850
await Context.SignOutAsync(
IdentityConstants
.TwoFactorUserIdScheme);
1072
var auth = await Context.AuthenticateAsync(
IdentityConstants
.ExternalScheme);
1159
var identity = new ClaimsIdentity(
IdentityConstants
.TwoFactorUserIdScheme);
1171
var rememberBrowserIdentity = new ClaimsIdentity(
IdentityConstants
.TwoFactorRememberMeScheme);
1216
if (await _schemes.GetSchemeAsync(
IdentityConstants
.TwoFactorUserIdScheme) != null)
1220
await Context.SignInAsync(
IdentityConstants
.TwoFactorUserIdScheme, StoreTwoFactorInfo(userId, loginProvider));
1229
await Context.SignOutAsync(
IdentityConstants
.ExternalScheme);
1249
var result = await Context.AuthenticateAsync(
IdentityConstants
.TwoFactorUserIdScheme);
Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test (1)
SqlStoreTestBase.cs (1)
45
services.AddAuthentication(
IdentityConstants
.ApplicationScheme).AddIdentityCookies();
Microsoft.AspNetCore.Identity.FunctionalTests (10)
Infrastructure\FunctionalTestsServiceCollectionExtensions.cs (1)
28
.AddContosoAuthentication(o => o.SignInScheme =
IdentityConstants
.ExternalScheme)
ManagementTests.cs (4)
117
services.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)
171
services.AddAuthentication().AddBearerToken(
IdentityConstants
.BearerScheme, options =>
246
services.AddAuthentication().AddBearerToken(
IdentityConstants
.BearerScheme, options =>
331
services.AddAuthentication().AddBearerToken(
IdentityConstants
.BearerScheme, options =>
1335
.AddBearerToken(
IdentityConstants
.BearerScheme);
RegistrationTests.cs (1)
231
authenticationMethod = user.FindFirstValue(ClaimTypes.AuthenticationMethod),
IdentityConstants
.ApplicationScheme);
Microsoft.AspNetCore.Identity.InMemory.Test (5)
ControllerTest.cs (1)
24
auth.Setup(a => a.SignInAsync(context,
IdentityConstants
.ApplicationScheme,
FunctionalTest.cs (4)
232
Assert.Contains(
IdentityConstants
.TwoFactorRememberMeScheme + "=", setCookie);
261
Assert.Contains(
IdentityConstants
.TwoFactorRememberMeScheme + "=", setCookie);
355
var result = await context.AuthenticateAsync(
IdentityConstants
.TwoFactorUserIdScheme);
385
services.AddAuthentication(
IdentityConstants
.ApplicationScheme).AddIdentityCookies();
Microsoft.AspNetCore.Identity.Test (94)
IdentityOptionsTest.cs (4)
87
Assert.Equal("a", options.Get(
IdentityConstants
.ApplicationScheme).Cookie.Name);
88
Assert.Equal("b", options.Get(
IdentityConstants
.ExternalScheme).Cookie.Name);
89
Assert.Equal("c", options.Get(
IdentityConstants
.TwoFactorRememberMeScheme).Cookie.Name);
90
Assert.Equal("d", options.Get(
IdentityConstants
.TwoFactorUserIdScheme).Cookie.Name);
SecurityStampValidatorTest.cs (27)
62
var id = new ClaimsPrincipal(new ClaimsIdentity(
IdentityConstants
.ApplicationScheme));
63
var ticket = new AuthenticationTicket(id, new AuthenticationProperties { IssuedUtc = DateTimeOffset.UtcNow },
IdentityConstants
.ApplicationScheme);
64
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(
IdentityConstants
.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket);
78
var id = new ClaimsIdentity(
IdentityConstants
.ApplicationScheme);
84
IdentityConstants
.ApplicationScheme);
86
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(
IdentityConstants
.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket);
111
var id = new ClaimsIdentity(
IdentityConstants
.ApplicationScheme);
118
authService.Setup(c => c.SignOutAsync(httpContext.Object,
IdentityConstants
.TwoFactorRememberMeScheme, /*properties*/null)).Returns(Task.CompletedTask).Verifiable();
138
var id = new ClaimsIdentity(
IdentityConstants
.ApplicationScheme);
142
IdentityConstants
.ApplicationScheme);
144
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(
IdentityConstants
.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket);
179
var tid = new ClaimsIdentity(
IdentityConstants
.ApplicationScheme);
183
IdentityConstants
.ApplicationScheme);
185
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(
IdentityConstants
.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket);
213
authService.Setup(c => c.SignOutAsync(httpContext.Object,
IdentityConstants
.TwoFactorRememberMeScheme, /*properties*/null)).Returns(Task.CompletedTask).Verifiable();
220
var id = new ClaimsIdentity(
IdentityConstants
.ApplicationScheme);
225
IdentityConstants
.ApplicationScheme);
226
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(
IdentityConstants
.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket);
257
var id = new ClaimsIdentity(
IdentityConstants
.ApplicationScheme);
262
IdentityConstants
.ApplicationScheme);
263
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(
IdentityConstants
.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket);
295
var id = new ClaimsIdentity(
IdentityConstants
.ApplicationScheme);
304
IdentityConstants
.ApplicationScheme);
305
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(
IdentityConstants
.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(),
338
authService.Setup(c => c.SignOutAsync(httpContext.Object,
IdentityConstants
.TwoFactorRememberMeScheme, /*properties*/null)).Returns(Task.CompletedTask).Verifiable();
349
IdentityConstants
.TwoFactorRememberMeScheme);
350
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(
IdentityConstants
.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket);
SignInManagerTest.cs (62)
261
var id = new ClaimsIdentity(
IdentityConstants
.TwoFactorRememberMeScheme);
263
auth.Setup(a => a.AuthenticateAsync(context,
IdentityConstants
.TwoFactorRememberMeScheme))
264
.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(id), null,
IdentityConstants
.TwoFactorRememberMeScheme))).Verifiable();
330
auth.Setup(a => a.SignInAsync(context,
IdentityConstants
.TwoFactorUserIdScheme,
378
auth.Setup(a => a.SignInAsync(context,
IdentityConstants
.TwoFactorUserIdScheme,
498
IdentityConstants
.TwoFactorUserIdScheme,
506
IdentityConstants
.TwoFactorUserIdScheme);
514
IdentityConstants
.TwoFactorUserIdScheme,
523
auth.Setup(a => a.AuthenticateAsync(context,
IdentityConstants
.TwoFactorUserIdScheme))
561
auth.Setup(a => a.AuthenticateAsync(context,
IdentityConstants
.TwoFactorUserIdScheme))
562
.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null,
IdentityConstants
.TwoFactorUserIdScheme))).Verifiable();
566
IdentityConstants
.TwoFactorRememberMeScheme,
568
&& i.Identities.First().AuthenticationType ==
IdentityConstants
.TwoFactorRememberMeScheme),
602
auth.Setup(a => a.AuthenticateAsync(context,
IdentityConstants
.TwoFactorUserIdScheme))
603
.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null,
IdentityConstants
.TwoFactorUserIdScheme))).Verifiable();
641
auth.Setup(a => a.AuthenticateAsync(context,
IdentityConstants
.TwoFactorUserIdScheme))
642
.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null,
IdentityConstants
.TwoFactorUserIdScheme))).Verifiable();
720
IdentityConstants
.ApplicationScheme,
724
auth.Setup(a => a.SignOutAsync(context,
IdentityConstants
.ExternalScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
725
auth.Setup(a => a.SignOutAsync(context,
IdentityConstants
.TwoFactorUserIdScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
731
auth.Setup(a => a.AuthenticateAsync(context,
IdentityConstants
.TwoFactorUserIdScheme))
732
.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null,
IdentityConstants
.TwoFactorUserIdScheme))).Verifiable();
789
auth.Setup(a => a.SignInAsync(context,
IdentityConstants
.ApplicationScheme, It.IsAny<ClaimsPrincipal>(), It.IsAny<AuthenticationProperties>()))
832
auth.Setup(a => a.AuthenticateAsync(context,
IdentityConstants
.ApplicationScheme))
884
auth.Setup(a => a.AuthenticateAsync(context,
IdentityConstants
.ApplicationScheme))
920
auth.Setup(a => a.AuthenticateAsync(context,
IdentityConstants
.ApplicationScheme))
972
IdentityConstants
.ApplicationScheme,
979
auth.Setup(a => a.SignOutAsync(context,
IdentityConstants
.ExternalScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
980
auth.Setup(a => a.SignOutAsync(context,
IdentityConstants
.TwoFactorUserIdScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
989
IdentityConstants
.TwoFactorRememberMeScheme,
991
&& i.Identities.First().AuthenticationType ==
IdentityConstants
.TwoFactorRememberMeScheme),
995
auth.Setup(a => a.AuthenticateAsync(context,
IdentityConstants
.TwoFactorUserIdScheme))
996
.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null,
IdentityConstants
.TwoFactorUserIdScheme))).Verifiable();
1030
auth.Setup(a => a.AuthenticateAsync(context,
IdentityConstants
.TwoFactorUserIdScheme))
1031
.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null,
IdentityConstants
.TwoFactorUserIdScheme))).Verifiable();
1056
IdentityConstants
.TwoFactorRememberMeScheme,
1058
&& i.Identities.First().AuthenticationType ==
IdentityConstants
.TwoFactorRememberMeScheme),
1090
IdentityConstants
.TwoFactorRememberMeScheme,
1128
var id = new ClaimsIdentity(
IdentityConstants
.TwoFactorRememberMeScheme);
1130
auth.Setup(a => a.AuthenticateAsync(context,
IdentityConstants
.TwoFactorRememberMeScheme))
1131
.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(id), null,
IdentityConstants
.TwoFactorRememberMeScheme))).Verifiable();
1160
auth.Setup(a => a.SignOutAsync(context,
IdentityConstants
.ApplicationScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
1161
auth.Setup(a => a.SignOutAsync(context,
IdentityConstants
.TwoFactorUserIdScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
1162
auth.Setup(a => a.SignOutAsync(context,
IdentityConstants
.ExternalScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
1189
auth.Setup(a => a.SignOutAsync(context,
IdentityConstants
.ApplicationScheme, It.IsAny<AuthenticationProperties>())).Returns(Task.FromException(new InvalidOperationException("error!"))).Verifiable();
1365
IdentityConstants
.ApplicationScheme,
1430
auth.Setup(s => s.AuthenticateAsync(context,
IdentityConstants
.ExternalScheme)).ReturnsAsync(authResult);
1461
auth.Setup(s => s.AuthenticateAsync(context,
IdentityConstants
.ExternalScheme)).ReturnsAsync(authResult);
1493
auth.Setup(s => s.AuthenticateAsync(context,
IdentityConstants
.ExternalScheme)).ReturnsAsync(authResult);
1588
auth.Setup(a => a.AuthenticateAsync(context,
IdentityConstants
.TwoFactorUserIdScheme))
1589
.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null,
IdentityConstants
.TwoFactorUserIdScheme))).Verifiable();
1654
auth.Setup(a => a.AuthenticateAsync(context,
IdentityConstants
.TwoFactorUserIdScheme))
1655
.ReturnsAsync(AuthenticateResult.Success(new AuthenticationTicket(id, null,
IdentityConstants
.TwoFactorUserIdScheme))).Verifiable();
1737
private static AuthenticationScheme CreateCookieScheme(string name) => new(
IdentityConstants
.ApplicationScheme, displayName: null, typeof(CookieAuthenticationHandler));
1741
[
IdentityConstants
.ApplicationScheme] = CreateCookieScheme(
IdentityConstants
.ApplicationScheme),
1742
[
IdentityConstants
.ExternalScheme] = CreateCookieScheme(
IdentityConstants
.ExternalScheme),
1743
[
IdentityConstants
.TwoFactorRememberMeScheme] = CreateCookieScheme(
IdentityConstants
.TwoFactorRememberMeScheme),
1744
[
IdentityConstants
.TwoFactorUserIdScheme] = CreateCookieScheme(
IdentityConstants
.TwoFactorUserIdScheme),
UserClaimsPrincipalFactoryTest.cs (1)
93
Assert.Equal(
IdentityConstants
.ApplicationScheme, identity.AuthenticationType);
Microsoft.AspNetCore.Identity.UI (9)
Areas\Identity\Pages\V4\Account\Login.cshtml.cs (1)
113
await HttpContext.SignOutAsync(
IdentityConstants
.ExternalScheme);
Areas\Identity\Pages\V4\Account\Manage\ExternalLogins.cshtml.cs (2)
130
await HttpContext.SignOutAsync(
IdentityConstants
.ExternalScheme);
161
await HttpContext.SignOutAsync(
IdentityConstants
.ExternalScheme);
Areas\Identity\Pages\V5\Account\Login.cshtml.cs (1)
113
await HttpContext.SignOutAsync(
IdentityConstants
.ExternalScheme);
Areas\Identity\Pages\V5\Account\Manage\ExternalLogins.cshtml.cs (2)
130
await HttpContext.SignOutAsync(
IdentityConstants
.ExternalScheme);
161
await HttpContext.SignOutAsync(
IdentityConstants
.ExternalScheme);
IdentityDefaultUIConfigureOptions.cs (1)
53
if (string.Equals(
IdentityConstants
.ApplicationScheme, name, StringComparison.Ordinal))
IdentityServiceCollectionUIExtensions.cs (2)
43
o.DefaultScheme =
IdentityConstants
.ApplicationScheme;
44
o.DefaultSignInScheme =
IdentityConstants
.ExternalScheme;