asp.net-identity-2

Invalidate ASP.NET Identity 2.0 login without removing the application cookie

泄露秘密 提交于 2019-12-23 02:36:52
问题 Background The application I'm working on is running on several different domains, all sharing the same database and IIS process. The user may switch between these domains by clicking a link, and should remain logged in when doing so. To accomplish this, when the switch domain link is clicked I create an entry in the database which contains the current value of the Identity 2 application cookie (named .AspNet.ApplicationCookie by default). The user is then redirected to the new domain, where

Duplicate Role Names on Asp.Net Identity and Multi-tenancy

倖福魔咒の 提交于 2019-12-22 14:44:07
问题 I'm developing a Multi-tenancy web application with ASP.Net MVC and Identity 2.0. I have extended the IdentityRole like this: public class ApplicationRole : IdentityRole { public ApplicationRole() : base() { } public ApplicationRole(string name) : base(name) { } public string TenantId { get; set; } } This because each Tenant will have individual sets of roles, like "Admin", "Staff", etc. But the problem is, when I add a new Role, if the "Tenant A" has "Admin" role, when I add to "Tenant B"

Duplicate Role Names on Asp.Net Identity and Multi-tenancy

三世轮回 提交于 2019-12-22 14:43:02
问题 I'm developing a Multi-tenancy web application with ASP.Net MVC and Identity 2.0. I have extended the IdentityRole like this: public class ApplicationRole : IdentityRole { public ApplicationRole() : base() { } public ApplicationRole(string name) : base(name) { } public string TenantId { get; set; } } This because each Tenant will have individual sets of roles, like "Admin", "Staff", etc. But the problem is, when I add a new Role, if the "Tenant A" has "Admin" role, when I add to "Tenant B"

using aspnet identity with custom tables

核能气质少年 提交于 2019-12-22 10:52:54
问题 I am working on asp.net MVC core application. I have custom database with users and roles tables. I want to use asp.net identity with custom tables so that I don't have to use aspnetusers, aspnet roles tables. How to do it with asp.net identity and asp.net core 回答1: Good luck with that! :) I have just gone through that process last few days. I've got it to work but its really painful at some stages. In short: You need to create your own user model that implements IUser interface. You need to

Web API 2 AccessFailedCount not Incrementing When using Token Based Authentication

早过忘川 提交于 2019-12-22 08:48:13
问题 I am using Webapi with Identity2.0 AccessFailedCount, LockoutEndDateUtc is not incermenting on Invalid UserName and Password. I have implement Token Based Authentication provided by WebAPI. Please help . here is code Snippet using (UserManager<ApplicationUser> userManager = userManagerFactory) { ApplicationUser user = await userManager.FindAsync(context.UserName, context.Password); if (user == null) { context.SetError("invalid_grant", "The user name or password is incorrect."); return; } if

How to change the cookie ExpireTimeSpan in Asp.Net Identity after ConfigureAuth

£可爱£侵袭症+ 提交于 2019-12-22 07:45:07
问题 We have a product that is using Asp.Net identity where we want the cookie expiry time to be configurable. The ExpireTimeSpan is currently set in the Startup.ConfigureAuth class that the Visual Studio creates for you with a new project. This is getting the time from a configuration file on startup but we want to be able to change this value from a webAPI. As it stands, the webAPI request can modify the config file but we need to recycle the app pool to get it to take effect. Is there any way

RemoveClaimAsync Identity 2.2

☆樱花仙子☆ 提交于 2019-12-21 20:13:55
问题 I have problem with Identity 2.0 . I'm trying to update claim on a user. So here is my code. var UserID = User.Identity.GetUserId(); var claims = await UserManager.GetClaimsAsync(UserID); var displayName = claims.FirstOrDefault(i => i.Type == "DisplayName"); var isPublic = claims.FirstOrDefault(i => i.Type == "IsPublic"); if (displayName != null) await UserManager.RemoveClaimAsync(UserID, displayName); if (isPublic != null) await UserManager.RemoveClaimAsync(UserID, isPublic); await

ASP.NET Identity 2 UserManager get all users async

放肆的年华 提交于 2019-12-21 03:21:29
问题 Can somebody tell if there is a way to get all users async in ASP.NET Identity 2? In the UserManager.Users there is nothing async or find all async or somwething like that 回答1: There is no way to do this asynchronously with the UserManager class directly. You can either wrap it in your own asynchronous method: (this might be a bit evil) public async Task<IQueryable<User>> GetUsersAsync { return await Task.Run(() => { return userManager.Users(); } } Or use the ToListAsync extension method:

Custom ASP.NET Identity 2.0 UserStore - Is implementing all interfaces required?

人走茶凉 提交于 2019-12-20 17:34:25
问题 I've created a custom IUserStore<TUser,int> for my application. I've implemented the interfaces I need, IUserStore<TUser, int>, IUserRoleStore<TUser, int>, IUserLockoutStore<TUser, int>, IUserPasswordStore<TUser, int> but when I call var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: false); I get an exception saying Store does not implement IUserTwoFactorStore<TUser>. I'm not using two factor authentication anywhere in my

Seeding Identity 2.0 database

此生再无相见时 提交于 2019-12-20 12:33:26
问题 I have an ASP.NET MVC 5 project (razor engine) which has Identity 2.0 with Individual User Accounts. I am using Visual Studio Professional 2013 I have not found any clear example (why doesn't it come out of the box?) of HOW I can seed the Identity 2.0 database and all examples I see are half backed because they don't say WHERE exactly you have to implement that. I used enable-migrations which created a Migrations folder with a Configuration.cs file. It has a Seed method override but when I