asp.net-identity-3

How to set the cookie validateInterval in ASP.NET Core?

旧街凉风 提交于 2019-12-10 14:45:33
问题 I'm trying to set the validateInterval for an ASP.NET 5 RC1 application which makes use of ASP.NET Identity 3 I am trying to implement the code in this answer. there are many code sample like this answer but it seems it isn't valid in ASP.NET 5 RC1 app.UseCookieAuthentication(new CookieAuthenticationOptions { Provider = new CookieAuthenticationProvider { OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>( validateInterval: TimeSpan

ASP.NET Identity (with IdentityServer4) get external resource oauth access token

偶尔善良 提交于 2019-12-08 23:00:19
问题 I have been through the docs of identityServer4 and I have set it up to use Microsoft Office 365 as a login provider. When the user has logged in I want to make a button where he can allow my app to subscribe to his calendar events using the webhooks api of graph.microsoft.com The code in startup.cs app.UseMicrosoftAccountAuthentication(new MicrosoftAccountOptions { AuthenticationScheme = "Microsoft", DisplayName = "Microsoft", SignInScheme = IdentityServerConstants

Changing Identity 3.0 table names in ASP.NET Core MVC6 not working

被刻印的时光 ゝ 提交于 2019-12-08 05:43:54
问题 This same question was asked and has not been answered after 12 days... I have looked at this which uses "ToTable" as an update to the question. I have looked at this which appears to be out of date. I want to change the table names of the identity 3.0 tables - ASP.NET Core. So far, using the "ToTable" option's (No. 2 above) update, I have managed to corrupt my lockfile and have as a result corrupted the project. The third option is out of date. I created a vanilla project - no changes just

How to turn on Roles in Asp.net Identity 3.0 and MVC 6?

会有一股神秘感。 提交于 2019-12-07 13:49:47
问题 I am not sure if I am missing something here. By Default User.IsInRole() does not work even if user DOES HAVE some roles. I don't have my own implementation of role stores. I am assuming that the default ones should work. Is there something special that I need to do in the Startup.cs to get the roles working? I'm using mvc 6 beta 2 default template. 回答1: The User.IsInRole() does not work if I add a role like this: await UserManager.AddToRoleAsync(user, "Admin"); But it does work if I do this:

Redirect Login to Controller Action

妖精的绣舞 提交于 2019-12-07 05:02:37
问题 Starting with the ASP.NET 5 Web App Template using Individual User Accounts I have managed to get external authentication working with Microsoft accounts. When users click Login they are redirected to ExternalLogin in AccountController like this <form asp-controller="Account" asp-action="ExternalLogin" method="post" asp-route-returnurl="@ViewData["ReturnUrl"]" class="nav navbar-right"> <button type="submit" class="btn btn-null nav navbar-nav navbar-right" name="provider" value="Microsoft"

Changing Identity 3.0 table names in ASP.NET Core MVC6 not working

寵の児 提交于 2019-12-06 14:56:19
This same question was asked and has not been answered after 12 days... I have looked at this which uses "ToTable" as an update to the question. I have looked at this which appears to be out of date. I want to change the table names of the identity 3.0 tables - ASP.NET Core. So far, using the "ToTable" option's (No. 2 above) update, I have managed to corrupt my lockfile and have as a result corrupted the project. The third option is out of date. I created a vanilla project - no changes just created via VS2015 with identity 3.0 I then tried this: protected override void OnModelCreating

How to turn on Roles in Asp.net Identity 3.0 and MVC 6?

假如想象 提交于 2019-12-05 22:54:47
I am not sure if I am missing something here. By Default User.IsInRole() does not work even if user DOES HAVE some roles. I don't have my own implementation of role stores. I am assuming that the default ones should work. Is there something special that I need to do in the Startup.cs to get the roles working? I'm using mvc 6 beta 2 default template. The User.IsInRole() does not work if I add a role like this: await UserManager.AddToRoleAsync(user, "Admin"); But it does work if I do this: await UserManager.AddClaimAsync(user, claim: new Claim(ClaimTypes.Role.ToString(), "Admin")); It looks like

How to get current UserId in Identity 3.0? User.GetUserId returns null

跟風遠走 提交于 2019-12-05 21:24:17
问题 I need to get ID of user that made some request. In previous versions of Identity I could do it like this: User.Identity.GetUserId(); But it seems it isn't available anymore. There is also something like: User.GetUserId(); But it always returns null, even if User.Identity.IsAuthenticated in true and User.Identity.Name is set correctly. What should I use to do it? EDIT: My authenticaton logic is based on [default Visual Studio 2015 template], I hadn't changed much so far in identity, so if you

Back button issue in MVC 6 after login and logout

☆樱花仙子☆ 提交于 2019-12-05 18:30:02
I am trying to restrict user to click back button after Login/Logout into the application. If the user is logged in into the application, then after clicking on back button Login view should not be displayed and if user is logged out from the application then clicking on back button LogOff view should not be displayed. I have already used caching technique which is given in number of links, but seems its not working. This CacheAfterLogout link and done exactly as it is, still problem is not solved. I am using asp.net identity framework. Could someone help on this ? To disable caching you can

Save user session in Redis with ASP.NET Core in Azure

旧街凉风 提交于 2019-12-05 15:41:03
I'm using redis cache for saving some stuff in my project. I am using Azure (WebApp), and when I do a SWAP between my preproduction environment to production, the user session is lost and he need to relogin in my web page. I'm using Identity 3.0, with UseCookieAuthentication. I would like to store the "session" in Redis for solving my problem when I do the swap. I don't found information about it, any ideas? Thanks Startup.cs Code ConfigureServices: public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddApplicationInsightsTelemetry(Configuration); /