asp.net-identity

Mvc login with Web API [closed]

假如想象 提交于 2019-12-04 06:14:37
Closed . This question needs to be more focused. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it focuses on one problem only by editing this post . Closed 3 years ago . In my solution folder there are two projects Myproject.API Myproject.Web API will server all the request to My Mvc web or android or IOS client. Now Here I'm confused, Where should I Implement Authentication process. At API or At API and MVC both As MVC identity uses Cookie based authentication where as API used token based. Now What I want In Web Project, If any user

Identity Server 4 Claims empty on API

若如初见. 提交于 2019-12-04 05:18:24
问题 I have been trying to Integrate Identity Server 4 with SPA application. I am able to Authorize the Application in API but after the authorization the User.Claims are always empty though i have added the Claims in Scopes. I am using Asp.net Identity in API with entity framework core. My project are distributed in different projects. Project.Auth (using Identity Server 4) Project.Admin Project.Data (where my Context and Migration Lies) Project.Domain(Enities) Project.Service(Repository and

ASP.NET MVC Identity Email/Username with Special Characters

时间秒杀一切 提交于 2019-12-04 05:11:52
When registering an account through Web API with an email such as "xxx-yyy@gmail.com", Fiddler returns the follow error. Note that email is used for username as well, so both fields are the same . But it works when registering on MVC itself. ExceptionMessage=User Creation Failed - Identity Exception. Errors were: User name xx-yyy@gmail.com is invalid, can only contain letters or digits. User Object var newUser = new ApplicationUser { UserName = user.Email, Email = user.Email }; IdentifyConfig.cs public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options,

How do I serialize an IdentityUser reference in Web API 2.2?

心已入冬 提交于 2019-12-04 05:09:28
问题 The Visual Studio "Web API" project template includes endpoints for handling registration, authentication, and authorization of users. In a production application, however, users will typically be associated with other Entities as well, such as: public class Post { public Post() {}; public int Id { get; set; } public ApplicationUser User { get; set; } } In these scenarios, the ApplicationUser class (which is derived from IdentityUser ) cannot be serialized. Attempting to do so will yield an

OWIN Cookies vs FormsAuthentication

こ雲淡風輕ζ 提交于 2019-12-04 05:08:15
Are there any major advantages of using OWIN cookie-based authentication over Forms Authentication cookie-based authentication for developing MVC web applications? The reason I ask is that I would not be using any of the Entity Framework based hooks for OWIN authentication. I've built apps based on Forms Authentication for years and have been able to do things like create different authentication tokens for admins (faster timeouts), anonymous users, and registered users. Using the UserData portion of the ticket I was able to implement universal sign out, store custom properties, etc. One of

How to remove dbo.AspNetUserClaims and dbo.AspNetUserLogins tables (IdentityUserClaim and IdentityUserLogin entities)?

自作多情 提交于 2019-12-04 04:39:17
Our application doesn't need the excessive "Logins" and "Claims" functionality that identity uses. It would be nice if these tables simlpy didn't get created in the database, but I don't want to have to reimplement all identity classes... I'd assume it's something like public ApplicationDbContext : IdentityDbContext { [...] protected override void OnModelCreating(DbModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Ignore<IdentityUserClaim>(); modelBuilder.Ignore<IdentityUserLogin>(); } } You would think this works according to the function descriptions, but it doesn

How to change default error messages of MVC Core ValidationSummary?

爱⌒轻易说出口 提交于 2019-12-04 03:37:11
Using MVC Core with ASP.NET Identity I would like to change the defaults error messages of ValidationSummary that arrived from Register action. Any advice will be much appreciated. adem caglin You should override methods of IdentityErrorDescriber to change identity error messages. public class YourIdentityErrorDescriber : IdentityErrorDescriber { public override IdentityError PasswordRequiresUpper() { return new IdentityError { Code = nameof(PasswordRequiresUpper), Description = "<your error message>" }; } //... other methods } In Startup.cs set IdentityErrorDescriber public void

Add column to aspnetusers with database first

孤街浪徒 提交于 2019-12-04 03:21:43
问题 I have found many tutorials for adding columns to the Identity tables (which I have successfully moved to the application database) with database migrations however my understanding is this is not applicable in database fist projects. So...how do I add columns to the aspnetusers table in a database first project? I would like to ad a bit type column called Is RegComplete which is initially set to 0 then at some point when the user has completed some more tasks then set to 1. 回答1: OK, I've

ASP.Net Identity Identity.IsAuthenticated remains true, even after deleting user

只谈情不闲聊 提交于 2019-12-04 03:00:32
I have implemented ASP.Net Identity after following the sample code here: https://github.com/rustd/AspnetIdentitySample In my implementation I check if a user is authenticated - this is called from a FilterAttribute on my MVC Controllers; the idea is i want to confirm they are still auth'ed before serving up the page. So in my filter, the following code eventually gets called: _authenticationManager.User.Identity.IsAuthenticated; _authenticationManager is here: private IAuthenticationManager _authenticationManager { get { return _httpContext.GetOwinContext().Authentication; } } The

UserManager Error - A second operation started on this context before a previous asynchronous operation completed

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 02:34:33
I am facing this issue with my asp.net MVC5 web application, using Identity v2.0.0.0, EF 6, Castle Windsor IOC Container, Microsoft SQL Server 2005 I am trying to get the current logged in User by using UserManagerExtensions,FindById() method but it is throwing an error "System.NotSupportedException : A second operation started on this context before a previous asynchronous operation completed. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context. Any instance members are not guaranteed to be thread safe" What I understood from the