asp.net-identity-2

Seed database for Identity 2

僤鯓⒐⒋嵵緔 提交于 2019-11-28 06:00:23
I came across a problem for seeding the database with Identity v2. I separated out the IdentityModel from the MVC5 project to my Data Access Layer where I setup EF Migrations as well. So I commented out the code which use inside "IdentityConfig.cs" to create initial user and put the code inside my seed database that looks like this protected override void Seed(Repository.DataContext.IdentityDb context) { // var userManager = HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>(); // var roleManager = HttpContext.Current.GetOwinContext().Get<ApplicationRoleManager>(); var

Transforming / Modifying claims in asp.net identity 2

泪湿孤枕 提交于 2019-11-28 05:13:37
问题 In Windows Identity Framework (WIF) you could implement a ClaimsAuthenticationManager in order to modify the claims on the principal or add new claims to it. The claims authentication manager provides an extensibility point in the application’s claims processing pipeline that you can use to validate, filter, modify, incoming claims or inject new claims into the set of claims presented by a ClaimsPrincipal before the RP application code is executed. Does ASP.net Identity 2 have any sort of

.Net Core 2.0 Web API using JWT - Adding Identity breaks the JWT authentication

旧巷老猫 提交于 2019-11-28 04:45:17
(Edit - Found proper fix! see below) OK - this is my first attempt at .Net Core 2.0 and authentication, though I've done things with Web API 2.0 in the past, and have worked fairly extensively on various MVC and Webforms ASP projects over the last couple of years. I'm trying to create a Web API ONLY project using .Net Core. This will form the back end of a multi-tenant application for producing some reports, so I need to be able to authenticate users. It seems the usual approach is to use JWT - first authenticate the user to generate a token, then pass that to the client to use on every API

Identity 2.0 Reset password by Admin

孤街浪徒 提交于 2019-11-28 03:47:19
问题 How can I reset password as a admin for other users? I have tried using the code below var code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); var result = await UserManager.ResetPasswordAsync(user.Id, code, vm.NewPassword); when stepping through GeneratePasswordResetTokenAsync, the dispose method of the controller is called. Can someone please enlighten me? 回答1: You can also extend UserManager and expose an explicit AdminChangePassword API that doesn't require any information.

No IUserTokenProvider is registered

冷暖自知 提交于 2019-11-28 03:31:24
I recently updated Asp.Net Identity Core of my application form 1.0 to 2.0. There are new features which I wanted to try like GenerateEmailConfirmationToken , etc. I'm using this project as a reference. When the user tries to register, I get error during the execution of Post method of Register private readonly UserManager<ApplicationUser> _userManager; public ActionResult Register(RegisterViewModel model) { if (ModelState.IsValid) { var ifUserEXists = _userManager.FindByName(model.EmailId); if (ifUserEXists == null) return View(model); var confirmationToken = _userRepository

Custom email confirmation token

爷,独闯天下 提交于 2019-11-28 03:24:48
问题 I'm using the Identity 2.0 framework for user management. Unfortunately, in my use case an account activation/password reset cannot be done using a direct link, so the user would have to copy the code from his e-mail and paste it into the website. The code that is generated by the UserManager 's default GenerateEmailConfirmationTokenAsync method is very long, it spans about 3 lines of text. I tried to override this method, generating a shorter code that is more user friendly. This doesn't

Asp.net identity entity framework database first approach with own table defintion

吃可爱长大的小学妹 提交于 2019-11-28 01:46:31
I have below four tables Role table User table UserRole table UserType table default Asp.net identity having below tables like Asp.netusers,Asp.netRoles,Asp.netuserlogins,Asp.netuserclaims,Asp.netuserroles My table doesn't match the same column name and some columns not available in my tables. can i use my own tables to utilize the feature of asp.net identity or else i need to follow the same columns used in Asp.netusers table to my User table. Is that all columns necessary to add in my table ? Already I have implemented asp.net identity EF database first approach with same default tables. I

Implementing UserManager to use a custom class and Stored Procedures

喜你入骨 提交于 2019-11-27 22:31:58
All of the authentication and authorization process of my app is done using stored procedures. I've written a class with all of functionalities that I need, e.g. GetUsers , Login , AddRole , AddMember , etc. Also the admin page for managing users and roles and permissions is done by using this class. I just need to add authentication (I mean that authorize attribute), cookies for Login and Logout and storing some server-side data for each Login. I think I need to implement Identity for that? In that case, can you please guide me with its implementation? It seems the very basic thing you need

User (IPrincipal) not available on ApiController's constructor using Web Api 2.1 and Owin

五迷三道 提交于 2019-11-27 21:21:45
问题 I am Using Web Api 2.1 with Asp.Net Identity 2. I am trying to get the authenticated User on my ApiController's constructor (I am using AutoFac to inject my dependencies), but the User shows as not authenticated when the constructor is called. I am trying to get the User so I can generate Audit information for any DB write-operations. A few things I'm doing that can help on the diagnosis: I am using only app.UseOAuthBearerTokens as authentication with Asp.Net Identity 2. This means that I

Moving ApplicationUser and other models out of MVC project

蹲街弑〆低调 提交于 2019-11-27 19:55:47
How can I split the properties, functionality and classes out of the default ASP.Net Mvc / Identity 2.0? I am battling with a few things: by default, it wants to use OWIN's context to wire up some kind of dependency injection, and control the Managers it puts the ApplicationDbContext at the application level, where my architecture requires it be available at "lower" levels. It requires that I declare any properties in the same class as the functionality that acts on those properties (which doesn't fit in with my architecture) The ApplcationUser model has dependencies on Asp.Net, which I would