claims-based-identity

Invalidate ClaimsPrincipal after it has been modified

故事扮演 提交于 2019-12-01 14:21:17
I am using ASP.NET MVC, Identity2. I have added "FirstName" Custom ClaimPrincipal : public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser, long> manager) { var userIdentity = await manager.CreateIdentityAsync( this, DefaultAuthenticationTypes.ApplicationCookie); // Add custom user claims here userIdentity.AddClaim(new Claim("FirstName", FirstName)); return userIdentity; } If I update the value of "FirstName", I need to logout and log back in, for the "FirstName" Claim to be updated. Is it possible to invalidate "FirstName" Claim, so it's value is forced to be

ASP.NET Core Identity Role, Claim and User

南楼画角 提交于 2019-12-01 14:13:52
问题 I am an ASP.NET Core beginner. I'm stuck in role, claim and user relationship. I have a user Ben , user belongs to Admin role. Admin role has claims view-page and edit-page in database. But I can't get claims and roles to be belonging to that user: (Please see comment in code) var user = await _userManager.FindByNameAsync(applicationUser.UserName); if(user != null) { var userClaims = await _userManager.GetClaimsAsync(user); // empty, WHY ? var userRoles = await _userManager.GetRolesAsync(user

Invalidate ClaimsPrincipal after it has been modified

自古美人都是妖i 提交于 2019-12-01 13:21:14
问题 I am using ASP.NET MVC, Identity2. I have added "FirstName" Custom ClaimPrincipal : public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser, long> manager) { var userIdentity = await manager.CreateIdentityAsync( this, DefaultAuthenticationTypes.ApplicationCookie); // Add custom user claims here userIdentity.AddClaim(new Claim("FirstName", FirstName)); return userIdentity; } If I update the value of "FirstName", I need to logout and log back in, for the

Digest verification failed for Reference

一个人想着一个人 提交于 2019-12-01 11:40:17
I have implementation of a custom STS. After being authenticated and redirected but before the page was loaded I would receive this error: [CryptographicException: Digest verification failed for Reference '#_8e0aea1a-713d-4536-8fac-a768073395e9'.] The reference number would change every time I tried. I eventually found out that the claims, I had loaded from the database, had carriage return line feeds. Once I replaced those I had no more issues. 来源: https://stackoverflow.com/questions/19013666/digest-verification-failed-for-reference

what are the URLs for in claim-types

旧城冷巷雨未停 提交于 2019-12-01 05:19:58
Since I want to add custom claims into my application, I checked the sourcecode of ClaimTypes (decompiled with JetBrains decompiler). Here is a piece of it: namespace System.Security.Claims { /// <summary>Defines constants for the well-known claim types that can be assigned to a subject. This class cannot be inherited.</summary> [ComVisible(false)] public static class ClaimTypes { internal const string ClaimTypeNamespace = "http://schemas.microsoft.com/ws/2008/06/identity/claims"; /// <summary>The URI for a claim that specifies the instant at which an entity was authenticated; http://schemas

Claims authorization for specific resources

邮差的信 提交于 2019-12-01 04:44:16
I am writing an example file storage system (example just for stackoverflow). My current domain models look as such: public class User { public int ID { get; set; } public string LoginIdentifier { get; set; } public string Password { get; set; } } public class File { public int ID { get; set; } public int UserID { get; set; } public string FileName { get; set; } public byte[] Data { get; set; } } The code I am writing to create the IPrincipal: private static IPrincipal CreatePrincipal(User user) { Debug.Assert(user != null); var identity = new GenericIdentity(user.LoginIdentifier, "Basic"); //

Unable to add and fetch custom claims values

狂风中的少年 提交于 2019-12-01 02:33:25
I am using mvc 5 with identity 2.0. I want use custom claim values over the application but I get null value. What am I doing wrong? Updated code Login Code in account controller if (!string.IsNullOrEmpty(model.UserName) && !string.IsNullOrEmpty(model.Password)) { AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie); var result = SignInManager.PasswordSignIn(model.UserName, model.Password, model.RememberMe, shouldLockout: false); //Generate verification token Dictionary<string, string> acceccToken = null; if (SignInStatus.Success == 0) { var userDeatails = FindUser(model

what are the URLs for in claim-types

霸气de小男生 提交于 2019-12-01 02:13:26
问题 Since I want to add custom claims into my application, I checked the sourcecode of ClaimTypes (decompiled with JetBrains decompiler). Here is a piece of it: namespace System.Security.Claims { /// <summary>Defines constants for the well-known claim types that can be assigned to a subject. This class cannot be inherited.</summary> [ComVisible(false)] public static class ClaimTypes { internal const string ClaimTypeNamespace = "http://schemas.microsoft.com/ws/2008/06/identity/claims"; ///

Claims authorization for specific resources

爱⌒轻易说出口 提交于 2019-12-01 02:04:59
问题 I am writing an example file storage system (example just for stackoverflow). My current domain models look as such: public class User { public int ID { get; set; } public string LoginIdentifier { get; set; } public string Password { get; set; } } public class File { public int ID { get; set; } public int UserID { get; set; } public string FileName { get; set; } public byte[] Data { get; set; } } The code I am writing to create the IPrincipal: private static IPrincipal CreatePrincipal(User

WIF config: issuerNameRegistry vs. certificateValidation

天涯浪子 提交于 2019-12-01 01:36:26
In the Windows Identity Foundation (WIF) 4.5 config, what is the relationship between issuerNameRegistry and certificateValidation ? What portion of a SAML 2.0 assertion is validated by each? For example: the code & config below will verify that the issuer cert has the given thumbprint. But I assume a certificateValidationMode other than "None" will validate some additional details? var handlers = FederatedAuthentication.FederationConfiguration.IdentityConfiguration.SecurityTokenHandlers; var token = handlers.ReadToken( myxmlReader ); var identities = handlers.ValidateToken( token ); config: