asp.net-identity-3

ASP.NET Core Identity 3 Cookie timeout

不想你离开。 提交于 2019-12-05 12:33:47
I have a weird issue happening with RC2. I have setup Identity 3 ExpireTimeSpan to 12 hours using the following configuration option options.Cookies.ApplicationCookie.ExpireTimeSpan = new TimeSpan(12,0,0); After logging in to the website and leaving it untouched for ~35-40mins, I get a 401 error (for my ajax post calls) and refreshing the website, I get back to the login page. Why do I have to reauthenticate when I have setup the ExpireTimeSpan to 12hours? Is there another setting or configuration that I need? Also, How can I get the time left before the expiry occurs? I would like to access

Checking login user AuthorizePolicy in Razor page on Asp.Net Core

非 Y 不嫁゛ 提交于 2019-12-04 23:38:09
I'm looking for a variant of this @if (SignInManager.IsSignedIn(User) && User.IsInRole(Roles.Administrator)) { <div id="editArticle"> but instead of checking after the role I'm after a check into the policy much like you would in a controller by doing this. [Authorize(Policy = Policies.RequireAdmin)] James P This seems similar to question asked here I found this link which may be helpful: https://docs.asp.net/en/latest/security/authorization/views.html Examples from that page: @if (await AuthorizationService.AuthorizeAsync(User, "PolicyName")) { <p>This paragraph is displayed because you

Store custom datas in Identity Cookie

眉间皱痕 提交于 2019-12-04 14:00:02
问题 Is there a way to store some custom datas from the user inside the cookie generated by the Identity API ? We are building an multi-tenant application, and so multiple companies can access to the same instance of our application. That's why I need, for a specific user, to store company code from the user in the identity cookie to retrieve the datas from the user when he returned on the web application after closing the browser. 回答1: you could achieve that by implementing a custom

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

流过昼夜 提交于 2019-12-04 02:50:54
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 want to check how is it done, you can simply see it on github link I pasted. Following our discussion

Store custom datas in Identity Cookie

淺唱寂寞╮ 提交于 2019-12-03 08:51:17
Is there a way to store some custom datas from the user inside the cookie generated by the Identity API ? We are building an multi-tenant application, and so multiple companies can access to the same instance of our application. That's why I need, for a specific user, to store company code from the user in the identity cookie to retrieve the datas from the user when he returned on the web application after closing the browser. Joe Audette you could achieve that by implementing a custom UserClaimsPrincipalFactory and adding a custom claim for your store number, then it would be stored in the

ASP .NET 5 MVC 6 Identity 3 Roles Claims Groups [closed]

我只是一个虾纸丫 提交于 2019-12-03 02:51:42
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I'm currently looking for a solution to use an advanced Roles/Group Permission management in ASP .NET 5 MVC 6 with Identity 3. I started a new Preview Starter Web Project with a integrated easy login system. Now I need a complex "users permission management" with following

How to register custom UserStore & UserManager in DI

佐手、 提交于 2019-12-02 23:20:29
Here is my setup: public class ApplicationUser : IdentityUser<Guid> { } public class ApplicationRole : IdentityRole<Guid> { } public class ApplicationUserLogin : IdentityUserLogin<Guid> { } public class ApplicationUserClaim : IdentityUserClaim<Guid> { } public class ApplicationRoleClaim : IdentityRoleClaim<Guid> { } Here is the definition of my UserStore public class ApplicationUserStore : UserStore<ApplicationUser, ApplicationRole, MyContext, Guid> { public ApplicationUserStore(MyContext context, IdentityErrorDescriber describer = null) : base(context, describer) { } } Here is the definition

ASP .NET 5 MVC 6 Identity 3 Roles Claims Groups [closed]

百般思念 提交于 2019-12-02 16:22:15
I'm currently looking for a solution to use an advanced Roles/Group Permission management in ASP .NET 5 MVC 6 with Identity 3. I started a new Preview Starter Web Project with a integrated easy login system. Now I need a complex "users permission management" with following functions: users can be in multiple groups/roles a group/role have many access objects (e.g. CanAccessUser, CanEditUser...) these access objects (maybe claims?) of each group/roles complement each other (optional for the ultimate solution): additionally => access objects(maybe claims) can be assigned independently by a group

Cannot use table 'AspNetUsers' in schema '' for entity 'AspNetUsers' since it is being used for another entity

女生的网名这么多〃 提交于 2019-12-02 08:00:29
问题 We are trying to add Identity 3 to our existing Customers app by extending AspNetUsers public class ApplicationUser : IdentityUser { public string BusinessName { get; set; } public string ContactName { get; set; } public string CountryCode { get; set; } public virtual Countries Country { get; set; } public string AddressLabel { get; set; } public string Phone { get; set; } public DateTime? FollowUp { get; set; } public bool MailingList { get; set; } public int SubscriptionId { get; set; }

ASP.NET 5 Identity 3 users get signed out after some time

北慕城南 提交于 2019-12-02 03:46:13
问题 I'm, using RC1 bits and external (Google) authentication, no Identity.EntityFramework. During login, I set 'Remember me' flag. Logged-in user survives browser restart (I see cookie set to expire in 14 days) and website restart. But after some time of inactivity (about 15 min), no matter browser/site were restarted or not, refreshing page lead to signing out, logs says: info: Microsoft.AspNet.Authentication.Cookies.CookieAuthenticationMiddleware: AuthenticationScheme: Microsoft.AspNet.Identity