asp.net-identity

Why is Asp.Net Identity IdentityDbContext a Black-Box?

夙愿已清 提交于 2019-12-17 07:17:24
问题 There is a lot of confusion it seems around IdentityDbContext. If we create two Database Contexts in our application, one for Identity and one for our custom business data, the Identity Database Context inherits from IdentityDbContext while our custom business data inherits from DbContext. So let's add the following to a controller: private MyDbContext db = new MyDbContext(); private ApplicationDbContext identityDb = new ApplicationDbContext(); And the following to an Index method in the

ExpireTimeSpan ignored after regenerateIdentity / validateInterval duration in MVC Identity (2.0.1)

你离开我真会死。 提交于 2019-12-17 07:07:31
问题 Been scratching my head all day on this one. I'm trying to set up "very long" login sessions in MVC Identity 2.0.1. (30 days). I use the following cookie startup: app.UseCookieAuthentication(new CookieAuthenticationOptions { SlidingExpiration = true, ExpireTimeSpan = System.TimeSpan.FromDays(30), AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/My/Login"), CookieName = "MyLoginCookie", Provider = new CookieAuthenticationProvider {

ASP.NET Identity Cookie across subdomains

荒凉一梦 提交于 2019-12-17 07:07:17
问题 For forms authentication I used this in web.config (note the domain attribute): <authentication mode="Forms"> <forms loginUrl="~/Account/Login" timeout="2880" name=".ASPXAUTH" protection="Validation" path="/" domain=".myserver.dev" /> </authentication> How is a single sign-on across subdomains configured for the new ASP.NET Identity Framework in Mvc 5? More Info: I am creating a multitenant application. Each client will be on a subdomain: client1.myapp.com client2.myapp.com I want a user to

ASP.NET Identity - Multiple object sets per type are not supported

隐身守侯 提交于 2019-12-17 05:00:54
问题 I got an error using ASP.NET Identity in my app. Multiple object sets per type are not supported. The object sets 'Identity Users' and 'Users' can both contain instances of type 'Recommendation Platform.Models.ApplicationUser'. I saw a few questions about this error in StackOverflow. All indicate on two DbSet objects of the same type. But in my DbContext there aren't the same types of DbSets . Exception is thrown on FindAsync() method during logging in. if (ModelState.IsValid) var user =

How to use JWT in MVC application for authentication and authorization?

随声附和 提交于 2019-12-17 04:44:15
问题 I planned to use ASP.NET Identity 2.0 in an ASP.NET MVC application for authentication and authorization. Referring the below link JSON Web Token in ASP.NET Web API 2 using Owin I was able to create a access token(JWT) for the valid user i.e., When user Logs in to the application I will validate the user with name and password then I will issue a JSON web token for that valid user. Now, I read in some articles that we need to pass the bearer token in headers for every request to validate the

ASP.NET Web API 2: How do I log in with external authentication services?

旧城冷巷雨未停 提交于 2019-12-17 04:10:21
问题 According to this post http://www.asp.net/web-api/overview/security/external-authentication-services... I'm able to log in with a local authentication service (with the new ASP.NET identity framework) but I can't find a walkthrough to properly call (from a mobile app or Postman) the default web API generated in the Visual Studio 2013 SPA template. Can anyone help me? 回答1: I had the same problem today and found the following solution: At first get all available providers GET /api/Account

Asp.net Identity password hashing

烈酒焚心 提交于 2019-12-17 03:57:32
问题 The new ASP.net Identity project has brought some useful code and interfaces for website security. To implement a custom system using the interfaces (instead of using the standard Entity Framework implementation included in the MVC 5 template) an IPasswordHasher is required. IPasswordHasher interface in ASP.net Identity namespace Microsoft.AspNet.Identity { public interface IPasswordHasher { string HashPassword(string password); PasswordVerificationResult VerifyHashedPassword(string

Unauthorised webapi call returning login page rather than 401

人盡茶涼 提交于 2019-12-17 02:06:24
问题 How do I configure my mvc/webapi project so that a webapi method called from a razor view doesn't return the loginpage when its unauthorised? Its a MVC5 application which also has WebApi controllers for calls via javascript. The two methods below [Route("api/home/LatestProblems")] [HttpGet()] public List<vmLatestProblems> LatestProblems() { // Something here } [Route("api/home/myLatestProblems")] [HttpGet()] [Authorize(Roles = "Member")] public List<vmLatestProblems> mylatestproblems() { //

Configure the authorization server endpoint

别说谁变了你拦得住时间么 提交于 2019-12-17 01:39:46
问题 Question How do we use a bearer token with ASP.NET 5 using a username and password flow? For our scenario, we want to let a user register and login using AJAX calls without needing to use an external login. To do this, we need to have an authorization server endpoint. In the previous versions of ASP.NET we would do the following and then login at the ourdomain.com/Token URL. // Configure the application for OAuth based flow PublicClientId = "self"; OAuthOptions = new

How can I change the table names when using ASP.NET Identity?

孤者浪人 提交于 2019-12-16 20:16:42
问题 I am using the release version (RTM, not RC) of Visual Studio 2013 (downloaded from MSDN 2013-10-18) and therefore the latest (RTM) version of AspNet.Identity. When I create a new web project, I select "Individual User Accounts" for authentication. This creates the following tables: AspNetRoles AspNetUserClaims AspNetUserLogins AspNetUserRoles AspNetUsers When I register a new user (using the default template), these tables (listed above) are created and the AspNetUsers table has a record