asp.net-identity

MVC 5 IsInRole Usage on Razor Views: Cannot connect to Database

人盡茶涼 提交于 2021-02-06 10:12:37
问题 I'm having issues using the new identity system in MVC 5, my goal is to make use of the User.IsinRole("RoleName") on Views. For example: @if(User.IsInRole("Administrator")) { <li>@Html.ActionLink("Admin", "Index", "Admin")</li> } This is placed in the main layout page which is hit when the application launches. On doing this, i'm getting the following error: "An exception of type 'System.Web.HttpException' occurred in System.Web.dll but was not handled in user code Additional information:

How to call Identity Server 4 with Postman for login

北城余情 提交于 2021-02-05 20:26:40
问题 I've a solution in Visual Studio 'TourManagement' which contains 2 projects of .Net core. One is IDP using Identity Server 4, second project is RESTful API of TourManagement secured by IDP project. My question is how can i call Identity Server 4 using Postman to get tokens and call TourManagement Bands API by passing these tokens in header return from identity server in postman? My code is below. Startup Class in IDP Project using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore

password History for Identity Core

ぐ巨炮叔叔 提交于 2021-02-04 16:28:05
问题 is there any default implementation for password history? i'm trying to implement that feature on my project with identity so i have added password history table which contain password hashes. when user change password usermanager generate hash for password. var passwordHash = _userManager.PasswordHasher.HashPassword(user, newPassword); if this hash does not inserted in password history table it allow to change password otherwise return error but the problem is each time when generating hash

How to change redirect_uri for Azure AD

偶尔善良 提交于 2021-01-29 10:43:11
问题 I've got Azure ServiceFabric web-app (AspNetCore 3) hosted over reverse proxy (NGinx). The app use AzureAD (in company) authentication. I've Registered App for the AD and setup Redirect Urls. After publishing the APP and configuring DNS and reverse proxy I tried to authorize to my app but failed with error AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application: '...-...-...-...-...'. I snifed the request and found that it redirects to

ASP.NET Core Identity - UserClaims, UserRoles and RoleClaims

半世苍凉 提交于 2021-01-29 08:38:53
问题 I'm setting up an application using ASP.NET Core Identity, and despite reading thoroughly on the topic, I'm struggling to find the right fit for my requirements. Users familiar with the subreddit concept of Reddit might understand my requirement well, as the concepts are very similar. Essentially, I have a requirement where a user can be a moderator of one "area" (similar to a subreddit) and just be a "user" in another "area". What it boils down to is that when a user logs in, I need to know

asp.net core - pass several parameters to custom authorization policy provider

喜夏-厌秋 提交于 2021-01-29 08:24:28
问题 I'm attempting to setup a custom policy provider in asp.net core. I need to pass in several custom authorization attributes to the provider but struggling with how to do so. I have it setup to accept one enum array currently and is working fine. However, I would like to add 2 more enum arrays as additional, optional parameters to the authorization attribute. Attribute as it is now: [LEMClaimAuthorize(new ELocation[] { ELocation.Indy, ELocation.Columbus })] Would like for it to work like so:

No owin.Environment with Put requests

半世苍凉 提交于 2021-01-29 06:26:50
问题 In my current project I'm using AspNet.Mvc 5.2.7 and Owin 4.1.0 My issue is that whenever I try to access to the Owin Context from a put request (i.e.: HttpContextBase.GetOwinContext() ) I get the error message: No owin.Environment item was found in the context. All's good with [HttpPost] and [HttpGet] but not with Put so looks like Identity has been introduced properly. As soon as I changed the very same request to post it started working as well. Went through a lot of SO posts but didn't

Integrate third party login in from my registration page with IdentityServer4 and Angular 6 - 'No matching state found in storage'

拟墨画扇 提交于 2021-01-29 05:15:42
问题 I'm trying to implement a third-party auth in my sign up page, but I can't get it to work with IdentityServer4. I have it working in my login page since the oidc client is initiating the login request. However the oidc client is not aware of a request to my registration page, so when I send an auth token back, it doesn't recognize the state and throws an exception: 'No matching state found in storage'. I know IdentityServer4 does not officially support user registration. I've got registration

How can I reference an user object in an Entity Framework model?

可紊 提交于 2021-01-29 04:31:06
问题 I have the following model: public class MyEntity { public Guid Id { get; set; } public virtual ICollection<ApplicationUser> AssociatedUsers { get; set; } public MyEntity() { AssociatedUsers = new HashSet<ApplicationUser>(); } } Notice that each entity has some associated users. In my controller, I'm trying to add an instance of MyEntity to the database like this: private ApplicationDbContext db = new ApplicationDbContext(); // ... ApplicationUser currentUser = System.Web.HttpContext.Current

There is no implicit reference conversion from ApplicationUser to IdentityUser

那年仲夏 提交于 2021-01-29 04:19:18
问题 I am trying to customize some ASP.NET Identity Core classes which use Generics. My ApplicationUser class: public class ApplicationUser : IdentityUser<Guid>//, ApplicationUserClaim, ApplicationRole, ApplicationUserLogin> { public ApplicationUser() { } } My ApplicationUserStore class: public class ApplicationUserStore : UserStore<ApplicationUser, ApplicationRole, ApplicationDbContext, Guid> { public ApplicationUserStore(ApplicationDbContext ctx, IdentityErrorDescriber describer = null) : base