1 override of User
Microsoft.AspNetCore.Http (1)
DefaultHttpContext.cs (1)
154public override ClaimsPrincipal User
22 writes to User
HtmlGenerationWebSite (1)
Controllers\Catalog_CacheTagHelperController.cs (1)
61HttpContext.User = new ClaimsPrincipal(identity);
Microsoft.AspNetCore.Authentication (1)
AuthenticationMiddleware.cs (1)
65context.User = result.Principal;
Microsoft.AspNetCore.Authentication.Test (1)
AuthenticationMiddlewareTests.cs (1)
125context.User = new ClaimsPrincipal();
Microsoft.AspNetCore.Authorization.Policy (2)
PolicyEvaluator.cs (2)
56context.User = newPrincipal; 65context.User = new ClaimsPrincipal(new ClaimsIdentity());
Microsoft.AspNetCore.Authorization.Test (1)
AuthorizationMiddlewareTests.cs (1)
877context.User = new ClaimsPrincipal();
Microsoft.AspNetCore.Http.Connections (4)
Internal\HttpConnectionDispatcher.cs (4)
630existing.User = context.User; 685newContext.User = new WindowsPrincipal((WindowsIdentity)(windowsIdentity.Clone())); 690newContext.User = new ClaimsPrincipal(); 705newContext.User = oldContext.User;
Microsoft.AspNetCore.Http.Extensions.Tests (4)
RequestDelegateGenerator\RequestDelegateCreationTests.SpecialTypes.cs (4)
80httpContext.User = user; 143httpContext.User = new ClaimsPrincipal(); 247httpContext.User = new ClaimsPrincipal(); 279httpContext.User = new ClaimsPrincipal();
Microsoft.AspNetCore.Identity (1)
SignInManager.cs (1)
245Context.User = userPrincipal;
Microsoft.AspNetCore.Mvc.Core.Test (2)
Authorization\AuthorizeFilterTest.cs (2)
90authorizationContext.HttpContext.User = new ClaimsPrincipal(); 618httpContext.Object.User = validUser;
Microsoft.AspNetCore.Mvc.TagHelpers.Test (2)
CacheTagKeyTest.cs (2)
359cacheTagHelper.ViewContext.HttpContext.User = new ClaimsPrincipal(identity); 406cacheTagHelper.ViewContext.HttpContext.User = new ClaimsPrincipal(identity);
Microsoft.AspNetCore.Owin.Tests (1)
OwinEnvironmentTests.cs (1)
23context.User = new ClaimsPrincipal(new ClaimsIdentity("Foo"));
Microsoft.AspNetCore.Server.IISIntegration (2)
IISMiddleware.cs (2)
155httpContext.User = user; 199context.User = null!;
178 references to User
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);
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}");
CookieSample (1)
Program.cs (1)
41if (!context.User.Identities.Any(identity => identity.IsAuthenticated))
CookieSessionSample (1)
Startup.cs (1)
32if (!context.User.Identities.Any(identity => identity.IsAuthenticated))
IdentitySample.Mvc (2)
Controllers\AccountController.cs (1)
547return _userManager.GetUserAsync(HttpContext.User);
Controllers\ManageController.cs (1)
373return _userManager.GetUserAsync(HttpContext.User);
IISSample (1)
Startup.cs (1)
61await context.Response.WriteAsync("User: " + context.User.Identity.Name + Environment.NewLine);
InProcessWebSite (11)
src\Servers\IIS\IIS\test\testassets\InProcessWebSite\Startup.cs (11)
135if (ctx.User.Identity.Name != null) 137await ctx.Response.WriteAsync(":" + ctx.User.Identity.Name); 234await ctx.Response.WriteAsync("Anonymous?" + !ctx.User.Identity.IsAuthenticated); 239if (ctx.User.Identity.IsAuthenticated) 241await ctx.Response.WriteAsync(ctx.User.Identity.AuthenticationType); 256if (string.Equals("NTLM", ctx.User.Identity.AuthenticationType, StringComparison.Ordinal)) 1075public Task Anonymous(HttpContext context) => context.Response.WriteAsync("Anonymous?" + !context.User.Identity.IsAuthenticated); 1079if (context.User.Identity.IsAuthenticated) 1081Assert.IsType<WindowsPrincipal>(context.User); 1082return context.Response.WriteAsync(context.User.Identity.AuthenticationType); 1094if (string.Equals("NTLM", context.User.Identity.AuthenticationType, StringComparison.Ordinal))
JwtBearerSample (1)
Startup.cs (1)
80var todo = new Todo() { Description = obj.GetProperty("Description").GetString(), Owner = context.User.Identity.Name };
Microsoft.AspNetCore.Antiforgery (4)
Internal\DefaultAntiforgeryTokenGenerator.cs (4)
58var authenticatedIdentity = GetAuthenticatedIdentity(httpContext.User); 62requestToken.ClaimUid = GetClaimUidBlob(_claimUidExtractor.ExtractClaimUid(httpContext.User)); 142var authenticatedIdentity = GetAuthenticatedIdentity(httpContext.User); 145currentClaimUid = GetClaimUidBlob(_claimUidExtractor.ExtractClaimUid(httpContext.User));
Microsoft.AspNetCore.Authentication.Negotiate.Test (12)
EventTests.cs (2)
438if (!context.User.Identity.IsAuthenticated) 445var name = context.User.Identity.Name;
NegotiateHandlerTests.cs (10)
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; 447context.User.Claims, 456Assert.True(context.User.Identity.IsAuthenticated, "Authenticated"); 457var name = context.User.Identity.Name;
Microsoft.AspNetCore.Authentication.Test (25)
AuthenticationMiddlewareTests.cs (4)
80Assert.Same(context.User, authenticateResultFeature.AuthenticateResult.Principal); 123Assert.Same(context.User, authenticateResultFeature.AuthenticateResult.Principal); 149Assert.Same(context.User, authenticateResultFeature.AuthenticateResult.Principal); 153Assert.Same(context.User, newTicket.Principal);
CertificateTests.cs (1)
831foreach (Claim claim in context.User.Claims)
CookieTests.cs (1)
1850await DescribeAsync(res, AuthenticateResult.Success(new AuthenticationTicket(context.User, new AuthenticationProperties(), CookieAuthenticationDefaults.AuthenticationScheme)));
GoogleTests.cs (1)
1172await res.DescribeAsync(context.User);
JwtBearerTests.cs (4)
1185if (context.User == null || 1186context.User.Identity == null || 1187!context.User.Identity.IsAuthenticated) 1195var identifier = context.User.FindFirst(ClaimTypes.NameIdentifier);
JwtBearerTests_Handler.cs (4)
1217if (context.User == null || 1218context.User.Identity == null || 1219!context.User.Identity.IsAuthenticated) 1227var identifier = context.User.FindFirst(ClaimTypes.NameIdentifier);
MicrosoftAccountTests.cs (1)
394await res.DescribeAsync(context.User);
TwitterTests.cs (1)
561await res.DescribeAsync(context.User);
WsFederation\WsFederationTest.cs (4)
382if (context.User.Identity.IsAuthenticated) 422if (context.User == null || !context.User.Identity.IsAuthenticated) 429var identity = context.User.Identities.Single();
WsFederation\WsFederationTest_Handler.cs (4)
378if (context.User.Identity.IsAuthenticated) 418if (context.User == null || !context.User.Identity.IsAuthenticated) 425var identity = context.User.Identities.Single();
Microsoft.AspNetCore.Authorization.Policy (5)
IPolicyEvaluator.cs (1)
17/// <see cref="ClaimsPrincipal"/> to <see cref="HttpContext.User"/>. If no schemes are set, this is a no-op.
PolicyEvaluator.cs (4)
29/// <see cref="ClaimsPrincipal"/> to <see cref="HttpContext.User"/>. If no schemes are set, this is a no-op. 75return (context.User?.Identity?.IsAuthenticated ?? false) 76? AuthenticateResult.Success(new AuthenticationTicket(context.User, "context.User")) 98var result = await _authorization.AuthorizeAsync(context.User, resource, policy);
Microsoft.AspNetCore.Authorization.Test (10)
AuthorizationMiddlewareTests.cs (9)
623Assert.NotNull(context.User?.Identity); 788Assert.Same(context.User, authenticateResultFeature.AuthenticateResult.Principal); 829var res = AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(c.User.Identities.FirstOrDefault(i => i.AuthenticationType == scheme)), scheme)); 836var res = AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(c.User.Identities.FirstOrDefault(i => i.AuthenticationType == scheme)), scheme)); 851Assert.Same(context.User, authenticateResultFeature.AuthenticateResult.Principal); 875Assert.Same(context.User, authenticateResultFeature.AuthenticateResult.Principal); 901Assert.Same(context.User, authenticateResultFeature.AuthenticateResult.Principal); 905Assert.Same(context.User, newTicket.Principal); 925var res = AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(c.User.Identities.FirstOrDefault(i => i.AuthenticationType == scheme)), scheme));
TestObjects\TestAuthenticationService.cs (1)
24var identity = context.User.Identities.SingleOrDefault(i => i.AuthenticationType == scheme);
Microsoft.AspNetCore.Components.Endpoints (1)
Rendering\EndpointHtmlRenderer.cs (1)
84var authenticationState = new AuthenticationState(httpContext.User);
Microsoft.AspNetCore.Http.Connections (9)
Internal\HttpConnectionDispatcher.cs (9)
628if (!(context.User.Identity is WindowsIdentity)) 630existing.User = context.User; 642var newName = connection.HttpContext?.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; 651connection.User = connection.HttpContext?.User; 678if (oldContext.User.Identity is WindowsIdentity windowsIdentity) 681if (OperatingSystem.IsWindows() && oldContext.User is WindowsPrincipal) 693foreach (var identity in oldContext.User.Identities) 700newContext.User.AddIdentity(identity.Clone()); 705newContext.User = oldContext.User;
Microsoft.AspNetCore.Http.Connections.Tests (1)
HttpConnectionDispatcherTests.cs (1)
824Assert.Equal("claimValue", connectionHttpContext.User.Claims.FirstOrDefault().Value);
Microsoft.AspNetCore.Http.Extensions (1)
RequestDelegateFactory.cs (1)
97private static readonly MemberExpression UserExpr = Expression.Property(HttpContextExpr, typeof(HttpContext).GetProperty(nameof(HttpContext.User))!);
Microsoft.AspNetCore.Http.Extensions.Tests (1)
RequestDelegateGenerator\RequestDelegateCreationTests.SpecialTypes.cs (1)
148Assert.Same(httpContext.User, httpContext.Items["user"]);
Microsoft.AspNetCore.HttpLogging (1)
W3CLoggingMiddleware.cs (1)
209shouldLog |= AddToList(elements, _userNameIndex, context.User?.Identity?.Name ?? "");
Microsoft.AspNetCore.Identity.InMemory.Test (1)
FunctionalTest.cs (1)
360await DescribeAsync(res, AuthenticateResult.Success(new AuthenticationTicket(context.User, null, "Application")));
Microsoft.AspNetCore.Mvc.Core (1)
ControllerBase.cs (1)
206public ClaimsPrincipal User => HttpContext?.User!;
Microsoft.AspNetCore.Mvc.Core.Test (3)
Authorization\AuthorizeFilterTest.cs (3)
27Assert.Contains(authorizationContext.HttpContext.User.Identities, i => i.IsAuthenticated); 214Assert.NotNull(authorizationContext.HttpContext.User?.Identity); 615httpContext.SetupProperty(c => c.User);
Microsoft.AspNetCore.Mvc.Razor (1)
RazorPageBase.cs (1)
134public virtual ClaimsPrincipal User => ViewContext.HttpContext.User;
Microsoft.AspNetCore.Mvc.RazorPages (1)
PageModel.cs (1)
86public ClaimsPrincipal User => HttpContext?.User!;
Microsoft.AspNetCore.Mvc.TagHelpers (2)
Cache\CacheTagKey.cs (1)
100_username = httpContext.User?.Identity?.Name;
CacheTagHelperBase.cs (1)
92/// <see cref="Http.HttpContext.User"/>.
Microsoft.AspNetCore.Mvc.ViewFeatures (2)
ViewComponent.cs (2)
44public IPrincipal User => ViewContext?.HttpContext?.User!; 49public ClaimsPrincipal UserClaimsPrincipal => ViewContext?.HttpContext?.User!;
Microsoft.AspNetCore.Owin.Tests (2)
OwinEnvironmentTests.cs (2)
65Assert.Equal("Foo", context.User.Identity.AuthenticationType); 68Assert.Equal("Bar", context.User.Identity.AuthenticationType);
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (53)
AuthenticationTests.cs (53)
32Assert.NotNull(httpContext.User); 33Assert.NotNull(httpContext.User.Identity); 34Assert.False(httpContext.User.Identity.IsAuthenticated); 71Assert.NotNull(httpContext.User); 72Assert.NotNull(httpContext.User.Identity); 73Assert.False(httpContext.User.Identity.IsAuthenticated); 97Assert.NotNull(httpContext.User); 98Assert.NotNull(httpContext.User.Identity); 99Assert.False(httpContext.User.Identity.IsAuthenticated); 121Assert.NotNull(httpContext.User); 122Assert.NotNull(httpContext.User.Identity); 125Assert.False(httpContext.User.Identity.IsAuthenticated); 130Assert.True(httpContext.User.Identity.IsAuthenticated); 155Assert.NotNull(httpContext.User); 156Assert.NotNull(httpContext.User.Identity); 157Assert.True(httpContext.User.Identity.IsAuthenticated); 175Assert.NotNull(httpContext.User); 176Assert.NotNull(httpContext.User.Identity); 177Assert.True(httpContext.User.Identity.IsAuthenticated); 180userName = httpContext.User.Identity.Name; 205Assert.NotNull(httpContext.User); 206Assert.NotNull(httpContext.User.Identity); 207Assert.False(httpContext.User.Identity.IsAuthenticated); 229Assert.NotNull(httpContext.User); 230Assert.NotNull(httpContext.User.Identity); 231Assert.True(httpContext.User.Identity.IsAuthenticated); 252Assert.NotNull(httpContext.User); 253Assert.NotNull(httpContext.User.Identity); 254Assert.False(httpContext.User.Identity.IsAuthenticated); 275Assert.NotNull(httpContext.User); 276Assert.NotNull(httpContext.User.Identity); 277Assert.False(httpContext.User.Identity.IsAuthenticated); 293Assert.NotNull(httpContext.User); 294Assert.NotNull(httpContext.User.Identity); 295Assert.False(httpContext.User.Identity.IsAuthenticated); 319Assert.NotNull(httpContext.User); 320Assert.NotNull(httpContext.User.Identity); 321Assert.False(httpContext.User.Identity.IsAuthenticated); 337Assert.NotNull(httpContext.User); 338Assert.NotNull(httpContext.User.Identity); 339Assert.False(httpContext.User.Identity.IsAuthenticated); 358Assert.NotNull(httpContext.User); 359Assert.NotNull(httpContext.User.Identity); 360Assert.True(httpContext.User.Identity.IsAuthenticated); 387Assert.NotNull(httpContext.User); 388Assert.NotNull(httpContext.User.Identity); 389Assert.False(httpContext.User.Identity.IsAuthenticated); 419Assert.NotNull(httpContext.User); 420Assert.NotNull(httpContext.User.Identity); 421Assert.True(httpContext.User.Identity.IsAuthenticated); 446Assert.NotNull(httpContext.User); 447Assert.NotNull(httpContext.User.Identity); 448Assert.True(httpContext.User.Identity.IsAuthenticated);
Microsoft.AspNetCore.Server.IISIntegration (1)
IISMiddleware.cs (1)
197if (context.User is WindowsPrincipal)
Microsoft.AspNetCore.Tests (2)
WebApplicationTests.cs (2)
2455Assert.Equal(username, context.User.Identity.Name); 2494Assert.Null(context.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>"); 319await WriteTableHeader(res, new string[] { "Claim Type", "Value" }, context.User.Claims.Select(c => new string[] { c.Type, c.Value }));
ServerComparison.TestSites (2)
StartupNtlmAuthentication.cs (2)
52return context.Response.WriteAsync("Anonymous?" + !context.User.Identity.IsAuthenticated); 57if (context.User.Identity.IsAuthenticated)
SocialSample (4)
Startup.cs (4)
402await response.WriteAsync("You have been logged out. Goodbye " + context.User.Identity.Name + "<br>"); 425var user = context.User; 450await response.WriteAsync("Hello " + (context.User.Identity.Name ?? "anonymous") + "<br>"); 451foreach (var claim in context.User.Claims)
WsFedSample (4)
Startup.cs (4)
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>"); 89var user = context.User; 124await WriteTableHeader(response, new string[] { "Claim Type", "Value" }, context.User.Claims.Select(c => new string[] { c.Type, c.Value }));