asp.net-identity

ASP.NET Identity, persistent cookie - is something like this build in?

偶尔善良 提交于 2019-12-24 06:14:30
问题 We are using CookieAuthenticationProvider and would like to implement the 'Remember me' functionality in our application that would work like this: No matter if the 'Remember me' checkbox is checked or not, the token expiration time should always be set to 30 minutes (with SlidingExpiration turned on) If user doesn't check 'Remember me' all we do is check if token expired - if it did, then user is redirected to login screen (this is build in into OWIN and works fine) However if user checks

ASP.NET Identity - Anonymous profiles

安稳与你 提交于 2019-12-24 04:25:19
问题 I want to use anonymous profiles to store and use profile data without authenticated. How to enable anonymous profiles is described on page https://msdn.microsoft.com/en-us/library/ewfkf772(v=vs.100).aspx Profiles can also work with anonymous users. Support for anonymous profiles is not enabled by default, so you must explicitly enable it. In addition, when you define profile properties in the Web.config file, you must explicitly make them available individually for anonymous users. Profile

Integrating ASP.NET Identity to existing database

旧时模样 提交于 2019-12-24 03:53:13
问题 I'm new to all this Entity Framework stuff, so excuse me in advance. I'm trying to integrate ASP.NET Identity to my project. I've got an existing database, mapped and ready, and I'm using Code First with automatic migrations. What I'm trying to do is have Identity only to store username, password and some other fields and the rest of the information needs to be stored in another table, called Contact, so I need 1:1 connection from my Identity to my that table. What I've tried so far is

EF Core There is already an object named 'AspNetRoles' in the database

霸气de小男生 提交于 2019-12-24 03:36:08
问题 I am receiving There is already an object named AspNetRoles in the database. error while attempting to use update-database command in NuGet console. Context: public class ApplicationDbContext : IdentityDbContext<IdentityUser> { public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } public DbSet<Customer> Customers { get; set; } } Startup: public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public

How to pass some more parameters to token endpoint web api 2

吃可爱长大的小学妹 提交于 2019-12-24 03:26:46
问题 i need to pass some more parameters to token endpoint as grant_type=password&username=Alice&password=password123&peop1=value&Prop2=value to get the token How can i pass these and where i can get them on the server 回答1: OAuth2 resource owner password flow defines these parameters. If you need to do something else when authenticating a user you should look into the Implicit Flow -- that way you can code a custom login screen to accept any data you need from the user. 回答2: Solution for OWIN but

How to iterate Roles in IEnumerable<ApplicationUser> and display role names in razor view

◇◆丶佛笑我妖孽 提交于 2019-12-24 03:24:26
问题 Am using Identity 2.1.0 with MVC and razor Views. One of my views gets a list of all users with this GET Controller Action: public async Task<ActionResult> Users() { return View(await UserManager.Users.ToListAsync()); } Within the View there is a foreach that iterates through each user and displays the usual information like email address, username, etc. I would like to know if there is also a way of iterating through the roles for each user so that I can display the role membership of each

Extra column/field on IdentityUserRoles table using Identity 2 and Entity Framework 6

柔情痞子 提交于 2019-12-24 03:08:59
问题 I'm using a custom implementation of the IdentityUser class in my project. The problem is that Entity Framework adds an extra column in the table IdentityUserRoles , mapping the child class Id as a constraint. I know that EF is probably getting confused on figuring how to map the relationship with this new class, I just don't know why and how to solve it. I've been searching the web about this EF behavior, but couldn't find a solution yet. Here are some screenshots that summarize the problem:

Self-hosted Owin, static files and authentication

孤街醉人 提交于 2019-12-24 03:06:02
问题 I need to embed a small Owin host in an Azure worker Role. I need to serve some static files, but a sub-directory should be password-protected. I couldn't find any good example on self-hosted apps with authentication. I'm trying to setup the following appBuilder: Func<CookieValidateIdentityContext, Task> validate = async context => { Logger.Trace("Access"); }; var authOptions = new CookieAuthenticationOptions { AuthenticationMode = AuthenticationMode.Active, AuthenticationType =

Add column to created identity table in asp.net mvc project?

若如初见. 提交于 2019-12-24 01:59:07
问题 I use identity 2.0 in my MVC 5 project. First time when I run the project in my DB has been created all default tables for authentication and authorization: In AspNetUsers table I need to create additional column named LoyoutId of type integer. My question is how can I add column to created default tables? 回答1: You can add profile data for the user by adding more properties to your ApplicationUser class, please visit this to learn more. In your case: public class ApplicationUser :

MVC Identity 2.2.1 - Primary Key (Guid) as UniqueIdentifier instead of nVarChar(128)

馋奶兔 提交于 2019-12-24 00:42:54
问题 Current project: ASP.NET 4.5.2 MVC 5 Identity 2.2.1 One of the problems I am running into is that I am making use of GUIDs properly throughout the rest of the project, with the DB field types being UniqueIdentifier. Unfortunately, Identity does not play by the same rules, and for some inscrutable reason they created the table fields as a string -- nVarChar(128). I have found a few hits out there that show how to properly modify Identity to use UniqueIdentifier and cast the Guids to the proper