claimsprincipal_dotnet Authentication means identifying a subject (user, external application etc) ASP.Net Core Identity is a framework that uses claims based authentication to authenticate users Key concepts in Claims-based authentication Claim Claim is a statement about the subject (user) being authenticated It is a key value pair (like username=John is a claim, email=john1543@gmail.com is a claim, userId=236 is a claim) A claim can have an issuer (for example: userId=236 as per system , date of birth=1st-Jan-2006 as per Gmail ; here system and Gmail are the issuers) ClaimsIdentity ClaimsIdentity is a collection of claims of the subject (user) For example, driving license of a subject (user) can be a ClaimsIdentity that has claims like name, photo, date of birth, address etc. Passport can be a ClaimsIdentity that has claims like name, place of birth, photo, nationality, permanent address etc ClaimsIdentity also has a string property called Authenti...
cookie_auth Cookie based authentication explained in ASP.NET Core Cookie based authentication can be implemented in ASP.NET Core using the built in Authentication service and Authentication middleware Add cookie authentication service in DI container // Add Cookie Authentication service builder . Services . AddAuthentication ( CookieAuthenticationDefaults . AuthenticationScheme ) . AddCookie ( options = > { options . LoginPath = "/Account/Login" ; // Specify the path to the login page options . AccessDeniedPath = "/Account/AccessDenied" ; // Specify the path for access denied options . ExpireTimeSpan = TimeSpan . FromMinutes ( 60 ) ; // Set the cookie expiration time options . SlidingExpiration = true ; // Enable sliding expiration } ) ; AddAuthentication adds required services for authentication. It also specifies the default authentication scheme to be used for authenticati...
implicit usings Implicit usings = no repeated using statement in all files With implicit usings feature in a C# project, common using statements are automatically added by the compiler in all the C# files. For example using System; statement is not required to run the dotnet console application as shown below Console . WriteLine ( "Hello World!" ) ; Additional implicit usings can be declared in a C# project with global usings statements in any one of the project’s C# files as shown below. global using Ardalis . GuardClauses ; global using MediatR ; global using Project2 . Utils ; Existing implicit usings can be removed or included in the .csproj file of the C# project as shown below < ItemGroup > < Using Remove = " System.Threading.Tasks " /> < Using Include = " System.Math " /> </ ItemGroup > The implicit usings added in a C# project is based on the project type as sh...
Comments
Post a Comment