asp.net-identity

ASP.NET Identity update column type for primary key Id in AspNetUsers table from a string to and int or a guid, yes or no?

二次信任 提交于 2020-01-04 00:14:52
问题 Today I read about the new features in ASP.NET Identity 2.0 alpha. http://blogs.msdn.com/b/webdev/archive/2013/12/20/announcing-preview-of-microsoft-aspnet-identity-2-0-0-alpha1.aspx Apparently the possibility to use and int or a guid as the primary key for the AspNetUsers table was added after numerous post/questions on stackoverflow. I started using ASP.NET Identity when the RTM was announced. Since then I have been using the default string ( nvarchar(128) ) type for the Id column in the

how to get claims of another user using ASP.NET Core

偶尔善良 提交于 2020-01-03 13:40:12
问题 I'm still learning identities with asp.net core. I'm doing a claims-based token authorization. Most examples are about "Current" logged in user. In my case my RPC service is receiving a username & password of some user in the identity DB. I need to verify that a user with such credentials exist get all the claims of that user so to verify if the user exists, I'm using this: ApplicationUser applicationUser = await _userManager.FindByNameAsync(username); bool exist = await _userManager

ASP.NET Core Identity. Using ApplicationDbContext and UserManager. Do they share the context?

强颜欢笑 提交于 2020-01-03 11:33:21
问题 i have an database initialization method in an ASP.NET MVC Core 2 application. In that method i'm using ApplicationDbContext and UserManager to initialize the database. I get both instances from the constructor's dependency injection: public static void Initialize(ApplicationDbContext context, UserManager<ApplicationUser> user) What i want to know is if they share the same context instance or if one context is created for ApplicationDbContext and another for UserManager. If i execute

ASP.NET Core Identity. Using ApplicationDbContext and UserManager. Do they share the context?

杀马特。学长 韩版系。学妹 提交于 2020-01-03 11:32:45
问题 i have an database initialization method in an ASP.NET MVC Core 2 application. In that method i'm using ApplicationDbContext and UserManager to initialize the database. I get both instances from the constructor's dependency injection: public static void Initialize(ApplicationDbContext context, UserManager<ApplicationUser> user) What i want to know is if they share the same context instance or if one context is created for ApplicationDbContext and another for UserManager. If i execute

How to get access token from httpcontext using owin and Mvc 5

▼魔方 西西 提交于 2020-01-03 10:48:41
问题 I've got a IDP implemented in IdentityServer 4. My web app client(implemented in Mvc 5) authenticates with the IDP but now I need to get the access token from the request. A way to do that in .Net Core is to use the Microsoft.AspNetCore.Authentication.AuthenticationTokenExtensions like so: HttpContext.Authentication.GetTokenAsync("acccess_token") I would like to be able to do the same in my .net Mvc5 web app client but I can't find any nuget package or namespace that has a similar

ASP.NET Identity doesn't load any claims

冷暖自知 提交于 2020-01-03 04:38:11
问题 I have a ASP MVC 5 site using the new identity framework with 3rd party authentication using entity framework as it comes out of the box. I have a logged in user and they have 3 claims (the standard name nameidentifier and authentication provider that seem to be provided by the default ClaimsIdentityFactory). When a user performs some operation I then add a claim for them using this: userManager.AddClaim(userId, new Claim(claimType,claimValue)); If I look in the db in the AspNetUserClaims

How to create two type of users with identity and .net core 2

两盒软妹~` 提交于 2020-01-03 03:23:33
问题 I start to develop an web application with .net core 2 and web service.. when a user registers on the site, he can choose whether he is a company or a simple user, so I store the data in a specific table but the login data are stored in AspNetUsers. How can i handle it with Identity in .net core? 回答1: Simply inherit from ApplicationUser , i.e.: public class CompanyUser : ApplicationUser {} public class SimpleUser : ApplicationUser {} By default, EF will implement inheritance via STI (single

How to do handle login-logoff

时间秒杀一切 提交于 2020-01-03 02:30:12
问题 I am using the new user authentication system Asp.Net Identity in my project. I have a situation where I have to store 3 types of users in database i.e.: Student Teacher Admin Now all these 3 have there separate table contains different information about each one of them. I want Asp.Net Identity to handle their login, logoff and password maintance for each type of user. Can anyone please guide me with the overview of how can I handle this situation? 回答1: You need an inheritance structure like

How to create roles in ASP.NET Core 2.2 and assign them to users

狂风中的少年 提交于 2020-01-02 16:51:30
问题 I am using asp.net core 2.2 default web site template and authentication selected as individual user account. How can i create an "Admin" role and assign it to a user so that i can use role in controller to filter the access and let them see different pages. Here is what i found on the internet until now, but it doesn't work, because it says : ApplicationUser could not be found private void CreateRoles(IServiceProvider serviceProvider) { var roleManager = serviceProvider.GetRequiredService

Correlation failed. at Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler during OIDC authentication

♀尐吖头ヾ 提交于 2020-01-02 12:17:33
问题 I am hitting this with the following combination: 1) Browser incognito mode (Chrome) 2) Application is behind Azure application gateway (no repro if it isnt). Cookie based affinity is turned OFF (default); if turned ON, seems to make repro happen more often. Code is rather plain vanilla OIDC authN + cookies. services.AddAuthentication(options => { options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = OpenIdConnectDefaults