asp.net-core-identity

ASP.NET Core 3.1 “'User' does not contain a definition for 'FindFirstValue'”

烂漫一生 提交于 2020-05-17 06:36:29
问题 While trying to implement the answer from here > How to get the current logged in user Id in ASP.NET Core and the user redirected me to here > https://github.com/dotnet/aspnetcore/issues/18348 var UserId = User.FindFirstValue(ClaimTypes.Name); ^ This is not working, and prints the following error 'User' does not contain a definition for 'FindFirstValue' Edit: Adding controller snippet The full snippet of my controller... using System; using System.Collections.Generic; using System.Linq; using

How to Retrieve Claims from Idp-Initiated Login Using Sustainsys Saml2?

随声附和 提交于 2020-05-16 01:13:30
问题 I am trying to add support for SAML authentication to an ASP.NET Core MVC application with ASP.NET Core Identity (not IdentityServer). The flow "works" when testing with StubIdp - the SAMLResponse is POSTed to /Saml2/Acs and I'm redirected to the app with an Identity.External cookie, but my ClaimsPrincipal is empty and unauthenticated. Even if I use the NameID of a user who already exists in the database, the claims are completely empty. I also see the following in the console log: Sustainsys

How to Retrieve Claims from Idp-Initiated Login Using Sustainsys Saml2?

喜你入骨 提交于 2020-05-16 01:13:19
问题 I am trying to add support for SAML authentication to an ASP.NET Core MVC application with ASP.NET Core Identity (not IdentityServer). The flow "works" when testing with StubIdp - the SAMLResponse is POSTed to /Saml2/Acs and I'm redirected to the app with an Identity.External cookie, but my ClaimsPrincipal is empty and unauthenticated. Even if I use the NameID of a user who already exists in the database, the claims are completely empty. I also see the following in the console log: Sustainsys

How to set .AspNetCore.Identity.Application Cookies expiration based on Identity Claims Role?

你说的曾经没有我的故事 提交于 2020-05-14 08:45:08
问题 I'm looking to set the .AspNetCore.Identity.Application Cookie's expiration time based on the role of claims of a user that logs in. In all of the configure options in ConfigureServices I have access to cookie properties but no access to user claims. Therefore I cannot dynamically set the expiration time. We are using Microsoft.AspNetCore.Identity SignInManager to authenticate. Can anyone point me in the right direction as to what class I need to override or what middleware I need to register

ASP.NET Core Identity impersonate specific user

淺唱寂寞╮ 提交于 2020-05-08 04:29:59
问题 Let's say I have the following roles: Admin User I want Admin role to impersonate specific user account with User role, but without knowing that specific user account's password. Admin should be able to impersonate any user from the application and be able to browse the application as the user himself. I found a link where this is actually implemented in ASP.NET MVC 4.6, but having a little headaches while converting this to Core version. Mostly because of the last line of code in the link

ASP.NET Core Identity impersonate specific user

淺唱寂寞╮ 提交于 2020-05-08 04:28:08
问题 Let's say I have the following roles: Admin User I want Admin role to impersonate specific user account with User role, but without knowing that specific user account's password. Admin should be able to impersonate any user from the application and be able to browse the application as the user himself. I found a link where this is actually implemented in ASP.NET MVC 4.6, but having a little headaches while converting this to Core version. Mostly because of the last line of code in the link

How to get the current external provider in HomeController of ASP.NET Core 2.0 MVC application

懵懂的女人 提交于 2020-03-20 13:55:53
问题 I'm creating ASP.NET Core 2.0 MVC with individual accounts. Google and Microsoft authentication is working fine. Now I'm using it to access data in Google and Microsoft accounts (this happens in HomeController). I can do this just fine if I know which provider to use. In AccountController, the info about the currently used provider (e.g. Google, Microsoft) is available out-of-the-box. But this info does not persist so I can't use it in HomeController. signInManager.GetExternalLoginInfoAsync()

How to get the current external provider in HomeController of ASP.NET Core 2.0 MVC application

元气小坏坏 提交于 2020-03-20 13:55:25
问题 I'm creating ASP.NET Core 2.0 MVC with individual accounts. Google and Microsoft authentication is working fine. Now I'm using it to access data in Google and Microsoft accounts (this happens in HomeController). I can do this just fine if I know which provider to use. In AccountController, the info about the currently used provider (e.g. Google, Microsoft) is available out-of-the-box. But this info does not persist so I can't use it in HomeController. signInManager.GetExternalLoginInfoAsync()

.NET Core 3.1 ChangePasswordAsync Inner Exception “Cannot update Identity column”

一笑奈何 提交于 2020-03-14 11:08:31
问题 I am upgrading a .NET Core Web API from 2.2 to 3.1. When testing the ChangePasswordAsync function, I receive the following error message: Cannot update identity column 'UserId'. I ran a SQL Profile and I can see that the Identity column is not included in the 2.2 UPDATE statement but it is in 3.1. The line of code in question returns NULL, as opposed to success or errors, and is as follows: objResult = await this.UserManager.ChangePasswordAsync(objUser, objChangePassword.OldPassword,

.NET Core 3.1 ChangePasswordAsync Inner Exception “Cannot update Identity column”

久未见 提交于 2020-03-14 11:08:28
问题 I am upgrading a .NET Core Web API from 2.2 to 3.1. When testing the ChangePasswordAsync function, I receive the following error message: Cannot update identity column 'UserId'. I ran a SQL Profile and I can see that the Identity column is not included in the 2.2 UPDATE statement but it is in 3.1. The line of code in question returns NULL, as opposed to success or errors, and is as follows: objResult = await this.UserManager.ChangePasswordAsync(objUser, objChangePassword.OldPassword,