asp.net-core-identity

How to use ASP.NET Core Identity without roles?

十年热恋 提交于 2019-12-05 12:26:48
Is it feasible to implement identity in asp.net core 2 without roles implementation? I have tried to implement the following: services.AddIdentityCore<TUser>(); but that does not seem to work as well. I got it! I have upload a repo in github: https://github.com/tolemac/IdentityWithoutRoles You have to create your custom ApplicationDbContext with corrects DbSets : public class ApplicationDbContext : DbContext { public ApplicationDbContext(DbContextOptions options) : base(options) { } /// <summary> /// Gets or sets the <see cref="DbSet{TEntity}"/> of Users. /// </summary> public DbSet

.Net Core Identity 2 Provider login Cancel leads to unhandled exception

倾然丶 夕夏残阳落幕 提交于 2019-12-05 11:40:44
I've added LinkedIn as a provider. I have implemented the login and register with LinkedIn without any issue. In the use case where the user CANCELS from within the provider Pages (either linkedIn login or cancels the authorization of the app) the identity middleware seems to throw an unhandled exception: An unhandled exception occurred while processing the request. Exception: user_cancelled_login;Description=The user cancelled LinkedIn login Unknown location Exception: An error was encountered while handling the remote login. Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler

AspNetCore 2.0 Identity - Issues with injecting RoleManager

谁都会走 提交于 2019-12-05 10:01:15
I need to create CRUD operations for ROLES. I'm getting the following error: "Unable to resolve service for type 'Microsoft.AspNetCore.Identity.RoleManager`" So, how can i inject roleManager? I'm using asp net core 2.0 + identity 2.2.1 Class ApplicationUser public class ApplicationUser : IdentityUser { [Key] public override string Id { get; set; } public bool Type { get; set; } } Now in Startup.cs services.AddIdentity<ApplicationUser, IdentityRole<int>>() .AddUserStore<UserStore<ApplicationUser, IdentityRole<int>, ApplicationDbContext, int>>() .AddRoleStore<RoleStore<IdentityRole<int>,

NormalizedUserName VS Username in DotNet Core

家住魔仙堡 提交于 2019-12-04 22:47:45
I'm trying to create a custom implementation of IUserLoginStore for MongoDB and I noticed when using UserManager<ApplicationUser> with the method var userResult = await _userManager.CreateAsync(user); it goes through the implementation of GetUserNameAsync FindByNameAsync SetNormalizedUserNameAsync GetUserIdAsync I would like to clarify two questions: what's the purpose of having a NormalizedUsername and a UserName? the only difference that I could notice id that the normalizedUserName is in uppercase. I'm using my Implementation only to store users from an external login(Google plus), is there

Multitenant Identity Server 4

断了今生、忘了曾经 提交于 2019-12-04 21:31:11
问题 I'm trying to implement an IdentityServer that handles an SSO for a multitenant application. Our system will have only one IdentityServer4 instance to handle the authentication of a multitentant client. On the client side, I'm using the acr_value to pass the tenant Id. A piece of code from the Startup.cs file is as follows: public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddAuthorization(); services.AddAuthentication(options => { options.DefaultScheme

ASP.NET Core Custom Policy Based Authorization - unclear

拜拜、爱过 提交于 2019-12-04 08:01:56
OK, Custom Policy Based Authorization in ASP.NET Core. I kinda of understood the idea of this new identity framework, but still not 100% clear what you can achieve with this. Assuming we have an Action in HomeController called List. This action will query and display a list of products from the database. The users that must access this list must be part of the Marketing division. Therefore in our policy we check if user has a claim called Division and the value of that is Marketing. If yes then he will be allowed to see the list otherwise not. We can decorate our action like this: [Authorize

Multitenant Identity Server 4

蓝咒 提交于 2019-12-04 06:30:01
I'm trying to implement an IdentityServer that handles an SSO for a multitenant application. Our system will have only one IdentityServer4 instance to handle the authentication of a multitentant client. On the client side, I'm using the acr_value to pass the tenant Id. A piece of code from the Startup.cs file is as follows: public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddAuthorization(); services.AddAuthentication(options => { options.DefaultScheme = "Cookies"; options.DefaultChallengeScheme = "oidc"; }) .AddCookie("Cookies") .AddOpenIdConnect("oidc"

Using AspNetUserTokens table to store refresh token in ASP.NET Core Web Api

落爺英雄遲暮 提交于 2019-12-04 00:05:21
I'm working with ASP.NET Core Web API application. I'm trying to implement Jwt Token Based Authentication on top of ASP.NET Identity( built in with database tables). I have implemented all scenarios like register user, login etc but now trying to implement refresh token flow( where access token get expired, client need to get replaced access token using refresh token) . I have seen people are creating new table (refreshToken) to store refresh token so it can be validated with access token and new access and refresh tokens will be generated https://www.blinkingcaret.com/2018/05/30/refresh

ASP.NET Core Identity & Cookies

本小妞迷上赌 提交于 2019-12-03 22:19:47
问题 I have an ASP.NET Core site using AspNetCore.Identity.EntityFrameworkCore 1.1.1 and cookies to authorize/authenticate my users. No matter what I choose as my setting in the code below, the cookie expires after about 20 minutes and I can't figure why. The website will then no longer work unless you close the browser and clear the history/cookies. Any ideas? services.AddIdentity<ApplicationUser, IdentityRole>(config => { // Require a confirmed email in order to log in config.SignIn

.NetCore JwtBearerAuthentication not rejecting expired tokens

六月ゝ 毕业季﹏ 提交于 2019-12-03 12:44:38
问题 I am generating JWT's to use with my WebApi project. I'm set the token to expire in one minute so that I can test if it rejects the token when submitted after the expiration date. CreateToken Controller public async Task<IActionResult> CreateToken([FromBody] CredentialModel model) { var user = await _unitOfWork.UserManager.FindByNameAsync(model.UserName); if (user == null) return BadRequest(); if (Hasher.VerifyHashedPassword(user, user.PasswordHash, model.Password) !=