asp.net-identity

User.Identity.Name is null in my ASP.NET Core Web API

荒凉一梦 提交于 2020-05-14 11:57:49
问题 I have added ASP.NET Core identity and Identity Server4 in one project with one database, and I want to use my Identity Server in all other project. IdentityServer4 Startup Class public class Startup { public IConfigurationRoot Config { get; set; } public Startup(IConfiguration configuration) { Config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", false) .Build(); Configuration = configuration; } public IConfiguration Configuration

Recommended best practice for role claims as permissions

偶尔善良 提交于 2020-05-10 03:08:51
问题 The app I am working on is a SPA and we are using JWT Bearer authentication and OpenIdConnect/OAuth2 when communicating with our backend API which uses .NETCore and ASP.NET Identity. Our API endpoints are secured using Custom Policy based authentication as shown here: Custom Policy Based Authentication We decided to use the out of the box AspNetRoleClaims table to store claims for our users as permissions. Each user is assigned 1 primary role although the potential is there to have multiple

Recommended best practice for role claims as permissions

半腔热情 提交于 2020-05-10 03:08:02
问题 The app I am working on is a SPA and we are using JWT Bearer authentication and OpenIdConnect/OAuth2 when communicating with our backend API which uses .NETCore and ASP.NET Identity. Our API endpoints are secured using Custom Policy based authentication as shown here: Custom Policy Based Authentication We decided to use the out of the box AspNetRoleClaims table to store claims for our users as permissions. Each user is assigned 1 primary role although the potential is there to have multiple

How can I fix email confirmation - in .NET Core, it doesn't work

本小妞迷上赌 提交于 2020-04-16 04:05:33
问题 I already have a register action public async Task<IActionResult> OnPostAsync(string returnUrl = null) { var useremail = _userManager.Users.FirstOrDefault(u => u.Email.ToLower() == Input.Email.ToLower()); if (useremail == null) { returnUrl = returnUrl ?? Url.Content("~/"); ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); if (ModelState.IsValid) { var user = new IdentityUser { UserName = Input.UserName, Email = Input.Email }; var result = await

Smart way for User Authorization (without creating table, etc.) in ASP.NET MVC

 ̄綄美尐妖づ 提交于 2020-04-10 05:53:33
问题 I use an external provider in order to authenticate user in my ASP.NET MVC app without any problem. However, I also need to authorize users in order to prevent them from direct access or expired access (session for 2 min). I had used ASP.NET Identity before, but this time I do not need to keep neither users nor roles on the table and for this reason I need a quick and good workaround for this problem. So, how can I prevent a user accessing the In dex page of my app without authenticating by

How to add ASP.Net identity to Asp.Net Core when webApi template is selected?

喜夏-厌秋 提交于 2020-04-07 17:43:18
问题 I have created a .NET Core project with WebApi template selected includes no authentication. I want to add ASP.NET identity in it for role based authorization. How can I achieve this? 回答1: This will give you a bear bones webapi with aspnet core identity, first create your project (this assumes you've created a new folder and you're in it): dotnet new webapi Add aspnet core identity: dotnet add package Microsoft.AspNetCore.Identity Add some database provider to store your data: dotnet add

ASP.Net Core Identity login status lost after deploy

ⅰ亾dé卋堺 提交于 2020-04-07 13:58:38
问题 I am using ASP.Net Core and MS Identity, I try to understand why after each deployment the login users are logged out. I am running on a IIS 8.5 I have been trying the method in this thread (setting static machine key) ASP.NET Identity 2 relogin after deploy by generating static keys at the server level in IIS UI and adding the following to web.config of the website: <system.web> <machineKey validationKey="XXX" decryptionKey="XXX" validation="SHA1" decryption="AES"/> </system.web> However the

ASP.Net Core Identity login status lost after deploy

你离开我真会死。 提交于 2020-04-07 13:56:51
问题 I am using ASP.Net Core and MS Identity, I try to understand why after each deployment the login users are logged out. I am running on a IIS 8.5 I have been trying the method in this thread (setting static machine key) ASP.NET Identity 2 relogin after deploy by generating static keys at the server level in IIS UI and adding the following to web.config of the website: <system.web> <machineKey validationKey="XXX" decryptionKey="XXX" validation="SHA1" decryption="AES"/> </system.web> However the

ASP.Net Core Identity login status lost after deploy

落爺英雄遲暮 提交于 2020-04-07 13:53:10
问题 I am using ASP.Net Core and MS Identity, I try to understand why after each deployment the login users are logged out. I am running on a IIS 8.5 I have been trying the method in this thread (setting static machine key) ASP.NET Identity 2 relogin after deploy by generating static keys at the server level in IIS UI and adding the following to web.config of the website: <system.web> <machineKey validationKey="XXX" decryptionKey="XXX" validation="SHA1" decryption="AES"/> </system.web> However the

IdentityServer4 - sub claim is missing

二次信任 提交于 2020-03-22 08:05:32
问题 I've got an IdentityServer4 instance that I'm trying to get running in a Docker container behind an nginx proxy. I've based it on the AspNet identity sample from the Git repo, but after a user successfully registers a new account I get "An error occurred" from IdentityServer and the logs show [07:46:39 ERR] An unhandled exception has occurred: sub claim is missing System.InvalidOperationException: sub claim is missing at IdentityServer4.IdentityServerPrincipal.AssertRequiredClaims