asp.net-identity

ASP.NET Identity + Facebook login: Pass in “rerequest?”

一世执手 提交于 2019-12-01 12:29:48
问题 (Using ASP.NET Identity 2.1, Microsoft.Owin.Security.Facebook 3.0.1 in a Web API project) From here: https://developers.facebook.com/docs/facebook-login/login-flow-for-web/v2.2 This is because once someone has declined a permission, the Login Dialog will not re-ask them for it unless you explicitly tell the dialog you're re-asking for a declined permission. You do this by adding the auth_type: rerequest flag to your FB.login() call: FB.login( function(response) { console.log(response); }, {

Is there a way to create a custom User and Role without specifying the TKey on IdenitityUser, IdentityRole, and IdentityDbContext?

☆樱花仙子☆ 提交于 2019-12-01 11:29:54
Is there a way to create a custom User and Role without specifying the TKey string in IdentityUser , IdentityRole , and IdentityDbContext ? I ask because it seems to think I don't want the auto-generated primary key Id anymore and I absolutely do. Doing what I've done below, UserManager.Create(user, password) will fail with an EntityValidationError on Id . public class ApplicationUser : IdentityUser<string, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim> { [Required] [StringLength(50)] public string FirstName { get; set; } [Required] [StringLength(50)] public string LastName {

OnValidateIdentity disables the MVC OWIN remember me option

六眼飞鱼酱① 提交于 2019-12-01 11:24:15
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 comparison of the security stamps, rejecting or renewing the identity) in the OnValidateIdentity

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

谁说我不能喝 提交于 2019-12-01 10:50:15
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 receive Unauthorizaed (401) when I try to call different Api (with different URL). For example: GET http:/

ASP .Net Core Identity Role Claims not adding to User

ぐ巨炮叔叔 提交于 2019-12-01 10:47:42
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) { // Create Roles IdentityRole adminRole = new IdentityRole("Admin"); roleManager.CreateAsync

How to Use ASP.NET Identity with your own Custom Table

淺唱寂寞╮ 提交于 2019-12-01 09:18:23
问题 I have a very simple table that has UserID as int Password as text and Roles as text(comma separated). Can i customize ASP.NET Identity structure to use it with my table? 回答1: Yes, you can make Identity work with your structure. You'll have to implement IPasswordValidator to take whatever hashing (I hope it is hashed) is used for your password. Also you'll have to implement IUserStore to point to your table. And IUserRoleStore also have to be implemented to take roles from your CSV list. Here

ASP.Net Identity change Password Hashing method [duplicate]

三世轮回 提交于 2019-12-01 09:17:11
This question already has an answer here: How do I generate an encryption hash in ASP.NET MVC? 4 answers I'm developing an MVC 5 web application with an existing database. I'm also using ASP.Net Identity for my Authorisation and Authentication but in database passwords are not Hashed using Identitys default password hasher, i need to change it with my own hasher. any idea? Irakli Gabisonia After creating UserManager instance, you need to assign the passwordhasher property to your CustomPasswordHasher. UserManager<ApplicationUser> UserManager = new UserManager<ApplicationUser>(store);

Adding Many to Many relationship from ApplicationUser to custom entity

风格不统一 提交于 2019-12-01 09:09:45
问题 I'm trying to setup a many to many relationship in EF 6.1 from the User entity (ApplicationUser) in ASP.NET Identity to a custom entity (Group). I'm using Code First and Migrations with the stock standard MVC sample app with ASP.Net Identity. Running Update-Database seems to work nicely as I end up with all the AspNet* tables plus my entity and a linking table: Groups GroupAspNetUsers My ApplicationUser declaration has a collection of Group, and likewise my Group has a collection of

Using ASP.Net Identity 2 cookie in forms authentication

南楼画角 提交于 2019-12-01 08:44:07
I have an Owin Identity application and another application set up in a virtual directory. The virtual app is set up using traditional forms authentication, and both Web.configs have the same <machineKey> set. I can login using the Identity app, and can see the resulting cookie. However, when I try to access the virtual app it says I am not authenticated. In the Identity app, I have the following setup: app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/login.aspx"), Provider = new

ASP.NET MVC 5 Identity userManager.IsInRole

瘦欲@ 提交于 2019-12-01 08:41:51
The following code does not work, and I can't explain why... My user manager is causing significant distress in that it creates users and roles just fine but when I run this code userManager.IsInRole is always returning false, so the second time I run my seed I am hitting errors because it is trying to create the record despite the fact it already exists! Please note that this is occurring when I am running update-database against my migrations project, is the fact this is a non ASP project causing issues, if so why? shouldn't an error be thrown. This is the first project I have used Identity