Skip to content

Commit

Permalink
Remove ValidateToken lines
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriyDurov committed Dec 29, 2024
1 parent 0f47803 commit 2f6f3e5
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions src/BitzArt.Blazor.Auth/Services/IdentityClaimsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ClaimsPrincipal> BuildClaimsPrincipalAsync(string accessToken)
{
Expand All @@ -15,21 +14,13 @@ public virtual Task<ClaimsPrincipal> 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<Claim> MapClaims(IEnumerable<Claim> claims) => claims;
}

0 comments on commit 2f6f3e5

Please sign in to comment.