asp.net-identity

There is already an object named AspNetRoles in the database. (entity-framework-core)

瘦欲@ 提交于 2019-12-10 18:43:15
问题 I have an asp.net core mvc website using entity framework core. I don't know how it initially happened, but I can't get past the error: "There is already an object named AspNetRoles in the database" I ended up deleted the database, deleting all my migration .cs files and starting from scratch. I've then tried add-migration MyInitialMigration same error I then deleted the database again, and tried a direct update-database (without adding a migration) still the same error I tried changing the

Asp.net Identity logout other user

喜欢而已 提交于 2019-12-10 18:15:27
问题 I'm usigin Asp.net Identity to authenticate user and I'm trying to lockout any user from admin side. But when I lockout any user who is online, It didn't logout. I have read many comments about my problem but all of them didn't work. I tried UserManager.UpdateSecurityStamp to logout user but it didn't work as well. How can I logout the user instantly when I lockout it ? public ActionResult LockUser(string userId) { _userManager.SetLockoutEnabled(userId, true); _userManager.SetLockoutEndDate

MVC Anti forgery token error on scaffold

﹥>﹥吖頭↗ 提交于 2019-12-10 18:14:05
问题 I'm recieving the following error: {"A claim of type 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier' or 'http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider' was not present on the provided ClaimsIdentity. To enable anti-forgery token support with claims-based authentication, please verify that the configured claims provider is providing both of these claims on the ClaimsIdentity instances it generates. If the configured claims provider

OnValidateIdentity session is null - Mvc Owin

大憨熊 提交于 2019-12-10 17:56:11
问题 Currently, I have problems when access Session in OnValidateIdentity - HttpContext.Current.Session is null. What's I wrong . My application as below: - I have 2 project : Mvc vs WebApi - I want user will logout when I changed password -> change security stamp. - I implement as: The Mvc Project will validate SecurityStamp changed when user request. And I'm will get SecurityStamp from other webapi website . This mean My mvc not access directly to database that through out webapi. And I'm must

ASP.net Identity - How does UserManager<TUser> Have Access To Roles?

微笑、不失礼 提交于 2019-12-10 17:21:21
问题 ... and we're only inside Microsoft.AspNet.Identity. (We're not even looking at the base implementation at Microsoft.AspNet.Identity.EntityFramework.) The UserManager class only takes in an IUserStore<TUser> at constructor. It does not have an IUserRoleStore<TUserRole> which I imagine would need to be accessed to determine whether UserManager.IsInRoleAsync(string, string) or not. I'm thinking UserStore's implementation would have an IsInRoleAsync(string, string) function as well (then it

How to mock UserManager<IdentityUser>

霸气de小男生 提交于 2019-12-10 17:13:04
问题 I am trying to work out how to add unit testing to my project. I thought it was best to start with a blank project and work it out from the start rather than adding it to my main project. Once I understand the process i figure i can start refactoring my project for adding testing. web application So i created a web application and added default user identity to it. This gave me a start up looking like this public void ConfigureServices(IServiceCollection services) { services.Configure

ASP.Net MVC 6 + WebAPI Auth - Redirect MVC to logon but 401 if WebAPI

懵懂的女人 提交于 2019-12-10 16:38:45
问题 I have a AngularJS + MVC + WebAPI where I'm trying to: - Use standard (individual accounts) for MVC authentication; - Use those same users and password for WebAPI based authentication. Problem, from AngularJS everything works fine, the cookie exchange happens, and Web API returns the value, but when I'm trying to access the WebAPI from Postman, I get a redirect to logon page instead of a 401 Unauthorized. What is the easiest way to achieve this? Do I have to subclass Authorize and implement

How to add additional claims in Api Project when using IdentityServer 4

半世苍凉 提交于 2019-12-10 16:37:14
问题 Sorry for my english. I have three projects: IdentityServer, Ensino.Mvc, Ensino.Api. The IdentityServer Project provides the main identity information and claims - claim Profile, claim Address, claim Sid... etc, from the IdentityServer4 library. The Ensino.Mvc Project gets this information in a token and sends it to the API, so that the MVC is grranted access to the resources. The token contains all the claims provided by IdentityServer. But in the API, I need to generate other claims that

Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory'

风流意气都作罢 提交于 2019-12-10 16:26:11
问题 Following is the exact exception I am getting while running my .NET application. An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Generic.Helpers.dll Additional information: Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.28.1.741, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. I have a console application which references a private assembly (.dll).

Checking for one of multiple policies with Authorize attribute in ASP.NET Core Identity

﹥>﹥吖頭↗ 提交于 2019-12-10 15:55:32
问题 I have setup a standard authentication system up in an ASP.NET Core application. Users, Roles, RoleClaims(acting as permissions) In Startup.cs I create a policy for each Role and each Permission. Assuming this would give me full flexibility in my Views to be able to say I want this button to show if user is part of a role that has claim DeleteCustomer or if User belongs to role Superuser. How can I do an OR condition using the Authorize attribute. For example all throughout my site I want