asp.net-identity

Asp.net web forms, Asp Identity - how to store claims from Facebook, Twitter, etc

半城伤御伤魂 提交于 2019-12-20 03:22:29
问题 This request is based upon the new Visual Studio 2013 integration of Asp.net Identity stuff. I have seen some of the posts regarding this question for MVC, but for the life of me cannot get it to work for standard Web Forms. What I'm trying to do is populate the AspNetUserClaims table from the claims that I get back from Facebook (or other service). I actually can see the values coming back in the OnAuthenticated below, but cannot for the life of me figure out how to add these claims to the

Why does a role shows as “not exist” even when present in the database (asp.net mvc)

微笑、不失礼 提交于 2019-12-20 03:13:38
问题 I'm trying to add users to a role when registering a user so i seeded the roles and updated the database with the code below in the migrations.cs class var RoleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(context)); string[] roleNames = { "Admin", "Reviewer", "User" }; IdentityResult roleResult; foreach (var roleName in roleNames) { if (!RoleManager.RoleExists(roleName)) { roleResult = RoleManager.Create(new IdentityRole(roleName)); } } i tried to fetch the roleNames

MVC5 Identity + multiple context in EntityFramework

拈花ヽ惹草 提交于 2019-12-20 02:52:19
问题 I have a MVC 5 application, which uses the Default Identity authentication. The user profile is part of our model, which means that there are several class which have a foreign key to the UserInfo. There are 2 DbContext, one for the model and another for the UserInfo. public class ApplicationDbContext : IdentityDbContext<UserInfo> { public ApplicationDbContext() : base("Profile") { } } public class UserInfo : IdentityUser { public UserInfo () { LibraryItems = new List<LibraryItem>(); if

How to remove the role-related tables from ASP.NET Identity Core 2.0

旧巷老猫 提交于 2019-12-20 02:52:13
问题 With the advice read-elsewhere that Roles are a subset of Claims, I am looking at a clean way to ask the EF Core implementation in ASP.NET Identity not to create role-related tables in the ASP.NET Identity Core 2.0 template in VS 2017. Only claims are needed. The template uses public class ApplicationDbContext : IdentityDbContext<ApplicationUser> { public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } protected override void OnModelCreating

Invalid_client using OpenIdConnect in client application

会有一股神秘感。 提交于 2019-12-20 02:29:11
问题 I have an IdentityServer4 application running with ASP.NET Identity. I want to use that so users from another application can login through my remote identity server. I have configured a client application in identity server with the following settings (showing only relevant settings): ClientId: mvc ProtocolType: oidc ClientSecret: K7gNU3sdo+OL0wNhqoVWhr3g6s1xYv72ol/pe/Unols= (URLs to client app) RedirectUri: https://localhost:44313/signin-oidc PostLogoutRedirectUri: https://localhost:44313

ASP.NET Identity and mobile clients

筅森魡賤 提交于 2019-12-19 19:46:56
问题 The latest version of ASP.NET includes the new authentication framework ASP.NET Identity, which should be the core building block for user management in all new and near future ASP.NET projects and websites. I have seen that it can integrate with the WebAPI quite nicely, but haven't seen any example of integration as authentication for mobile client devices. For example - suppose I have a ASP.NET website with Identity implemented in use. Now I want to build client applications for Windows 8.1

Get Role name in IdentityUserRole 2.0 in ASP.NET

情到浓时终转凉″ 提交于 2019-12-19 12:54:23
问题 Before the update of the dll's in the Entity Framework i was able to do this user.Roles.Where(r => r.Role.Name == "Admin").FisrtOrDefault(); Now, i can only do r.RoleId, and i can't find a way to retreive the name of thar Role Id. I'm using this in my controllers and in my AuthorizeAttribute class. Can someone help me here? Regards 回答1: Ask the RoleMananger? RoleManager.Roles. // or RoleManager.FindByIdAsync() // or RoleManager.FindByNameAsync() You may want to take some time and learn the

Error 401 Unauthorized. How to Use the same token for different Urls?

柔情痞子 提交于 2019-12-19 10:25:03
问题 In ASP.Net Identity using Oauth2 a token is created once the user is authenticated posting User and Password. Before making a call to an action from one API, the user must ask for a token: http://mysite/auth/token Once the token is received, all Web Api calls can be done, sending the Authorization: Bearer <token> header: GET http://mysite/auth/product/1 PUT http://mysite/auth/client/42 I have several Web Apis that use a centralised Security System for Authentication, the problem is that I

ASP .Net Core Identity Role Claims not adding to User

时间秒杀一切 提交于 2019-12-19 10:08:09
问题 I'm having issues with using Role/Claims. I have created Roles and given the roles claims. Then assigned these roles to the users, from what I read online this means the User should inherit the Role Claims but they don't. The policy's didn't work and upon further inspection I couldn't see the claims when outputting the user claims via JSON. All the data is being saved in the database as I can see it. Role/Claim Seeder public static void SeedRolesAndClaims(RoleManager<IdentityRole> roleManager

OnValidateIdentity disables the MVC OWIN remember me option

断了今生、忘了曾经 提交于 2019-12-19 10:07:58
问题 When I activate the OWIN logout-everywhere feature via security stamps and use the OnValidateIdentity -Callback of the CookieAuthenticationProvider with the SecurityStampValidator -class, the user is logged out every time he closes the browser. provider.OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<MyUserManager, MyUser>( System.TimeSpan.FromSeconds(10),(manager, user) => { return user.GenerateUserIdentityAsync(manager); }); However, when I do the plumbing myself (lookup and