asp.net-identity

How to create SecurityStamp for AspNetUser in ASP .NET MVC 5

限于喜欢 提交于 2019-12-03 09:48:23
When I create user by Register action whe application is running the application user gets SecurityStamp. When I add user by: if (!context.Users.Any()) { System.Diagnostics.Debug.WriteLine("INSIDE"); var hasher = new PasswordHasher(); try { var users = new List<ApplicationUser> { new ApplicationUser{PasswordHash = hasher.HashPassword("TestPass44!"), Email = "informatyka4444@wp.pl", UserName = "informatyka4444@wp.pl"}, new ApplicationUser{PasswordHash = hasher.HashPassword("TestPass44!"), Email = "informatyka4445@wp.pl", UserName = "informatyka4445@wp.pl"} }; users.ForEach(user => context.Users

How to use Asp.Net Core Identity in Multi-Tenant environment

天涯浪子 提交于 2019-12-03 09:40:39
问题 I have a working Asp.Net Core application with default Identity handling. Now I want to use it for multi domains. I extended ApplicationUser with DomainId. How can I handle not just username / email to authenticate / register the user, but also the current DomainId? It's not a problem to get the current DomainId when the user is registering, logging into the system, I have a working multi-tenant Asp.Net Core system. I have issue only with user management with DomainId. Is there any setting

ASP.NET Identity, add another user to role instantly (they don't have to log out and in again)

不羁的心 提交于 2019-12-03 09:32:46
问题 First of all, I'm aware of this question: MVC 5 AddToRole requires logout before it works? and this one: What is ASP.NET Identity's IUserSecurityStampStore<TUser> interface? so please don't mark this as a duplicate. I'm trying to add another user to a role (i.e. the user we're adding to the role is not the current user. If they are, the answer to first question I linked to is sufficient.) Like so: IdentityResult result = await userManager.AddToRoleAsync(userID, roleName); The two situations I

MVC 5 Role Based Authentication

自闭症网瘾萝莉.ら 提交于 2019-12-03 08:59:19
I am trying to lock down our "admin" page to only admins using Asp.net Identity (we are building in MVC5). I can get [Authorize(Users="admin")] to work but can not get [Authorize(Roles="Admin")] to work. I have created the role in the dbo.AspNetRoles table and then associated the account in the AspNetUserRoles by pairing the user GUID to the ID in the aspnetroles table. I have seen in previous editions of MVC you have had to get into web.config to add some lines. Can anyone help point me in the right direction? Have you specified in the web.config that you are going to use roles? <roleManager

What is the Signing Credential in IdentityServer4?

核能气质少年 提交于 2019-12-03 08:53:56
问题 We are in the process of implementing Identity Server 4 with our .NET Core web app. I went trough the Identity Server documentation. When configuring the Identity server (using DI) there is the line: .AddTemporarySigningCredential I'm trying to understand what this Signing credential is but couldn't figure out. Therefore I don't know if it's ok to use the built in temporary, or if I should provide a different one. My question is, what is a signing credential and how should I use it? In the

Role Management in ASP MVC 5 (Microsoft.AspNet.Identity)

余生颓废 提交于 2019-12-03 08:53:26
in ASP MVC5 RC I didn't get the role system to work. My database has all needs tables an role exist but proofing if user is in role always return false (no SQL exception or something)!? Did I need to activate role system for IPrincipal somewhere? Test code: AccountController accCont = new AccountController(); // check role exist : result = true var roleExist = await accCont.IdentityManager.Roles.RoleExistsAsync("61c84919-72e2-4114-9520-83a3e5f09de1"); // try find role by name : result = role object var role = await accCont.IdentityManager.Roles.FindRoleByNameAsync("ProjectAdministrator"); //

Updating user role using asp.net identity

荒凉一梦 提交于 2019-12-03 08:39:43
I have the following problem. While using the following code below to change the user's current role i am getting an exception with the message like below: [HttpPost] [ValidateAntiForgeryToken] public virtual ActionResult Edit(User user, string role) { if (ModelState.IsValid) { var oldUser = DB.Users.SingleOrDefault(u => u.Id == user.Id); var oldRoleId = oldUser.Roles.SingleOrDefault().RoleId; var oldRoleName = DB.Roles.SingleOrDefault(r => r.Id == oldRoleId).Name; if (oldRoleName != role) { Manager.RemoveFromRole(user.Id, oldRoleName); Manager.AddToRole(user.Id, role); } DB.Entry(user).State

No Individual User Accounts auth option in ASP.NET Core Web API template

眉间皱痕 提交于 2019-12-03 08:19:55
问题 I am a bit confused as to why there is no Individual User Accounts authentication option in the latest ASP.NET Core Web API template. Is it still possible to implement individual user accounts the way that the MVC template does or would it not make sense? Let's say I am creating a stand-alone web API that is going to have all of my business logic and data layer that accesses the database which has the AspNet Identity tables. I plan on making calls to this API w/ an MVC app. I know one way of

Facebook MVC 5 ASP.NET Identity - Email is null for certain users

六月ゝ 毕业季﹏ 提交于 2019-12-03 07:20:47
This is a problem i am trying to solve for a month now. (tried any possible article/code out there). In ExternalLoginCallback action, AuthenticationManager.GetExternalLoginInfoAsync() returns a valid object (with all the provider details) but email is null for certain Facebook users . For the large majority of Facebook login email is presetnt. But for about 30% of logins I get an exception down the process because the email is null. Luckily sometime ago I've created a Facebook user which reproduce the problem . I've created a sterile test environment in localhost and indeed email comes null

Ninject and ASP.NET Identity 2.0

只愿长相守 提交于 2019-12-03 07:11:50
I just upgraded the ASP.NET Identity Entity Framework package from 1.0 to 2.0 and one of the Ninject bindings is now broken: kernel.Bind<IUserStore<User>>().To<UserStore<User>>(); kernel.Bind<UserManager<User>>().ToSelf(); kernel.Bind<IRoleStore<IdentityRole>>().To<RoleStore<IdentityRole>>(); kernel.Bind<RoleManager<IdentityRole>>().ToSelf(); The second last one is giving this error on compile: The type 'Microsoft.AspNet.Identity.EntityFramework.RoleStore' cannot be used as type parameter 'TImplementation' in the generic type or method 'Ninject.Syntax.IBindingToSyntax.To()'. There is no