Implemented interface member:
2 overrides of Identity
System.Security.Claims (1)
System\Security\Claims\GenericPrincipal.cs (1)
65public override IIdentity Identity
System.Security.Principal.Windows (1)
artifacts\obj\System.Security.Principal.Windows\Debug\net10.0\System.Security.Principal.Windows.notsupported.cs (1)
279public override System.Security.Principal.IIdentity Identity { get { throw new System.PlatformNotSupportedException(System.SR.PlatformNotSupported_Principal); } }
193 references to Identity
Aspire.Dashboard (2)
Authentication\AspirePolicyEvaluator.cs (1)
86return (context.User?.Identity?.IsAuthenticated ?? false)
DashboardWebApplication.cs (1)
754var claimsIdentity = (ClaimsIdentity)context.Principal!.Identity!;
AzureAppServicesHostingStartupSample (1)
Startup.cs (1)
36await context.Response.WriteAsync("User: " + context.User.Identity.Name + Environment.NewLine);
AzureAppServicesSample (1)
Startup.cs (1)
47await context.Response.WriteAsync("User: " + context.User.Identity.Name + Environment.NewLine);
BasicTestApp (1)
Program.cs (1)
39policy.RequireAssertion(ctx => ctx.User.Identity.Name?.StartsWith('B') ?? false));
Certificate.Optional.Sample (2)
Startup.cs (2)
49return context.Response.WriteAsync($"Hello {context.User.Identity.Name} at {context.Request.Host}"); 54return context.Response.WriteAsync($"Hello {context.User.Identity.Name} at {context.Request.Host}. Try /auth");
Certificate.Sample (1)
Startup.cs (1)
54return context.Response.WriteAsync($"Hello {context.User.Identity.Name}");
dotnet-user-jwts (1)
Helpers\JwtIssuer.cs (1)
82if (handler.ValidateToken(encodedToken, tokenValidationParameters, out _).Identity?.IsAuthenticated == true)
Identity.ExternalClaims (2)
Pages\Account\ExternalLogin.cshtml.cs (1)
86_logger.LogInformation("{Name} logged in with {LoginProvider} provider.", info.Principal.Identity.Name, info.LoginProvider);
Pages\Account\SignedOut.cshtml.cs (1)
15if (User.Identity.IsAuthenticated)
IdentitySample.ApiEndpoints (1)
Program.cs (1)
25app.MapGet("/requires-auth", (ClaimsPrincipal user) => $"Hello, {user.Identity?.Name}!").RequireAuthorization();
IISSample (1)
Startup.cs (1)
61await context.Response.WriteAsync("User: " + context.User.Identity.Name + Environment.NewLine);
InProcessWebSite (10)
src\Servers\IIS\IIS\test\testassets\InProcessWebSite\Startup.cs (10)
136if (ctx.User.Identity.Name != null) 138await ctx.Response.WriteAsync(":" + ctx.User.Identity.Name); 235await ctx.Response.WriteAsync("Anonymous?" + !ctx.User.Identity.IsAuthenticated); 240if (ctx.User.Identity.IsAuthenticated) 242await ctx.Response.WriteAsync(ctx.User.Identity.AuthenticationType); 257if (string.Equals("NTLM", ctx.User.Identity.AuthenticationType, StringComparison.Ordinal)) 1076public Task Anonymous(HttpContext context) => context.Response.WriteAsync("Anonymous?" + !context.User.Identity.IsAuthenticated); 1080if (context.User.Identity.IsAuthenticated) 1083return context.Response.WriteAsync(context.User.Identity.AuthenticationType); 1095if (string.Equals("NTLM", context.User.Identity.AuthenticationType, StringComparison.Ordinal))
JwtBearerSample (2)
Startup.cs (2)
52if (authResult.Succeeded && authResult.Principal.Identity.IsAuthenticated) 80var todo = new Todo() { Description = obj.GetProperty("Description").GetString(), Owner = context.User.Identity.Name };
Microsoft.AspNetCore.Antiforgery.Test (6)
DefaultAntiforgeryTokenGeneratorTest.cs (6)
37Assert.False(httpContext.User.Identity.IsAuthenticated); 57Assert.False(httpContext.User.Identity.IsAuthenticated); 156mockClaimUidExtractor.Setup(o => o.ExtractClaimUid(It.Is<ClaimsPrincipal>(c => c.Identity == identity))) 405mockClaimUidExtractor.Setup(o => o.ExtractClaimUid(It.Is<ClaimsPrincipal>(c => c.Identity == identity))) 443mockClaimUidExtractor.Setup(o => o.ExtractClaimUid(It.Is<ClaimsPrincipal>(c => c.Identity == identity))) 585mockClaimUidExtractor.Setup(o => o.ExtractClaimUid(It.Is<ClaimsPrincipal>(c => c.Identity == identity)))
Microsoft.AspNetCore.Authentication.Core (2)
AuthenticationService.cs (2)
170if (principal.Identity == null) 174if (!principal.Identity.IsAuthenticated)
Microsoft.AspNetCore.Authentication.JwtBearer.Tools.Tests (1)
UserJwtsTests.cs (1)
92webApp.MapGet("/secret", (ClaimsPrincipal user) => $"Hello {user.Identity?.Name}!")
Microsoft.AspNetCore.Authentication.Negotiate (1)
NegotiateHandler.cs (1)
352await LdapAdapter.RetrieveClaimsAsync(ldapContext.LdapSettings, (ldapContext.Principal.Identity as ClaimsIdentity)!, Logger);
Microsoft.AspNetCore.Authentication.Negotiate.Test (12)
EventTests.cs (3)
279var identity = context.Principal.Identity; 438if (!context.User.Identity.IsAuthenticated) 445var name = context.User.Identity.Name;
NegotiateHandlerTests.cs (9)
272Assert.True(context.User.Identity.IsAuthenticated); 410Assert.False(context.User.Identity.IsAuthenticated, "Anonymous"); 417Assert.False(context.User.Identity.IsAuthenticated, "Anonymous"); 423if (!context.User.Identity.IsAuthenticated) 430var name = context.User.Identity.Name; 437if (!context.User.Identity.IsAuthenticated) 444var name = context.User.Identity.Name; 456Assert.True(context.User.Identity.IsAuthenticated, "Authenticated"); 457var name = context.User.Identity.Name;
Microsoft.AspNetCore.Authentication.OAuth (1)
Events\OAuthCreatingTicketContext.cs (1)
101public ClaimsIdentity? Identity => Principal?.Identity as ClaimsIdentity;
Microsoft.AspNetCore.Authentication.OpenIdConnect (2)
OpenIdConnectHandler.cs (2)
918var identity = (ClaimsIdentity)user!.Identity!; 1097var identity = (ClaimsIdentity)principal.Identity!;
Microsoft.AspNetCore.Authentication.Test (14)
JwtBearerTests.cs (3)
493var identity = (ClaimsIdentity)context.Principal.Identity; 1186context.User.Identity == null || 1187!context.User.Identity.IsAuthenticated)
JwtBearerTests_Handler.cs (3)
462var identity = (ClaimsIdentity)context.Principal.Identity; 1253context.User.Identity == null || 1254!context.User.Identity.IsAuthenticated)
TicketSerializerTests.cs (4)
49Assert.Equal("misc", readTicket.Principal.Identity.AuthenticationType); 72Assert.Equal("misc", readTicket.Principal.Identity.AuthenticationType); 74var identity = (ClaimsIdentity)readTicket.Principal.Identity; 107Assert.Equal("misc", readTicket.Principal.Identity.AuthenticationType);
WsFederation\WsFederationTest.cs (2)
382if (context.User.Identity.IsAuthenticated) 422if (context.User == null || !context.User.Identity.IsAuthenticated)
WsFederation\WsFederationTest_Handler.cs (2)
378if (context.User.Identity.IsAuthenticated) 418if (context.User == null || !context.User.Identity.IsAuthenticated)
Microsoft.AspNetCore.Authorization (1)
DenyAnonymousAuthorizationRequirement.cs (1)
26user?.Identity == null ||
Microsoft.AspNetCore.Authorization.Policy (1)
PolicyEvaluator.cs (1)
75return (context.User?.Identity?.IsAuthenticated ?? false)
Microsoft.AspNetCore.Authorization.Test (1)
AuthorizationMiddlewareTests.cs (1)
623Assert.NotNull(context.User?.Identity);
Microsoft.AspNetCore.Components.Authorization.Tests (20)
AuthorizeRouteViewTest.cs (2)
184state => builder => builder.AddContent(0, $"Go away, {state.User.Identity.Name}"); 209state => builder => builder.AddContent(0, $"Go away, {state.User.Identity.Name}");
AuthorizeViewTest.cs (17)
43Assert.Null(call.user.Identity); 58context => builder => builder.AddContent(0, $"You are not authorized, even though we know you are {context.User.Identity.Name}")); 78Assert.Equal("Nellie", call.user.Identity.Name); 106Assert.Equal("Nellie", call.user.Identity.Name); 122builder.AddContent(0, $"You are authenticated as {context.User.Identity.Name}")); 142Assert.Equal("Nellie", call.user.Identity.Name); 158builder.AddContent(0, $"You are authenticated as {context.User.Identity.Name}")); 178Assert.Equal("Nellie", call.user.Identity.Name); 194builder.AddContent(0, $"You are authenticated as {context.User.Identity.Name}")); 225Assert.Equal("Ronaldo", call.user.Identity.Name); 301authorized: context => builder => builder.AddContent(0, $"Hello, {context.User.Identity.Name}!")); 342Assert.Equal("Monsieur", call.user.Identity.Name); 360authorized: context => builder => builder.AddContent(0, $"Hello, {context.User.Identity.Name}!")); 400Assert.Equal("Monsieur", call.user.Identity.Name); 423Assert.Equal("Nellie", call.user.Identity.Name); 446Assert.Equal("Nellie", call.user.Identity.Name); 471Assert.Equal("Nellie", call.user.Identity.Name);
CascadingAuthenticationStateTest.cs (1)
165var identity = AuthStateTask.Result.User.Identity;
Microsoft.AspNetCore.Components.Server (1)
Circuits\RevalidatingServerAuthenticationStateProvider.cs (1)
64if (authenticationState.User.Identity?.IsAuthenticated == true)
Microsoft.AspNetCore.Components.Server.Tests (9)
Circuits\RevalidatingServerAuthenticationStateProviderTest.cs (9)
51Assert.Equal("test user", (await provider.GetAuthenticationStateAsync()).User.Identity.Name); 71Assert.False(newAuthState.User.Identity.IsAuthenticated); 95Assert.False(newAuthState.User.Identity.IsAuthenticated); 112call => Assert.Equal("test user", call.AuthenticationState.User.Identity.Name)); 124call => Assert.Equal("different user", call.AuthenticationState.User.Identity.Name)); 173Assert.Equal("different user", (await provider.GetAuthenticationStateAsync()).User.Identity.Name); 178call => Assert.Equal("different user", call.AuthenticationState.User.Identity.Name)); 212Assert.False(newAuthState.User.Identity.IsAuthenticated); 213Assert.Null(newAuthState.User.Identity.Name);
Microsoft.AspNetCore.Components.WebAssembly.Server (1)
AuthenticationStateSerializationOptions.cs (1)
40if (authenticationState.User.Identity?.IsAuthenticated ?? false)
Microsoft.AspNetCore.Http.Connections (3)
Internal\HttpConnectionContext.cs (1)
280if (TransportType == HttpTransportType.LongPolling && User?.Identity is WindowsIdentity)
Internal\HttpConnectionDispatcher.cs (2)
628if (!(context.User.Identity is WindowsIdentity)) 678if (oldContext.User.Identity is WindowsIdentity windowsIdentity)
Microsoft.AspNetCore.Http.Tests (7)
DefaultHttpContextTests.cs (7)
86Assert.False(context.User.Identity.IsAuthenticated); 87Assert.True(string.IsNullOrEmpty(context.User.Identity.AuthenticationType)); 93Assert.False(context.User.Identity.IsAuthenticated); 94Assert.True(string.IsNullOrEmpty(context.User.Identity.AuthenticationType)); 100Assert.Null(context.User.Identity); 103Assert.Equal("SomeAuthType", context.User.Identity.AuthenticationType); 104Assert.True(context.User.Identity.IsAuthenticated);
Microsoft.AspNetCore.HttpLogging (1)
W3CLoggingMiddleware.cs (1)
209shouldLog |= AddToList(elements, _userNameIndex, context.User?.Identity?.Name ?? "");
Microsoft.AspNetCore.Identity (2)
SignInManager.cs (2)
297if (principal == null || principal.Identity?.Name == null) 301var user = await UserManager.FindByIdAsync(principal.Identity.Name);
Microsoft.AspNetCore.Identity.FunctionalTests (1)
MapIdentityApiTests.cs (1)
1305(ClaimsPrincipal user) => $"Hello, {user.Identity?.Name}!");
Microsoft.AspNetCore.Identity.InMemory.Test (1)
FunctionalTest.cs (1)
177newId.AddClaim(new Claim("PreviousName", c.CurrentPrincipal.Identity.Name));
Microsoft.AspNetCore.Mvc.Core.Test (1)
Authorization\AuthorizeFilterTest.cs (1)
214Assert.NotNull(authorizationContext.HttpContext.User?.Identity);
Microsoft.AspNetCore.Mvc.TagHelpers (1)
Cache\CacheTagKey.cs (1)
100_username = httpContext.User?.Identity?.Name;
Microsoft.AspNetCore.Owin.Tests (4)
OwinEnvironmentTests.cs (4)
38Assert.Equal("Foo", Get<ClaimsPrincipal>(env, "server.User").Identity.AuthenticationType); 39Assert.Equal("Foo", Get<ClaimsPrincipal>(env, "owin.RequestUser").Identity.AuthenticationType); 65Assert.Equal("Foo", context.User.Identity.AuthenticationType); 68Assert.Equal("Bar", context.User.Identity.AuthenticationType);
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (38)
AuthenticationTests.cs (38)
33Assert.NotNull(httpContext.User.Identity); 34Assert.False(httpContext.User.Identity.IsAuthenticated); 72Assert.NotNull(httpContext.User.Identity); 73Assert.False(httpContext.User.Identity.IsAuthenticated); 98Assert.NotNull(httpContext.User.Identity); 99Assert.False(httpContext.User.Identity.IsAuthenticated); 122Assert.NotNull(httpContext.User.Identity); 125Assert.False(httpContext.User.Identity.IsAuthenticated); 130Assert.True(httpContext.User.Identity.IsAuthenticated); 156Assert.NotNull(httpContext.User.Identity); 157Assert.True(httpContext.User.Identity.IsAuthenticated); 176Assert.NotNull(httpContext.User.Identity); 177Assert.True(httpContext.User.Identity.IsAuthenticated); 180userName = httpContext.User.Identity.Name; 206Assert.NotNull(httpContext.User.Identity); 207Assert.False(httpContext.User.Identity.IsAuthenticated); 230Assert.NotNull(httpContext.User.Identity); 231Assert.True(httpContext.User.Identity.IsAuthenticated); 253Assert.NotNull(httpContext.User.Identity); 254Assert.False(httpContext.User.Identity.IsAuthenticated); 276Assert.NotNull(httpContext.User.Identity); 277Assert.False(httpContext.User.Identity.IsAuthenticated); 294Assert.NotNull(httpContext.User.Identity); 295Assert.False(httpContext.User.Identity.IsAuthenticated); 320Assert.NotNull(httpContext.User.Identity); 321Assert.False(httpContext.User.Identity.IsAuthenticated); 338Assert.NotNull(httpContext.User.Identity); 339Assert.False(httpContext.User.Identity.IsAuthenticated); 359Assert.NotNull(httpContext.User.Identity); 360Assert.True(httpContext.User.Identity.IsAuthenticated); 388Assert.NotNull(httpContext.User.Identity); 389Assert.False(httpContext.User.Identity.IsAuthenticated); 394Assert.NotNull(authenticateResult.Principal.Identity); 395Assert.True(authenticateResult.Principal.Identity.IsAuthenticated); 420Assert.NotNull(httpContext.User.Identity); 421Assert.True(httpContext.User.Identity.IsAuthenticated); 447Assert.NotNull(httpContext.User.Identity); 448Assert.True(httpContext.User.Identity.IsAuthenticated);
Microsoft.AspNetCore.Shared.Tests (14)
SecurityHelperTests.cs (14)
19Assert.Equal("Alpha", user.Identity.AuthenticationType); 20Assert.Equal("Test1", user.Identity.Name); 22Assert.IsAssignableFrom<ClaimsIdentity>(user.Identity); 31Assert.Equal("Alpha", user.Identity.AuthenticationType); 32Assert.Equal("Test1", user.Identity.Name); 36Assert.Equal("Beta", user.Identity.AuthenticationType); 37Assert.Equal("Test2", user.Identity.Name); 41Assert.Equal("Gamma", user.Identity.AuthenticationType); 42Assert.Equal("Test3", user.Identity.Name); 60Assert.False(existingPrincipal.Identity.IsAuthenticated); 71Assert.False(user.Identity.IsAuthenticated); 72Assert.Null(user.Identity.Name); 83Assert.Equal("Gamma", user.Identity.AuthenticationType); 84Assert.Equal("Test3", user.Identity.Name);
Microsoft.AspNetCore.Tests (3)
WebApplicationTests.cs (3)
2455Assert.Equal(username, context.User.Identity.Name); 2463Assert.Equal(username, user.Identity.Name); 2494Assert.Null(context.User.Identity.Name);
MinimalJwtBearerSample (2)
Program.cs (2)
22app.MapGet("/protected", (ClaimsPrincipal user) => $"Hello {user.Identity?.Name}!") 27return $"Glory be to the admin {user.Identity?.Name}!";
MinimalOpenIdConnectSample (1)
Program.cs (1)
15app.MapGet("/protected", (ClaimsPrincipal user) => $"Hello {user.Identity?.Name}!")
NativeIISSample (1)
Startup.cs (1)
55await context.Response.WriteAsync("User: " + context.User.Identity.Name + Environment.NewLine);
Negotiate.Server (2)
Controllers\AuthController.cs (2)
17var user = HttpContext.User.Identity; 30var user = HttpContext.User.Identity;
NegotiateAuthSample (1)
Startup.cs (1)
57var user = context.User.Identity;
OpenIdConnectSample (3)
Startup.cs (3)
166await res.WriteAsync($"<h1>Signed out {HtmlEncode(context.User.Identity.Name)}</h1>"); 198await res.WriteAsync($"<h1>Access Denied for user {HtmlEncode(context.User.Identity.Name)} to resource '{HtmlEncode(context.Request.Query["ReturnUrl"])}'</h1>"); 311await res.WriteAsync($"<h1>Hello Authenticated User {HtmlEncode(user.Identity.Name)}</h1>");
ServerComparison.TestSites (2)
StartupNtlmAuthentication.cs (2)
52return context.Response.WriteAsync("Anonymous?" + !context.User.Identity.IsAuthenticated); 57if (context.User.Identity.IsAuthenticated)
SocialSample (2)
Startup.cs (2)
402await response.WriteAsync("You have been logged out. Goodbye " + context.User.Identity.Name + "<br>"); 450await response.WriteAsync("Hello " + (context.User.Identity.Name ?? "anonymous") + "<br>");
StaticFilesAuth (1)
Startup.cs (1)
39var userName = context.User.Identity.Name;
System.Security.Claims (1)
System\Security\Claims\ClaimsPrincipal.cs (1)
583if (identitiesCount == 1 && Identity is ClaimsIdentity claimsIdentity)
WsFedSample (3)
Startup.cs (3)
61await context.Response.WriteAsync($"<h1>Signed out {HtmlEncode(context.User.Identity.Name)}</h1>"); 82await context.Response.WriteAsync($"<h1>Access Denied for user {HtmlEncode(context.User.Identity.Name)} to resource '{HtmlEncode(context.Request.Query["ReturnUrl"])}'</h1>"); 118await response.WriteAsync($"<h1>Hello Authenticated User {HtmlEncode(user.Identity.Name)}</h1>");