asp.net-identity

Asp.net identity Google account id migration from openId to oauth

空扰寡人 提交于 2020-01-01 07:04:29
问题 I have an existing asp.net mvc5 application using DotNetOpenAuth for Google OpenId authentication. I am migrating to Asp.Net Identity, and using Google+ Auth with OAuth2.0. But I have seen thant I can't map existing OpenId account Id to OAuth2.0 Id : - Old id is : https://www.google.com/accounts/o8/id?id=blablabla - New Id is : a long number Since I would like to use new id, I am searching for help on migrating identities. I have not found yet a simple sample to achieve this. I am using a new

Asp.net identity Google account id migration from openId to oauth

无人久伴 提交于 2020-01-01 07:04:21
问题 I have an existing asp.net mvc5 application using DotNetOpenAuth for Google OpenId authentication. I am migrating to Asp.Net Identity, and using Google+ Auth with OAuth2.0. But I have seen thant I can't map existing OpenId account Id to OAuth2.0 Id : - Old id is : https://www.google.com/accounts/o8/id?id=blablabla - New Id is : a long number Since I would like to use new id, I am searching for help on migrating identities. I have not found yet a simple sample to achieve this. I am using a new

How to create different user types in ASP.NET Identity?

微笑、不失礼 提交于 2020-01-01 05:15:11
问题 I'm new to web development. Now I learn ASP.NET MVC 5 with ASP.NET Identity. Can you give me some advices in my situation: In my site I want to have some types of users. For example: Buyer Seller Each of them can login and control his part of information.(e.g. Buyer can change his info, add requests. Seller also can change his own info and add goods) Now, i create something like that: using Microsoft.AspNet.Identity.EntityFramework; using System.Data.Entity; public class ApplicationUser :

ASP.NET Identity - Error when changing User ID Primary Key default type from string to int AND when using custom table names

微笑、不失礼 提交于 2020-01-01 05:10:08
问题 I'm using Microsoft.AspNet.Identity 2.0.0-beta1 and Entity Framework 6.1.0-beta1 (released 11 Feb 2014). I'm getting the following error when I try to change the default type of User ID Primary Key from string to int AND when I try to use custom table names (so User.MyUsers instead of dbo.AspNetUsers): " The entity types 'IdentityUser' and 'ApplicationUser' cannot share table 'MyUsers' because they are not in the same type hierarchy or do not have a valid one to one foreign key relationship

How to secure IdentityManager with IdentityServer v3

隐身守侯 提交于 2020-01-01 03:24:08
问题 Brock Allen released the new beta version of IdentityManager last week. There are quite some changes in the security model, so the configuration also changed. He even took some videos (Setting up ASP.NET Identity and Security and IdentityManager) on how to configure the new version properly. These well explain the usage in a classic ASP.NET MVC application, and also ADFS setup, but I couldn't find any help or sample code about how to make it work side by side with Identity Server v3. Can you

Updating user role using asp.net identity

混江龙づ霸主 提交于 2020-01-01 00:34:28
问题 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) {

implementing roles in identity server 4 with asp.net identity

落爺英雄遲暮 提交于 2019-12-31 13:27:13
问题 I am working on an asp.net MVC application with identity server 4 as token service. I have an api as well which has some secure resources. I want to implement roles (Authorization) for api. I want to make sure that only an authorized resource with valid role can access an api end point otherwise get 401 (unauthorized error). Here are my configurations: Client new Client() { ClientId = "mvcClient", ClientName = "MVC Client", AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,

Change from Roles authorization to Claims authorization

允我心安 提交于 2019-12-31 05:06:59
问题 I have a webforms application which was built with ASP.NET Membership. I migrated to Identities successfully. I now want to use Claims authorization instead of Roles authorization, but the Role information for the old users has been migrated to the AspNetUserRoles table in the database but the AspNetUserClaims table is empty. New users registered after migration, I can add to AspNetUserClaims with the following code: IdentityResult result1 = manager.AddClaim(user.Id, new Claim(ClaimTypes.Role

How do I expose `UserManager<IApplicationUser>` to my business layer while hiding `IdentityUser`?

不想你离开。 提交于 2019-12-31 04:27:11
问题 I don't want to reference EntityFramework and hence Identity.EntityFramework with its IdentityUser in my domain. But I'd like to use UserManager of Identity.Core which uses IUserStore<TUser> where TUser : IUser<string> . And hence I need to expose that IUserStore while hiding ApplicationUser as it derives from IdentityUser . In my data access layer: public class ApplicationUser : IdentityUser, IApplicationUser { } // somewhere for IoC container: var userStore = new UserStore<ApplicationUser>(

ASP.Net Identity built in functions with custom tables in ASP.Net Core

余生颓废 提交于 2019-12-31 02:39:13
问题 I am using ASP.Net Core Web Api 2 on .Net 2.1 Framework I have custom AppUsers and AppRoles tables, linked with bridge table AppUserRoles My main problem is that I want to use [Authorize(Roles = "UserRole")] As User.Identity is working fine and I am getting user Id from User.Identity.Name I thought there was some way to set roles and check them before controller request, or to use User.IsInRole("UserRole") for checking inside controller. Is it possible to rebuild or overload .IsInRole(