asp.net-identity-2

Overlap User Login in Two Projects with ASP.NET Identity

亡梦爱人 提交于 2019-11-27 18:49:38
问题 I have a problem I can not understand in asp.net identity apply the following steps create two empty web projects, they have names : WebApplication1 WebApplication2 install package " Microsoft ASP.NET Identity Samples 2.0.0-beta2 " On each project Create two sql database have the following names: WebDatabase1 WebDatabase2 add user has name " User1 " in WebApplication1 add user has name " User2 " in WebApplication2 run two the projects at the same time . My problem is when I Login by " User1 "

Entity Framework 6 and Asp.Net Identity UserManager: Multiple DbContext

邮差的信 提交于 2019-11-27 15:19:36
问题 This is MVC 5/ EF6. So I have the following classes: public class User : IdentityUser { public User() { Levels = new List<Level>(); } [Required, MaxLength(200)] public string FirstName { get; set; } [Required, MaxLength(200)] public string LastName { get; set; } public virtual ICollection<Level> Levels { get; set; } } and public class Level { public int Id { get; set; } [Required] public string Name { get; set; } public virtual ICollection<User> Users { get; set; } } In addition to regular

Usage of User.IsInRole() in a View

这一生的挚爱 提交于 2019-11-27 14:08:34
In my mvc5 project to disable an action link for unauthorized users i did like this @if (User.IsInRole("Admin") | User.IsInRole("Manager")) { @Html.ActionLink("Add New Record", "ProductTypeIndex", "ProductType") } But if there are many roles to check then this @if() gets long. How to avoid this? Do i need custom helpers for this(if so how can i approach it)? Help appreciated.. You could write your own extension method and use it in your code. public static class PrincipalExtensions { public static bool IsInAllRoles(this IPrincipal principal, params string[] roles) { return roles.All(r =>

Invalidate Old Session Cookie - ASP.Net Identity

余生长醉 提交于 2019-11-27 11:39:07
问题 An external company has done some penetration tests on the ASP.NET MVC 5 application i'm working on. An issue that they raised is described below A cookie linked with session Management is called AspNet.ApplicationCookie. When entered manually,the application authenticates the user. Even though the user logs out from the Application,the cookie is still valid. This means,the old session cookie can be used for a valid authentication within unlimited timeframe. In the moment the old value is

How To Change Password Validation in ASP.Net MVC Identity 2?

天大地大妈咪最大 提交于 2019-11-27 10:15:04
问题 How To Change Password Validation in ASP.Net MVC5 Identity 2 ? Thanks 回答1: In the MVC project template in VS2013 Update 2, there should be a file called App_Start/IdentityConfig.cs . In it you should find the class ApplicationUserManager and a static factory method called Create() . That's where the user manager class is configured, including the server-side validation rules for passwords are defined. For example: manager.PasswordValidator = new PasswordValidator { RequiredLength = 6,

aspnet identity invalid token on confirmation email

我的梦境 提交于 2019-11-27 08:40:42
I'm trying to confirm an account but I'm getting "invalid token." error. Here's what I'm trying: var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmacaoEmail", "Usuario", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); await UserManager.SendEmailAsync(user.Id, "Ativação de Conta", user.GetEmailAtivacao(model.Nome, callbackUrl)); if I call UserManager.ConfirmEmailAsync after this code, I can confirm the account. However, if I open the link that it's inside the variable callbackUrl and try to confirm through that

ASP.NET MVC 5 : Endless redirect to the login page using the site template

柔情痞子 提交于 2019-11-27 07:45:53
问题 I just started using ASP.NET MVC 5 (I already used the previous versions quite a lot) and I have a very weird issue: I created a new website using the Visual Studio 2013 (fully updated) ASP.NET template. For the template options I selected the MVC template, "Individual User Accounts" authentication type, no cloud hosting, and no other components than the core MVC library. After I validate the options, I update all the NuGet packages. And after that I press F5 (without opening or modifying any

ASP.NET Identity in Microservice Architecture

空扰寡人 提交于 2019-11-27 07:42:10
I'm attempting to implement a web app using a microservice architecture by breaking up major components into separate web servers. I'm implementing an authentication server using ASP.NET Identity (email/username logins only, no Facebook, etc) and a "main" application server. My current challenge is figuring out how the application server will recognize if a user has logged via the authentication server. Since the authentication server generates tokens which it users to verify users's identities, I imagine that they are stored somewhere and can be queried by the application server, but I'm not

Getting the email from external providers Google and Facebook during account association step in a default MVC5 app

醉酒当歌 提交于 2019-11-27 06:25:36
Apparently you can do this with the Facebook provider by adding scopes to the FacebookAuthenticationOptions object in Startup.Auth.cs : http://blogs.msdn.com/b/webdev/archive/2013/10/16/get-more-information-from-social-providers-used-in-the-vs-2013-project-templates.aspx List<string> scope = new List<string>() { "email" }; var x = new FacebookAuthenticationOptions(); x.Scope.Add("email"); ... app.UseFacebookAuthentication(x); How to do the same with Google provider? There isn't a x.Scope property for the GoogleAuthenticationOptions class/object! PLEASE SEE UPDATES AT THE BOTTOM OF THIS POST!

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

左心房为你撑大大i 提交于 2019-11-27 05:26:14
问题 (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