claims-based-identity

Thread.CurrentPrincipal is authenticated but ClaimsPrincipal.Current is not

时光毁灭记忆、已成空白 提交于 2019-12-08 17:58:34
问题 I'm using Claims based Authorization in my WebApi project and have a method where I check if the current Identity is authenticated. When I use ClaimsPrincipal.Current the current Identity is not authenticated but when I use Thread.CurrentPrincipal it is. ClaimsPrincipal.Current.Identity.IsAuthenticated; //False Thread.CurrentPrincipal.Identity.IsAuthenticated; //True This seems strange especially since the MSDN says ClaimsPrincipal.Current just returns Thread.CurrentPrincipal: Remarks By

Is there any way I can mock a Claims Principal in my ASP.NET MVC web application?

非 Y 不嫁゛ 提交于 2019-12-08 16:38:16
问题 I've got some ASP.NET MVC controller code that checks if a user is authenticated and if so, it checks to see if it has a specific claim. Works fine. I've got some unit tests and I need to mock out an IPrincipal (which is easy to do) ... but I'm not sure how to check for the claims! I usually do something like public static ClaimsPrincipal ClaimsPrincipal(this Controller controller) { return controller.User as ClaimsPrincipal; } and some controller code ... this.ClaimsPrincipal().HasClaim(x =>

LiveID API fails - missing token

情到浓时终转凉″ 提交于 2019-12-08 12:16:03
问题 I'm trying to retrieve some information from the LiveID API but am getting the error: The provided request does not include an access token. An access token is required in order to request this resource. the code is relatively simple; I'm including the library, calling the initialiser with the nameidentifier claim I get from WIF and then requesting the me path. from the error message I surmise I failed to provide an access token... but wouldn't my app have this already since I successfully

Web API 2 + MVC 5 Share Identity Table

 ̄綄美尐妖づ 提交于 2019-12-08 09:12:02
问题 I have a web API and MVC5 sharing the same Identity Table. The Context belonging to the Web API: public partial class CrestfineContext: IdentityDbContext<ApplicationUser> { public CrestfineContext(): base("WelbeckDatabase", throwIfV1Schema: false) { } protected override void OnModelCreating(DbModelBuilder builder) { builder.Conventions.Remove<PluralizingTableNameConvention>(); builder.Entity<IdentityUserClaim>().ToTable("UserClaim").HasKey<Int32>(r => r.Id); builder.Entity<IdentityUserLogin>(

WSO2 Identity Server + Rest STS Client (without ESB)

北战南征 提交于 2019-12-08 06:37:28
问题 Is below possible using WSO2 IS? I have gone through different WSO2 blogs. They are nice pointer. Still I need to advised on this. Requirement- WSO2 Identity Server + Rest STS Client (without ESB) Users are managed on WSO2 Identity Server. STS Client use RestFul API to call WSO2 Identity Server's STS service for a) Get Security Token b)Validate Token c)cancel Issued Token d) renew Issued Token Retrieve user profile using a specific Security token. Reference: https://web.cci.emory.edu

WSO2 Identity Server not returning requested claims with OAuth/OpenID

こ雲淡風輕ζ 提交于 2019-12-08 06:33:37
问题 I'm trying out OAuth/OpenID with WSO2 Identity Server 5.1.0, but I'm having problems with returning the claims I need. I'm not sure if I'm misunderstanding how this should work... I'm using the default resident identity provider. The service provider has the claims configured like this: This only other configuration for this SP is inbound authentication with OAuth2. When I get an OAuth token for this service using the openid scope, the JWT received only has the subject field (email address in

How to avoid 'SamlAssertion.NotOnOrAfter condition is not satisfied' errors

与世无争的帅哥 提交于 2019-12-07 22:44:45
问题 Recently I have started using claim-based authentication on an existing web application. Because the application makes use of jQuery & more notably, the AJAX functions, I have had to alter the handlers not to attempt to redirect the XmlHTTPRequests , and instead return a 403 status which is easier to handle. Here is the FederatedAuthentication.WSFederationAuthenticationModule.AuthorizationFailed event hanlder: protected void WSFederationAuthenticationModule_AuthorizationFailed(object sender,

Looking for a secure and robust STS implementation

和自甴很熟 提交于 2019-12-07 12:14:37
问题 I am faced with a project that uses custom authentication via a WCF service that returns a set of claims based on some data identifying a user, close to user name and password. Then on top of this, I have a custom STS, derived from Microsoft.IdentityModel.SecurityTokenService , that resides in an ASP.NET web site project. This project looks like it was created with the VS2010 template, and not carefully had-crafted. My gut feeling, and lots of on-line advice tell me that this web site STS

Asp.Net Identity - case insensitive email and usernames

落爺英雄遲暮 提交于 2019-12-07 08:20:40
问题 Is there a way to get Asp.Net Identity to be case insensitive with email addresses and usernames? At the moment if I call "FindByEmailAsync(email)" it will only work if the email address is being stored exactly as it's is typed (case sensitive) 回答1: You can change how the user is registered so that the username is set to lowercase and when logging in as well. For registering the user, in the AccountController [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task

ASP.Net MVC: How to read my custom claims value

假装没事ソ 提交于 2019-12-07 07:30:54
问题 See the below code. I got to know that this way we can add our custom data to claims but now question is how to read back those value. Say I want to read back value for claims Email and Email2 please tell me what code I need to write to read back value for claims Email and Email2 . UserManager<applicationuser> userManager = new UserManager<applicationuser>(new UserStore<applicationuser>(new SecurityContext())); ClaimsIdentity identity = userManager.CreateIdentity(user,