asp.net-identity-2

ASP.NET Identity 2.0: How to rehash password

半城伤御伤魂 提交于 2019-12-04 05:09:39
I am migrating users from a legacy user store to ASP.NET Identity 2.0 in my ASP.NET 5.0 web application. I have a means of verifying legacy hashes, but I want to upgrade them at login-time to ASP.NET Identity 2.0 hashes. I've created a custom IPasswordHasher that is able to detect and verify legacy hashes, and return PasswordVerificationResult.SuccessRehashNeeded at the appropriate time. (If it detects that the hash is not legacy, it simply falls through to the built-in ASP.NET Identity hash verification.) However, returning PasswordVerificationResult.SuccessRehashNeeded doesn't seem to cause

MVC 5 ASP.NET Identity 2: Capture user's preference for “remember me” in ExternalLogin

夙愿已清 提交于 2019-12-04 04:43:57
问题 I am using the Identity 2.0 Sample. I get that by setting isPersistent to true in ExternalLoginCallback action method, the browser will automatically log the user in the next time (within limits) they visit using the same browser. I know that if the user's "remember me" preference was captured and passed to the ExternalLogin action method that it could be put into returnUrl and accessed in ExternalLoginCallback. But how do I get their preference to the ExternalLogin action method? I don't get

Can send emails through Gmail account only if account has “Access for less secure apps” enabled

删除回忆录丶 提交于 2019-12-04 02:38:19
If my Gmail account has Access for less secure apps disabled , then my application can't send emails through this account . Instead I get " The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required " exception. Here Google explains that by disabling Access for less secure apps , only apps that use modern security standards can sign in . What are those modern security standards my code needs to implement and can you show me how to implement them with an example ( not sure if it matters, but my app and Gmail account

How to get ApplicationDbContext out of the Owin pipeline

扶醉桌前 提交于 2019-12-04 01:05:53
This has to be simple, but I'm going bug-eyed trying to find the answer. How does a controller action get a reference to the per-request ApplicationDbContext that was stashed in the Owin pipeline? EDIT: Ok, I think I'm getting closer... or maybe not... All of my Googling seems to lead to this blog post , which sez to use: var dbContext = context.Get<ApplicationDbContext>(); where context is apparently an instance of Microsoft.Owin.IOwinContext . So I tried: var db = HttpContext.GetOwinContext().Get<ApplicationDbContext>(); But the Get<T> method requires a string key parameter. :( And the

MVC 5, Identity 2.0 Android Rest/Json Api

人盡茶涼 提交于 2019-12-03 19:29:45
I have an ASP.NET MVC 5 Application which uses Identity 2.0 for authentication/authorisation. Now I want to provide access to the data in my web application to my Android Application via Web Api 2.0. My question is: How to control authorize/authenticate the access of my android application? On Android side I use "org.springframework.web.client.RestTemplate" and add this HTTP header to my request: HttpAuthentication authHeader = new HttpBasicAuthentication("username", "password"); HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.setAuthorization(authHeader); HttpEntity<?>

Should I separate my application context from ApplicationDbContext used for identity?

瘦欲@ 提交于 2019-12-03 15:43:58
问题 In Visual-Studio 2013, when creating an ASP.NET project, it generates a file IdentityModels.cs that contains a class ApplicationDbContext , that inherits from IdentityDbContext<ApplicationUser> , which eventually inherits from DbContext . Should I keep this context only for account-related entities, and created a separate context for all the other entities in the application or should I mix it. Any security issue or reason not to include all the entities of my entire application in one

Dynamically assign controller action permissions to roles in asp.net MVC

巧了我就是萌 提交于 2019-12-03 13:48:44
问题 I am working on asp.net mvc 5. I want to assign permissions of controllers' action methods to roles dynamically without hard conding the roles in Authorize attribute. Here is the scenario - In my project, I have four roles - Student, Teacher, Program Officer and Admin. I want that admin can change the accessability of each role whenever he wishes. I do not want to hard code the authorize attribute with role names before every action name of controller because admin will not then be able to

Example of using asp.net 5 MVC 6 with Identity and EF 6

守給你的承諾、 提交于 2019-12-03 13:38:41
问题 I'm setting up a new project using asp.net 5 and MVC 6, but I want to use Entity Framework 6 due to the missing features in EF 7. I setup EF 6.1.3 and that is working. Identity 3.0 depends on EF 7 so I have removed that and referenced in Identity 2.2 but I'm not sure where to go from here. 回答1: I'm not sure how this will be handled in the final release of ASP.NET 5, but in the case of ASP.NET 5 RC1 we have the following: Firstly, you should go with Identity 3.0, as there is no way to use

How to disable a User in Identity 2.0?

不想你离开。 提交于 2019-12-03 13:17:09
问题 I'm trying to find a way to disable a user in Identity 2.0 and can't seem to find any info on it. I would like to basically set a user to IsActive=false and would prefer to do it as soon as the user is created. However, I need a way to set the IsActive for our site Admin. I already have this with ASP.Net membership but I'm looking to covert the site to MVC and Identity. For my requirements we ask people to go ahead and register an account but we want it to be disabled by default. Then when we

One to many relationship between AspNetUsers (Identity) and a custom table

瘦欲@ 提交于 2019-12-03 12:57:33
问题 I'm desperate trying to create an One to Many relationship between AspNetUsers table of Identity 2.0 and a custom table called Map (One user can have many maps, but a map can only have one user) I've tryied mostly every solutions available in this website and also lost many days trying other soulutions found in the web. I'm stuck. Nothing seems to work for me. I'm new to MVC and EF so basically I think I need some sort of step-by-step guide. Can anyone please be very kind to provide me a