asp.net-core-identity

Inherit (?) IdentityUser from another project

浪子不回头ぞ 提交于 2021-02-20 08:58:48
问题 I have multiple projects in my solution, all .NET Core 3.1. One of them is my core project (“ A Project ”) where I just have basic model classes with no methods or database access. For demonstration purposes, below are simplified versions of my Address.cs and User.cs files: public class Address { public int Id {get;set;} public string AddressText {get;set;} public virtual User User {get;set;} } public class User { public int UserId {get;set;} public int UserName {get;set;} public ICollection

ASP.NET Core and Angular: Microsoft Authentication

谁说胖子不能爱 提交于 2021-02-08 10:36:28
问题 For the moment I'm trying to add third party authentication to my ASP.NET Core web application. Today I've successfully implemented Facebook authentication. This was already a struggle since the docs only mention Facebook authentication for a ASP.NET application with razor pages (https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/facebook-logins?view=aspnetcore-2.2). Nothing has been written in the docs about implementing this for Angular apps. This was the most

Create shorter tokens with small lifespan in ASP.NET Core Identity

寵の児 提交于 2021-02-08 07:19:27
问题 Using ASP.NET Core 3.1 I am creating an User's Email confirmation token to send by email: String token = await _userManager.GenerateEmailConfirmationTokenAsync(user); And I get the following: CfDJ8IjJLi0iO61KsS5NTyS4wJkSvCyzEDUBaVlXCkbxz6zwI1LocG8+WPubx5Rvoi4tFuiWAVFut4gfTnhgsdihE0gY+o7JyJrNtfXmzGLnczwbKZ3Wwy15+IUEi1h2qId72IRKvFqBSFv7rJdECSR/thZphpTQm7EnOuAA7loHlQFRWuMUVBce8HUsv1odbLNsKQ== How can I create shorter tokens with a small lifespan instead of huge tokens? 回答1: If I understand the

Migrate existing Microsoft.AspNet.Identity DB (EF 6) to Microsoft.AspNetCore.Identity (EF Core)

丶灬走出姿态 提交于 2021-02-07 13:20:17
问题 I am working on an application (APS.net MVC) which uses Microsoft.AspNet.Identity . Now I want to revamp my application to APS.net Core which uses Microsoft.AspNetCore.Identity . But those two has some differences in each model. Is there any direct way to generate initial migration for Microsoft.AspNetCore.Identit y related changes in-order to connect existing DB with Asp.net Core identity? 回答1: I was able to migrate existing DBs using the following steps. Create a new ASP.net Core project

ASP.NET Core Identity with Windows Authentication

…衆ロ難τιáo~ 提交于 2021-02-06 10:13:12
问题 I'm using .NET Core 3.0 Preview6. We have an Intranet application with enabled Windows authentication which means that only valid AD users are allowed to use the application. However, we like to run our own authentication backend with ASP.NET Identity, because it works "out-of-the-box". I just added a column to AspNetUsers table with the user's Windows login. What I'd like to accomplish is that Windows users are automatically signed-in to the application with their Windows login. I already

Why can't I use role authorization in my API controller

╄→гoц情女王★ 提交于 2021-01-29 10:20:44
问题 I created a react project with the react template in asp.net core with individual user accounts. I have looked around and found out I needed to add roles in the startup file and add a profile service, which seems to have half worked. I can see the roles in my authorization token like this: "role": [ "admin", "bookkeeping" ], But when I add the [Authorize(Roles = "admin")] tag to my controller the requests are now forbidden, even when i can see my token includes the role "admin". What am I

Is there a way to use Identity Server features in asp.net core 3.1 Rest-API

拥有回忆 提交于 2021-01-28 02:34:37
问题 I’m working in a project with Rest-API in the server by using asp.net core 3.1, angular as front for single page application. From each client, the user would need to supply their username and password in order to access protected parts of the web API. I would like to use the features of Identity Server to access the ASP.NET Core Identity UserManager, RoleManager, and SignInManagers to determine if the supplied username and password is valid. I haven't ever been done this before and I tried

Is there a way to use Identity Server features in asp.net core 3.1 Rest-API

心不动则不痛 提交于 2021-01-27 20:50:23
问题 I’m working in a project with Rest-API in the server by using asp.net core 3.1, angular as front for single page application. From each client, the user would need to supply their username and password in order to access protected parts of the web API. I would like to use the features of Identity Server to access the ASP.NET Core Identity UserManager, RoleManager, and SignInManagers to determine if the supplied username and password is valid. I haven't ever been done this before and I tried

ASP.NET Core 2 - GetUserIdAsync returning null Result with Guid Ids

只谈情不闲聊 提交于 2021-01-27 20:05:18
问题 I'm currently porting a site to ASP.NET Core 2 and am getting the following Exception thrown when I call userManager.GenerateEmailConfirmationTokenAsync(user) with a user class that extends IdentityUser<Guid> : System.ArgumentNullException: Value cannot be null. Parameter name: value at System.IO.BinaryWriter.Write(String value) at Microsoft.AspNetCore.Identity.DataProtectorTokenProvider`1.<GenerateAsync>d__11.MoveNext() GenerateAsync() makes a call to UserManager.GetUserIdAsync(), which is

ASP.NET Core 3.1.1 Jwt redirects instead of returning http status 401 after migration from ASP.NET Core 2.2

混江龙づ霸主 提交于 2021-01-04 14:54:59
问题 After migrating my website from .NET Core 2.2 to 3.1.1, my api endpoints suddenly started trying to redirect my api request to a default login page ( /Account/Login?ReturnUrl= , which I don't even have in any of my routes). My api is using a JWT bearer authentication scheme, with JWT Challenge Scheme, but still the redirect happened. services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultScheme = JwtBearerDefaults