From 2f6f3e566fd809179d531afd5998694153964e2f Mon Sep 17 00:00:00 2001 From: Yuriy Durov Date: Sun, 29 Dec 2024 15:55:52 +0400 Subject: [PATCH] Remove ValidateToken lines --- .../Services/IdentityClaimsService.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/BitzArt.Blazor.Auth/Services/IdentityClaimsService.cs b/src/BitzArt.Blazor.Auth/Services/IdentityClaimsService.cs index bcc73e8..0111986 100644 --- a/src/BitzArt.Blazor.Auth/Services/IdentityClaimsService.cs +++ b/src/BitzArt.Blazor.Auth/Services/IdentityClaimsService.cs @@ -6,7 +6,6 @@ namespace BitzArt.Blazor.Auth; public class IdentityClaimsService() : IIdentityClaimsService { private readonly JwtSecurityTokenHandler _tokenHandler = new(); - private static ClaimsPrincipal EmptyClaimsPrincipal => new(new ClaimsIdentity()); public virtual Task BuildClaimsPrincipalAsync(string accessToken) { @@ -15,21 +14,13 @@ public virtual Task BuildClaimsPrincipalAsync(string accessToke public virtual ClaimsPrincipal BuildClaimsPrincipal(string accessToken) { - if (ValidateRawToken(accessToken) == false) return EmptyClaimsPrincipal; - var token = _tokenHandler.ReadJwtToken(accessToken); - if (ValidateToken(token) == false) return EmptyClaimsPrincipal; - var claims = MapClaims(token.Claims); claims = claims.Append(new Claim(Constants.AccessTokenCookieName, accessToken)); return new ClaimsPrincipal(new ClaimsIdentity(claims, "Custom")); } - protected virtual bool ValidateRawToken(string token) => true; - - protected virtual bool ValidateToken(JwtSecurityToken token) => true; - protected virtual IEnumerable MapClaims(IEnumerable claims) => claims; }