diff --git a/src/Infrastructure/Security/DefaultTokenHandler.cs b/src/Infrastructure/Security/DefaultTokenHandler.cs new file mode 100644 index 0000000..15df00c --- /dev/null +++ b/src/Infrastructure/Security/DefaultTokenHandler.cs @@ -0,0 +1,15 @@ +using System.IdentityModel.Tokens.Jwt; +using Microsoft.IdentityModel.Tokens; + +namespace Infrastructure.Security; + +public class DefaultTokenHandler(IEncryptionService encryptionService, JwtSecurityTokenHandler jwtSecurityTokenHandler) + : TokenHandler +{ + public override Task ValidateTokenAsync(string token, + TokenValidationParameters validationParameters) + { + var decodeToken = encryptionService.Decrypt(token); + return jwtSecurityTokenHandler.ValidateTokenAsync(decodeToken, validationParameters); + } +} \ No newline at end of file diff --git a/src/Infrastructure/Security/TokenInfo.cs b/src/Infrastructure/Security/TokenInfo.cs new file mode 100644 index 0000000..9db0294 --- /dev/null +++ b/src/Infrastructure/Security/TokenInfo.cs @@ -0,0 +1,10 @@ +namespace Infrastructure.Security; + +public class TokenInfo(string token, double expiredIn, string tokenType) +{ + public string? Token { get; } = token; + + public double? ExpiredIn { get; } = expiredIn; + + public string? TokenType { get; } = tokenType; +} \ No newline at end of file