

Stub User.Identity.IsAuthenticated in ASP Core
source link: https://andersmalmgren.com/2019/04/23/stub-user-identity-isauthenticated-in-asp-core/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Stub User.Identity.IsAuthenticated in ASP Core
I’m writing this article strictly because google do not have any obvious solutions in the hope it will be indexed and presented for fellow devs.
We use identity server and to make things easier in dev I want to stub it. ClaimsIdentity takes a second argument AuthenticationType. Its important you set this property. You can set it to what ever you like. Once set IsAuthenticated will return true.
if
(env.IsDevelopment())
{
app.Use(
async
(ctx, next) =>
{
ctx.User =
new
ClaimsPrincipal(
new
ClaimsIdentity(
new
[] {
new
Claim(ClaimTypes.Name,
"local"
) },
"Authenticated"
));
await
next.Invoke();
});
}
Recommend
-
14
Angular Authentication Functionality with ASP.NET Core Identity Posted by Marinko Spasojevic | Updated Date Dec 16, 2020 |
-
17
Angular Email Confirmation with ASP.NET Core Identity Posted by Marinko Spasojevic | Updated Date Dec 21, 2020 |
-
9
Microsoft Identity Claims in ASP.NET Core: OperationAuthorization Requirement I didn't know this existed until a reader made me aware of it. Today, we update the menu systems with Microsoft Identity using the OperationAuthorizationR...
-
85
ASP.NET Core Identity AddDefaultIdentity vs AddIdentity The short version on the difference between AddDefaultIdentity and AddIdentity is the default part adds in all the built-in controllers and vi...
-
12
ASP.NET Core and Blazor Identity and State 16 Mar 2022 Over the past several weeks I’ve been wrestling with the way in which ASP.NET Core (aspnetcore) and server-side Blazor manage things like context, identity, and state....
-
8
Using Oracle Database with ASP.NET Core IdentityASP.NET Core Identity is a .NET interface that supports user and role authenticati...
-
7
Introduction to Identity Server with ASP.Net Core Identity Importance of security On every platform security is important, and especially tru...
-
8
Part-5 | Asp.Net Core Identity Series[.NET 7] | Google Authentication
-
6
Improvements to auth and identity in ASP.NET Core 8 Jeremy Likness...
-
7
Unit Testing With UserManager and RoleManager in ASP.NET Core Identity Posted by Code Maze | U...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK