394 references to ClaimTypes
Aspire.Dashboard (4)
Authentication\UnsecuredAuthenticationHandler.cs (1)
20[new Claim(ClaimTypes.NameIdentifier, "Local"), new Claim(FrontendAuthorizationDefaults.UnsecuredClaimName, bool.TrueString)],
DashboardWebApplication.cs (2)
732new Claim(ClaimTypes.NameIdentifier, 735new Claim(ClaimTypes.Name,
Model\ValidateTokenMiddleware.cs (1)
94[new Claim(ClaimTypes.NameIdentifier, "Local")],
BasicTestApp (1)
AuthTest\ServerAuthenticationStateProvider.cs (1)
29var claims = new[] { new Claim(ClaimTypes.Name, data.UserName) }
BasicWebSite (3)
BasicAuthenticationHandler.cs (2)
29new Claim(ClaimTypes.Role, "Administrator"), 30new Claim(ClaimTypes.NameIdentifier, "John")
ConfigureAuthPolicies.cs (1)
23policy.RequireClaim(ClaimTypes.NameIdentifier);
Certificate.Sample (2)
Startup.cs (2)
24new Claim(ClaimTypes.NameIdentifier, context.ClientCertificate.Subject, ClaimValueTypes.String, context.Options.ClaimsIssuer), 25new Claim(ClaimTypes.Name, context.ClientCertificate.Subject, ClaimValueTypes.String, context.Options.ClaimsIssuer)
CookiePolicySample (1)
Startup.cs (1)
43var user = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "bob") },
CookieSample (1)
Program.cs (1)
43var user = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "bob") }, CookieAuthenticationDefaults.AuthenticationScheme));
CookieSessionSample (2)
Startup.cs (2)
36claims.Add(new Claim(ClaimTypes.Name, "bob")); 39claims.Add(new Claim(ClaimTypes.Role, "SomeRandomGroup" + i, ClaimValueTypes.String, "IssuedByBob", "OriginalIssuerJoe"));
CustomPolicyProvider (3)
Authorization\MinimumAgeAuthorizationHandler.cs (1)
32var dateOfBirthClaim = context.User.FindFirst(c => c.Type == ClaimTypes.DateOfBirth);
Controllers\AccountController.cs (2)
31claims.Add(new Claim(ClaimTypes.Name, userName)); 34claims.Add(new Claim(ClaimTypes.DateOfBirth, birthDate));
dotnet-user-jwts (1)
Helpers\JwtIssuer.cs (1)
41identity.AddClaims(rolesToAdd.Select(r => new Claim(ClaimTypes.Role, r)));
Identity.DefaultUI.WebSite (3)
Pages\Contoso\Login.cshtml.cs (3)
57new Claim(ClaimTypes.NameIdentifier, Input.Login) 60ClaimTypes.NameIdentifier, 61ClaimTypes.Role);
Identity.ExternalClaims (4)
Pages\Account\ExternalLogin.cshtml.cs (3)
98if (info.Principal.HasClaim(c => c.Type == ClaimTypes.Email)) 102Email = info.Principal.FindFirstValue(ClaimTypes.Email) 127await _userManager.AddClaimAsync(user, info.Principal.FindFirst(ClaimTypes.Gender));
Startup.cs (1)
49o.ClaimActions.MapJsonKey(ClaimTypes.Gender, "gender");
IdentitySample.Mvc (1)
Controllers\AccountController.cs (1)
191var email = info.Principal.FindFirstValue(ClaimTypes.Email);
JwtSample (2)
Startup.cs (2)
25policy.RequireClaim(ClaimTypes.NameIdentifier); 79var claims = new[] { new Claim(ClaimTypes.NameIdentifier, httpContext.Request.Query["user"]) };
Microsoft.AspNetCore.Antiforgery (2)
Internal\DefaultClaimUidExtractor.cs (2)
68claim => string.Equals(ClaimTypes.NameIdentifier, claim.Type, StringComparison.Ordinal)); 80claim => string.Equals(ClaimTypes.Upn, claim.Type, StringComparison.Ordinal));
Microsoft.AspNetCore.Antiforgery.Test (27)
DefaultClaimUidExtractorTest.cs (27)
39mockIdentity.Setup(o => o.Claims).Returns(new Claim[] { new Claim(ClaimTypes.Name, "someName") }); 55identity.AddClaim(new Claim(ClaimTypes.Email, "someone@antiforgery.com")); 56identity.AddClaim(new Claim(ClaimTypes.GivenName, "some")); 57identity.AddClaim(new Claim(ClaimTypes.Surname, "one")); 58identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, string.Empty)); 85identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, "nameIdentifierValue")); 93ClaimTypes.NameIdentifier, 104identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, "nameIdentifierValue")); 106identity.AddClaim(new Claim(ClaimTypes.Upn, "upnClaimValue")); 125identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, "nameIdentifierValue")); 126identity.AddClaim(new Claim(ClaimTypes.Upn, "upnClaimValue")); 134ClaimTypes.NameIdentifier, 146identity.AddClaim(new Claim(ClaimTypes.Upn, "upnClaimValue")); 154ClaimTypes.Upn, 167identity2.AddClaim(new Claim(ClaimTypes.NameIdentifier, "nameIdentifierValue")); 175ClaimTypes.NameIdentifier, 188identity2.AddClaim(new Claim(ClaimTypes.Email, "email@domain.com")); 190identity3.AddClaim(new Claim(ClaimTypes.Country, "countryValue")); 192identity4.AddClaim(new Claim(ClaimTypes.Name, "claimName")); 201ClaimTypes.Country, 204ClaimTypes.Email, 207ClaimTypes.Name, 218identity1.AddClaim(new Claim(ClaimTypes.NameIdentifier, "nameIdentifierValue")); 229ClaimTypes.NameIdentifier, 240identity1.AddClaim(new Claim(ClaimTypes.Upn, "upnValue")); 242identity2.AddClaim(new Claim(ClaimTypes.NameIdentifier, "nameIdentifierValue")); 251ClaimTypes.Upn,
Microsoft.AspNetCore.Authentication.Certificate (8)
CertificateAuthenticationHandler.cs (8)
259claims.Add(new Claim(ClaimTypes.Thumbprint, thumbprint, ClaimValueTypes.Base64Binary, Options.ClaimsIssuer)); 264claims.Add(new Claim(ClaimTypes.X500DistinguishedName, value, ClaimValueTypes.String, Options.ClaimsIssuer)); 270claims.Add(new Claim(ClaimTypes.SerialNumber, value, ClaimValueTypes.String, Options.ClaimsIssuer)); 276claims.Add(new Claim(ClaimTypes.Dns, value, ClaimValueTypes.String, Options.ClaimsIssuer)); 282claims.Add(new Claim(ClaimTypes.Name, value, ClaimValueTypes.String, Options.ClaimsIssuer)); 288claims.Add(new Claim(ClaimTypes.Email, value, ClaimValueTypes.String, Options.ClaimsIssuer)); 294claims.Add(new Claim(ClaimTypes.Upn, value, ClaimValueTypes.String, Options.ClaimsIssuer)); 300claims.Add(new Claim(ClaimTypes.Uri, value, ClaimValueTypes.String, Options.ClaimsIssuer));
Microsoft.AspNetCore.Authentication.Facebook (8)
FacebookOptions.cs (8)
32ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); 35ClaimActions.MapJsonKey(ClaimTypes.DateOfBirth, "birthday"); 36ClaimActions.MapJsonKey(ClaimTypes.Email, "email"); 37ClaimActions.MapJsonKey(ClaimTypes.Name, "name"); 38ClaimActions.MapJsonKey(ClaimTypes.GivenName, "first_name"); 40ClaimActions.MapJsonKey(ClaimTypes.Surname, "last_name"); 41ClaimActions.MapJsonKey(ClaimTypes.Gender, "gender"); 44ClaimActions.MapJsonKey(ClaimTypes.Locality, "locale");
Microsoft.AspNetCore.Authentication.Google (6)
GoogleOptions.cs (6)
29ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); // v2 30ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "sub"); // v3 31ClaimActions.MapJsonKey(ClaimTypes.Name, "name"); 32ClaimActions.MapJsonKey(ClaimTypes.GivenName, "given_name"); 33ClaimActions.MapJsonKey(ClaimTypes.Surname, "family_name"); 35ClaimActions.MapJsonKey(ClaimTypes.Email, "email");
Microsoft.AspNetCore.Authentication.MicrosoftAccount (5)
MicrosoftAccountOptions.cs (5)
27ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); 28ClaimActions.MapJsonKey(ClaimTypes.Name, "displayName"); 29ClaimActions.MapJsonKey(ClaimTypes.GivenName, "givenName"); 30ClaimActions.MapJsonKey(ClaimTypes.Surname, "surname"); 31ClaimActions.MapCustomJson(ClaimTypes.Email, user => user.GetString("mail") ?? user.GetString("userPrincipalName"));
Microsoft.AspNetCore.Authentication.Test (146)
CertificateTests.cs (19)
490actual = responseAsXml.Elements("claim").Where(claim => claim.Attribute("Type").Value == ClaimTypes.Thumbprint); 497actual = responseAsXml.Elements("claim").Where(claim => claim.Attribute("Type").Value == ClaimTypes.X500DistinguishedName); 507actual = responseAsXml.Elements("claim").Where(claim => claim.Attribute("Type").Value == ClaimTypes.SerialNumber); 517actual = responseAsXml.Elements("claim").Where(claim => claim.Attribute("Type").Value == ClaimTypes.Dns); 527actual = responseAsXml.Elements("claim").Where(claim => claim.Attribute("Type").Value == ClaimTypes.Email); 537actual = responseAsXml.Elements("claim").Where(claim => claim.Attribute("Type").Value == ClaimTypes.Name); 547actual = responseAsXml.Elements("claim").Where(claim => claim.Attribute("Type").Value == ClaimTypes.Upn); 557actual = responseAsXml.Elements("claim").Where(claim => claim.Attribute("Type").Value == ClaimTypes.Uri); 589new Claim(ClaimTypes.Name, Expected, ClaimValueTypes.String, context.Options.ClaimsIssuer), 615var name = responseAsXml.Elements("claim").Where(claim => claim.Attribute("Type").Value == ClaimTypes.Name); 634name = responseAsXml.Elements("claim").Where(claim => claim.Attribute("Type").Value == ClaimTypes.Name); 660new Claim(ClaimTypes.Name, Expected, ClaimValueTypes.String, context.Options.ClaimsIssuer) 685var actual = responseAsXml.Elements("claim").Where(claim => claim.Attribute("Type").Value == ClaimTypes.Name); 716new Claim(ClaimTypes.Name, Expected, ClaimValueTypes.String, context.Options.ClaimsIssuer), 742var name = responseAsXml.Elements("claim").Where(claim => claim.Attribute("Type").Value == ClaimTypes.Name); 761name = responseAsXml.Elements("claim").Where(claim => claim.Attribute("Type").Value == ClaimTypes.Name); 783name = responseAsXml.Elements("claim").Where(claim => claim.Attribute("Type").Value == ClaimTypes.Name); 918new Claim(ClaimTypes.NameIdentifier, context.ClientCertificate.Subject, ClaimValueTypes.String, context.Options.ClaimsIssuer), 919new Claim(ClaimTypes.Name, context.ClientCertificate.Subject, ClaimValueTypes.String, context.Options.ClaimsIssuer)
CookieTests.cs (52)
262Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); 273Assert.Equal("Alice", FindClaimValue(transaction4, ClaimTypes.Name)); 297Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); 306Assert.Null(FindClaimValue(transaction3, ClaimTypes.Name)); 473Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); 489Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); 517Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); 519Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); 521Assert.Null(FindClaimValue(transaction4, ClaimTypes.Name)); 551Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); 553Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); 555Assert.Null(FindClaimValue(transaction4, ClaimTypes.Name)); 584Assert.Null(FindClaimValue(transaction2, ClaimTypes.Name)); 613Assert.Null(FindClaimValue(transaction2, ClaimTypes.Name)); 642Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); 678Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); 684Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); 690Assert.Null(FindClaimValue(transaction4, ClaimTypes.Name)); 696Assert.Null(FindClaimValue(transaction5, ClaimTypes.Name)); 723Assert.Equal("Alice2", FindClaimValue(transaction2, ClaimTypes.Name)); 755Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); 758Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); 765Assert.Equal("Alice2", FindClaimValue(transaction4, ClaimTypes.Name)); 771Assert.Equal("Alice2", FindClaimValue(transaction5, ClaimTypes.Name)); 799Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); 805Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); 811Assert.Equal("Alice", FindClaimValue(transaction4, ClaimTypes.Name)); 817Assert.Null(FindClaimValue(transaction5, ClaimTypes.Name)); 960Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); 966Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); 972Assert.Null(FindClaimValue(transaction4, ClaimTypes.Name)); 978Assert.Null(FindClaimValue(transaction5, ClaimTypes.Name)); 1012Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); 1024Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); 1030Assert.Equal("Alice", FindClaimValue(transaction4, ClaimTypes.Name)); 1059Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); 1065Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); 1071Assert.Null(FindClaimValue(transaction4, ClaimTypes.Name)); 1089Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); 1095Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); 1102Assert.Equal("Alice", FindClaimValue(transaction4, ClaimTypes.Name)); 1108Assert.Equal("Alice", FindClaimValue(transaction5, ClaimTypes.Name)); 1135Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); 1141Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); 1148Assert.Equal("Alice", FindClaimValue(transaction4, ClaimTypes.Name)); 1154Assert.Equal("Alice", FindClaimValue(transaction5, ClaimTypes.Name)); 1183Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); 1189Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); 1196Assert.Equal("Alice", FindClaimValue(transaction4, ClaimTypes.Name)); 1201Assert.Equal("Alice", FindClaimValue(transaction5, ClaimTypes.Name)); 1206Assert.Equal("Alice", FindClaimValue(transaction6, ClaimTypes.Name)); 1739Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name));
DynamicSchemeTests.cs (9)
34Assert.Equal("One", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "One")); 39Assert.Equal("One", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "One")); 46Assert.Equal("Two", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "Two")); 51Assert.Equal("One", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "One")); 54Assert.Equal("Two", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "Two")); 69Assert.Equal("One", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "One")); 75Assert.Equal("Two", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "Two")); 82Assert.Equal("One", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "One")); 119id.AddClaim(new Claim(ClaimTypes.NameIdentifier, Scheme.Name, ClaimValueTypes.String, Scheme.Name));
GoogleTests.cs (21)
575Assert.Equal("Test Name", transaction.FindClaimValue(ClaimTypes.Name, expectedIssuer)); 576Assert.Equal("Test User ID", transaction.FindClaimValue(ClaimTypes.NameIdentifier, expectedIssuer)); 577Assert.Equal("Test Given Name", transaction.FindClaimValue(ClaimTypes.GivenName, expectedIssuer)); 578Assert.Equal("Test Family Name", transaction.FindClaimValue(ClaimTypes.Surname, expectedIssuer)); 579Assert.Equal("Test email", transaction.FindClaimValue(ClaimTypes.Email, expectedIssuer)); 792Assert.Equal("Test email", context.Identity.FindFirst(ClaimTypes.Email)?.Value); 793Assert.Equal("Test User ID", context.Identity.FindFirst(ClaimTypes.NameIdentifier)?.Value); 794Assert.Equal("Test Name", context.Identity.FindFirst(ClaimTypes.Name)?.Value); 795Assert.Equal("Test Family Name", context.Identity.FindFirst(ClaimTypes.Surname)?.Value); 796Assert.Equal("Test Given Name", context.Identity.FindFirst(ClaimTypes.GivenName)?.Value); 898Assert.Equal("Test Name", transaction.FindClaimValue(ClaimTypes.Name)); 899Assert.Equal("Test User ID", transaction.FindClaimValue(ClaimTypes.NameIdentifier)); 900Assert.Equal("Test Given Name", transaction.FindClaimValue(ClaimTypes.GivenName)); 901Assert.Equal("Test Family Name", transaction.FindClaimValue(ClaimTypes.Surname)); 902Assert.Equal("Test email", transaction.FindClaimValue(ClaimTypes.Email)); 942Assert.Equal("Test Name", transaction.FindClaimValue(ClaimTypes.Name)); 943Assert.Equal("Test User ID", transaction.FindClaimValue(ClaimTypes.NameIdentifier)); 944Assert.Equal("Test Given Name", transaction.FindClaimValue(ClaimTypes.GivenName)); 945Assert.Equal("Test Family Name", transaction.FindClaimValue(ClaimTypes.Surname)); 946Assert.Equal("Test email", transaction.FindClaimValue(ClaimTypes.Email)); 986Assert.Null(transaction.FindClaimValue(ClaimTypes.Name));
JwtBearerTests.cs (12)
54new Claim(ClaimTypes.NameIdentifier, "Bob") 91new Claim(ClaimTypes.NameIdentifier, "Bob") 229new Claim(ClaimTypes.NameIdentifier, "Bob le Magnifique"), 230new Claim(ClaimTypes.Email, "bob@contoso.com"), 493var identifier = identity.FindFirst(ClaimTypes.NameIdentifier); 502identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, "Bob le Magnifique")); 923new Claim(ClaimTypes.NameIdentifier, "Bob") 968new Claim(ClaimTypes.NameIdentifier, "Bob") 1148new Claim(ClaimTypes.NameIdentifier, "Bob le Tout Puissant"), 1149new Claim(ClaimTypes.Email, "bob@contoso.com"), 1193var identifier = context.User.FindFirst(ClaimTypes.NameIdentifier); 1279new Claim(ClaimTypes.NameIdentifier, "Bob")
JwtBearerTests_Handler.cs (12)
47new Claim(ClaimTypes.NameIdentifier, "Bob") 83new Claim(ClaimTypes.NameIdentifier, "Bob") 217new Claim(ClaimTypes.NameIdentifier, "Bob le Magnifique"), 218new Claim(ClaimTypes.Email, "bob@contoso.com"), 463var identifier = identity.FindFirst(ClaimTypes.NameIdentifier); 472identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, "Bob le Magnifique")); 869new Claim(ClaimTypes.NameIdentifier, "Bob") 913new Claim(ClaimTypes.NameIdentifier, "Bob") 1211new Claim(ClaimTypes.NameIdentifier, "Bob le Tout Puissant"), 1212new Claim(ClaimTypes.Email, "bob@contoso.com"), 1261var identifier = context.User.FindFirst(ClaimTypes.NameIdentifier); 1347new Claim(ClaimTypes.NameIdentifier, "Bob")
OpenIdConnect\OpenIdConnectEventTests.cs (2)
759new Claim(ClaimTypes.NameIdentifier, "Bob le Magnifique"), 760new Claim(ClaimTypes.Email, "bob@contoso.com"),
OpenIdConnect\OpenIdConnectEventTests_Handler.cs (2)
759new Claim(ClaimTypes.NameIdentifier, "Bob le Magnifique"), 760new Claim(ClaimTypes.Email, "bob@contoso.com"),
PolicyTests.cs (10)
39Assert.Equal("auth1", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth1")); 42Assert.Equal("auth1", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth1")); 45Assert.Equal("auth2", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth2")); 48Assert.Equal("auth3", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth3")); 51Assert.Equal("auth2", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth2")); 354Assert.Equal("auth1", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth1")); 356Assert.Equal("auth2", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth2")); 358Assert.Equal("auth3", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth3")); 375id.AddClaim(new Claim(ClaimTypes.NameIdentifier, Scheme.Name, ClaimValueTypes.String, Scheme.Name)); 425id.AddClaim(new Claim(ClaimTypes.NameIdentifier, Scheme.Name, ClaimValueTypes.String, Scheme.Name));
TestHandlers.cs (2)
40id.AddClaim(new Claim(ClaimTypes.NameIdentifier, Scheme.Name, ClaimValueTypes.String, Scheme.Name)); 72id.AddClaim(new Claim(ClaimTypes.NameIdentifier, Scheme.Name, ClaimValueTypes.String, Scheme.Name));
TwitterTests.cs (5)
445Assert.Equal("@dotnet", transaction.FindClaimValue(ClaimTypes.Name, expectedIssuer)); 446Assert.Equal("123456", transaction.FindClaimValue(ClaimTypes.NameIdentifier, expectedIssuer)); 535Assert.Equal("@dotnet", transaction.FindClaimValue(ClaimTypes.Name, expectedIssuer)); 536Assert.Equal("123456", transaction.FindClaimValue(ClaimTypes.NameIdentifier, expectedIssuer)); 539Assert.Equal("Test email", transaction.FindClaimValue(ClaimTypes.Email, expectedIssuer));
Microsoft.AspNetCore.Authentication.Twitter (3)
TwitterHandler.cs (2)
109new Claim(ClaimTypes.NameIdentifier, accessToken.UserId, ClaimValueTypes.String, ClaimsIssuer), 110new Claim(ClaimTypes.Name, accessToken.ScreenName, ClaimValueTypes.String, ClaimsIssuer),
TwitterOptions.cs (1)
28ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email);
Microsoft.AspNetCore.Authorization.Test (18)
AuthorizationMiddlewareTests.cs (5)
1016new Claim(ClaimTypes.Role, "Administrator"), 1017new Claim(ClaimTypes.Role, "User"), 1018new Claim(ClaimTypes.NameIdentifier, "John")}, 1026new Claim(ClaimTypes.Role, "Token"), 1027new Claim(ClaimTypes.NameIdentifier, "John Bear")},
DefaultAuthorizationServiceTests.cs (13)
349.RequireClaim(ClaimTypes.Role, "User"); 354new Claim(ClaimTypes.Role, "User"), 355new Claim(ClaimTypes.Role, "Administrator") 371var policy = new AuthorizationPolicyBuilder().RequireClaim(ClaimTypes.Role); 376new Claim(ClaimTypes.Role, "none"), 392var policy = new AuthorizationPolicyBuilder("AuthType").RequireClaim(ClaimTypes.Name); 395new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, "Name") }, "AuthType") 412new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Role, "Admin") }, "AuthType") 429new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Role, "Users") }, "AuthType")); 447new Claim(ClaimTypes.Role, "Nope"), 495new Claim(ClaimTypes.Name, "Tek"), 521new Claim(ClaimTypes.Name, "Hao"), 591new Claim(ClaimTypes.Name, "Name"),
Microsoft.AspNetCore.Components.Authorization (1)
ClaimData.cs (1)
37/// Gets the claim type of the claim. <seealso cref="ClaimTypes"/>.
Microsoft.AspNetCore.Components.Server.Tests (1)
Circuits\RevalidatingServerAuthenticationStateProviderTest.cs (1)
219? new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, "testauth")
Microsoft.AspNetCore.Http.Connections (2)
Internal\HttpConnectionDispatcher.cs (2)
641var originalName = connection.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; 642var newName = connection.HttpContext?.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
Microsoft.AspNetCore.Http.Connections.Tests (3)
HttpConnectionDispatcherTests.cs (3)
3242var claims = new[] { new Claim(ClaimTypes.NameIdentifier, httpContext.Request.Query["user"]) }; 3306new Claim(ClaimTypes.NameIdentifier, context.Request.Query["user"]) 3404var claims = new[] { new Claim(ClaimTypes.NameIdentifier, httpContext.Request.Query["user"]) };
Microsoft.AspNetCore.Identity (10)
SignInManager.cs (10)
205var authenticationMethod = auth.Principal?.FindFirst(ClaimTypes.AuthenticationMethod); 250additionalClaims.Add(new Claim(ClaimTypes.AuthenticationMethod, authenticationMethod)); 744return (result?.Principal != null && result.Principal.FindFirstValue(ClaimTypes.Name) == userId); 846claims.Add(new Claim(ClaimTypes.AuthenticationMethod, twoFactorInfo.LoginProvider)); 1097var providerKey = auth.Principal.FindFirstValue(ClaimTypes.NameIdentifier) ?? auth.Principal.FindFirstValue("sub"); 1169identity.AddClaim(new Claim(ClaimTypes.Name, userId)); 1172identity.AddClaim(new Claim(ClaimTypes.AuthenticationMethod, loginProvider)); 1181rememberBrowserIdentity.AddClaim(new Claim(ClaimTypes.Name, userId)); 1264var userId = result.Principal.FindFirstValue(ClaimTypes.Name); 1279LoginProvider = result.Principal.FindFirstValue(ClaimTypes.AuthenticationMethod),
Microsoft.AspNetCore.Identity.FunctionalTests (25)
ManagementTests.cs (2)
172Assert.NotNull(principals[1].Identities.Single().Claims.Single(c => c.Type == ClaimTypes.AuthenticationMethod).Value); 179AssertClaimsEqual(principals[1], principals[2], ClaimTypes.AuthenticationMethod);
MapIdentityApiTests.cs (22)
1045Assert.Equal(Email, GetSingleClaim(infoClaims, ClaimTypes.Name)); 1046Assert.Equal(Email, GetSingleClaim(infoClaims, ClaimTypes.Email)); 1048var originalNameIdentifier = GetSingleClaim(infoClaims, ClaimTypes.NameIdentifier); 1063Assert.Equal(Email, GetSingleClaim(infoPostClaims, ClaimTypes.Name)); 1064Assert.Equal(Email, GetSingleClaim(infoPostClaims, ClaimTypes.Email)); 1065Assert.Equal(originalNameIdentifier, GetSingleClaim(infoPostClaims, ClaimTypes.NameIdentifier)); 1089Assert.Equal(Email, GetSingleClaim(claimsAfterEmailChange, ClaimTypes.Name)); 1090Assert.Equal(Email, GetSingleClaim(claimsAfterEmailChange, ClaimTypes.Email)); 1091Assert.Equal(originalNameIdentifier, GetSingleClaim(claimsAfterEmailChange, ClaimTypes.NameIdentifier)); 1104Assert.Equal(newEmail, GetSingleClaim(claimsAfterFinalLogin, ClaimTypes.Name)); 1105Assert.Equal(newEmail, GetSingleClaim(claimsAfterFinalLogin, ClaimTypes.Email)); 1106Assert.Equal(originalNameIdentifier, GetSingleClaim(claimsAfterFinalLogin, ClaimTypes.NameIdentifier)); 1140Assert.Equal(Email, GetSingleClaim(infoClaims, ClaimTypes.Name)); 1141Assert.Equal(Email, GetSingleClaim(infoClaims, ClaimTypes.Email)); 1143var originalNameIdentifier = GetSingleClaim(infoClaims, ClaimTypes.NameIdentifier); 1156Assert.Equal(Email, GetSingleClaim(infoPostClaims, ClaimTypes.Email)); 1157Assert.Equal(originalNameIdentifier, GetSingleClaim(infoPostClaims, ClaimTypes.NameIdentifier)); 1178Assert.Equal(Email, GetSingleClaim(claimsAfterEmailChange, ClaimTypes.Email)); 1179Assert.Equal(originalNameIdentifier, GetSingleClaim(claimsAfterEmailChange, ClaimTypes.NameIdentifier)); 1189Assert.Equal(newEmail, GetSingleClaim(claimsAfterFinalLogin, ClaimTypes.Name)); 1190Assert.Equal(newEmail, GetSingleClaim(claimsAfterFinalLogin, ClaimTypes.Email)); 1191Assert.Equal(originalNameIdentifier, GetSingleClaim(claimsAfterFinalLogin, ClaimTypes.NameIdentifier));
RegistrationTests.cs (1)
231authenticationMethod = user.FindFirstValue(ClaimTypes.AuthenticationMethod), IdentityConstants.ApplicationScheme);
Microsoft.AspNetCore.Identity.InMemory.Test (14)
ControllerTest.cs (1)
68externalIdentity.AddClaim(new Claim(ClaimTypes.NameIdentifier, externalId));
FunctionalTest.cs (13)
61Assert.Equal("hao", FindClaimValue(transaction3, ClaimTypes.Name)); 62Assert.Equal("role", FindClaimValue(transaction3, ClaimTypes.Role)); 96Assert.Equal("hao", FindClaimValue(transaction3, ClaimTypes.Name)); 102Assert.Equal("hao", FindClaimValue(transaction4, ClaimTypes.Name)); 108Assert.Null(FindClaimValue(transaction5, ClaimTypes.Name)); 142Assert.Equal("hao", FindClaimValue(transaction3, ClaimTypes.Name)); 148Assert.Equal("hao", FindClaimValue(transaction4, ClaimTypes.Name)); 156Assert.Equal("hao", FindClaimValue(transaction5, ClaimTypes.Name)); 160Assert.Equal("hao", FindClaimValue(transaction6, ClaimTypes.Name)); 194Assert.Equal("hao", FindClaimValue(transaction3, ClaimTypes.Name)); 200Assert.Equal("hao", FindClaimValue(transaction4, ClaimTypes.Name)); 208Assert.Equal("hao", FindClaimValue(transaction5, ClaimTypes.Name)); 213Assert.Equal("hao", FindClaimValue(transaction6, ClaimTypes.Name));
Microsoft.AspNetCore.Identity.Test (29)
IdentityOptionsTest.cs (3)
31Assert.Equal(ClaimTypes.Role, options.ClaimsIdentity.RoleClaimType); 32Assert.Equal(ClaimTypes.Name, options.ClaimsIdentity.UserNameClaimType); 33Assert.Equal(ClaimTypes.NameIdentifier, options.ClaimsIdentity.UserIdClaimType);
PrincipalExtensionsTest.cs (2)
24new Claim(ClaimTypes.NameIdentifier, "NameIdentifier", null, ExternalAuthenticationScheme), 25new Claim(ClaimTypes.Name, "Name")
SecurityStampValidatorTest.cs (7)
79id.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id)); 112id.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id)); 139id.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id)); 180tid.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id)); 221id.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id)); 258id.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id)); 296id.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id));
SignInManagerTest.cs (17)
262id.AddClaim(new Claim(ClaimTypes.Name, user.Id)); 331It.Is<ClaimsPrincipal>(id => id.FindFirstValue(ClaimTypes.Name) == user.Id), 379It.Is<ClaimsPrincipal>(id => id.FindFirstValue(ClaimTypes.Name) == user.Id), 567It.Is<ClaimsPrincipal>(i => i.FindFirstValue(ClaimTypes.Name) == user.Id 721It.Is<ClaimsPrincipal>(i => i.FindFirstValue(ClaimTypes.AuthenticationMethod) == loginProvider 722&& i.FindFirstValue(ClaimTypes.NameIdentifier) == user.Id), 826id.AddClaim(new Claim(ClaimTypes.AuthenticationMethod, loginProvider)); 845claims.Any(claim => claim.Type == ClaimTypes.AuthenticationMethod && claim.Value == loginProvider)))) 973It.Is<ClaimsPrincipal>(i => i.FindFirstValue(ClaimTypes.AuthenticationMethod) == loginProvider 975&& i.FindFirstValue(ClaimTypes.NameIdentifier) == user.Id), 990It.Is<ClaimsPrincipal>(i => i.FindFirstValue(ClaimTypes.Name) == user.Id 1057It.Is<ClaimsPrincipal>(i => i.FindFirstValue(ClaimTypes.Name) == user.Id 1129id.AddClaim(new Claim(ClaimTypes.Name, user.Id)); 1367(userId == null || id.FindFirstValue(ClaimTypes.NameIdentifier) == userId) && 1368(loginProvider == null || id.FindFirstValue(ClaimTypes.AuthenticationMethod) == loginProvider) && 1424identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, "bar")); 1486identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, "bar"));
Microsoft.AspNetCore.Identity.UI (4)
Areas\Identity\Pages\V4\Account\ExternalLogin.cshtml.cs (2)
159if (info.Principal!.HasClaim(c => c.Type == ClaimTypes.Email)) 163Email = info.Principal.FindFirstValue(ClaimTypes.Email)!
Areas\Identity\Pages\V5\Account\ExternalLogin.cshtml.cs (2)
159if (info.Principal.HasClaim(c => c.Type == ClaimTypes.Email)) 163Email = info.Principal.FindFirstValue(ClaimTypes.Email)!
Microsoft.AspNetCore.Mvc.Core.Test (5)
Authorization\AuthorizeFilterTest.cs (5)
579new Claim(ClaimTypes.Role, "Administrator"), 580new Claim(ClaimTypes.Role, "User"), 581new Claim(ClaimTypes.NameIdentifier, "John")}, 589new Claim(ClaimTypes.Role, "Token"), 590new Claim(ClaimTypes.NameIdentifier, "John Bear")},
Microsoft.AspNetCore.SignalR.Client.FunctionalTests (3)
Startup.cs (3)
41policy.RequireClaim(ClaimTypes.NameIdentifier); 46policy.RequireClaim(ClaimTypes.Name); 135var claims = new[] { new Claim(ClaimTypes.NameIdentifier, name) };
Microsoft.AspNetCore.SignalR.Core (1)
DefaultUserIdProvider.cs (1)
17return connection.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
Microsoft.AspNetCore.SignalR.Specification.Tests (2)
src\SignalR\common\testassets\Tests.Utils\TestClient.cs (2)
53var claims = new List<Claim> { new Claim(ClaimTypes.Name, claimValue) }; 56claims.Add(new Claim(ClaimTypes.NameIdentifier, userIdentifier));
Microsoft.AspNetCore.SignalR.Tests (7)
HubConnectionHandlerTests.cs (5)
2199policy.RequireClaim(ClaimTypes.NameIdentifier); 2235policy.RequireClaim(ClaimTypes.NameIdentifier); 2245client.Connection.User.AddIdentity(new ClaimsIdentity(new[] { new Claim(ClaimTypes.NameIdentifier, "name") })); 2335policy.RequireClaim(ClaimTypes.NameIdentifier); 2347client.Connection.User.AddIdentity(new ClaimsIdentity(new[] { new Claim(ClaimTypes.NameIdentifier, "name") }));
Startup.cs (1)
107var claims = new[] { new Claim(ClaimTypes.NameIdentifier, httpContext.Request.Query["user"]) };
TestAuthHandler.cs (1)
19var hasClaim = context.User.HasClaim(o => o.Type == ClaimTypes.NameIdentifier && !string.IsNullOrEmpty(o.Value));
Microsoft.AspNetCore.SignalR.Tests.Utils (2)
TestClient.cs (2)
53var claims = new List<Claim> { new Claim(ClaimTypes.Name, claimValue) }; 56claims.Add(new Claim(ClaimTypes.NameIdentifier, userIdentifier));
Microsoft.Extensions.Identity.Core (9)
ClaimsIdentityOptions.cs (8)
14/// Gets or sets the ClaimType used for a Role claim. Defaults to <see cref="ClaimTypes.Role"/>. 16public string RoleClaimType { get; set; } = ClaimTypes.Role; 19/// Gets or sets the ClaimType used for the user name claim. Defaults to <see cref="ClaimTypes.Name"/>. 21public string UserNameClaimType { get; set; } = ClaimTypes.Name; 24/// Gets or sets the ClaimType used for the user identifier claim. Defaults to <see cref="ClaimTypes.NameIdentifier"/>. 26public string UserIdClaimType { get; set; } = ClaimTypes.NameIdentifier; 29/// Gets or sets the ClaimType used for the user email claim. Defaults to <see cref="ClaimTypes.Email"/>. 31public string EmailClaimType { get; set; } = ClaimTypes.Email;
UserManager.cs (1)
440/// <remarks>The User ID claim is identified by <see cref="ClaimTypes.NameIdentifier"/>.</remarks>
mscorlib (1)
src\libraries\shims\mscorlib\ref\mscorlib.cs (1)
854[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Security.Claims.ClaimTypes))]
netstandard (1)
netstandard.cs (1)
1838[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Security.Claims.ClaimTypes))]
OpenIdConnectSample (1)
Startup.cs (1)
363public IssuerFixupAction() : base(ClaimTypes.NameIdentifier, string.Empty) { }
PathSchemeSelection (1)
Startup.cs (1)
47id.AddClaim(new Claim(ClaimTypes.Name, "Hao", ClaimValueTypes.String, "Api"));
SignalR.Client.FunctionalTestApp (2)
Startup.cs (2)
52policy.RequireClaim(ClaimTypes.NameIdentifier); 295var claims = new[] { new Claim(ClaimTypes.NameIdentifier, "testuser") };
SocialSample (11)
Startup.cs (11)
75o.ClaimActions.Remove(ClaimTypes.GivenName); 88o.ClaimActions.MapJsonKey("urn:twitter:profilepicture", "profile_image_url", ClaimTypes.Uri); 126o.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); 127o.ClaimActions.MapJsonKey(ClaimTypes.Name, "login"); 129o.ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email); 181o.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "sub"); 182o.ClaimActions.MapJsonKey(ClaimTypes.Name, "name"); 183o.ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email); 184o.ClaimActions.MapJsonKey(ClaimTypes.GivenName, "given_name"); 185o.ClaimActions.MapJsonKey(ClaimTypes.Surname, "family_name"); 187o.ClaimActions.MapJsonKey(ClaimTypes.Uri, "website");
System.Security.Claims (8)
System\Security\Claims\Claim.cs (6)
154/// <seealso cref="ClaimTypes"/> 174/// <seealso cref="ClaimTypes"/> 194/// <seealso cref="ClaimTypes"/> 214/// <seealso cref="ClaimTypes"/> 232/// <seealso cref="ClaimTypes"/> 356/// <seealso cref="ClaimTypes"/>.
System\Security\Claims\ClaimsIdentity.cs (2)
44public const string DefaultNameClaimType = ClaimTypes.Name; 45public const string DefaultRoleClaimType = ClaimTypes.Role;