/// <summary> /// Given a JWT, decodes it and return the payload. /// </summary> /// <param name="decoder">The decoder instance</param> /// <param name="token">The JWT</param> /// <returns>A string containing the JSON payload</returns> /// <exception cref="ArgumentException" /> /// <exception cref="ArgumentOutOfRangeException" /> /// <exception cref="InvalidTokenPartsException" /> public static string Decode(this IJwtDecoder decoder, string token) => decoder.Decode(new JwtParts(token));
/// <summary> /// Given a JWT, decodes it and return the payload. /// </summary> /// <param name="decoder">The decoder instance</param> /// <param name="jwt">The JWT</param> /// <returns>A string containing the JSON payload</returns> public static string Decode(this IJwtDecoder decoder, JwtParts jwt) => decoder.Decode(jwt, (byte[])null, verify: false);
public bool VerifyToken(IJwtDecoder jwtDecoder, string token, JwtOptions options) { return(jwtDecoder.TryDecode(token, options.SecretBytes, out string result)); }
public static IDictionary <string, string> DecodeHeaderToDictionary(this IJwtDecoder decoder, string token) => decoder.DecodeHeader <Dictionary <string, string> >(token);
public static IDictionary <string, object> DecodeToObject(this IJwtDecoder decoder, string token, string[] keys, bool verify) => decoder.DecodeToObject(token, GetBytes(keys), verify);
/// <summary> /// Sets JWT decoder. /// </summary> /// <returns>Current builder instance</returns> public JwtBuilder WithDecoder(IJwtDecoder decoder) { _decoder = decoder; return(this); }
public JWTService(IJWTSettings jwtSettings, IJwtDecoder jwtDecoder, IJwtEncoder jwtEncoder) { _key = jwtSettings.Key; _decoder = jwtDecoder; _encoder = jwtEncoder; }
/// <summary> /// Given a JWT, decodes it and return the payload as an object. /// </summary> /// <typeparam name="T">The type to return</typeparam> /// <param name="decoder">The decoder instance</param> /// <param name="token">The JWT</param> /// <returns>An object representing the payload</returns> public static T DecodeToObject <T>(this IJwtDecoder decoder, string token) => decoder.DecodeToObject <T>(new JwtParts(token));
/// <summary> /// Given a JWT, decodes it and return the payload as an object. /// </summary> /// <typeparam name="T">The type to return</typeparam> /// <param name="decoder">The decoder instance</param> /// <param name="token">The JWT</param> /// <param name="keys">The keys provided which one of them was used to sign the JWT</param> /// <param name="verify">Whether to verify the signature (default is true)</param> /// <returns>An object representing the payload</returns> public static T DecodeToObject <T>(this IJwtDecoder decoder, string token, string[] keys, bool verify) => decoder.DecodeToObject <T>(token, keys is object?GetBytes(keys) : null, verify);
public JwtController(IJwtEncoder jwtEncoder, IJwtDecoder jwtDecoder) { _jwtEncoder = jwtEncoder; _jwtDecoder = jwtDecoder; }
/// <summary> /// Given a JWT, decodes it and return the payload as an object. /// </summary> /// <typeparam name="T">The type to return</typeparam> /// <param name="decoder">The decoder instance</param> /// <param name="token">The JWT</param> /// <param name="key">The key that was used to sign the JWT</param> /// <param name="verify">Whether to verify the signature (default is true)</param> /// <returns>An object representing the payload</returns> public static T DecodeToObject <T>(this IJwtDecoder decoder, string token, byte[] key, bool verify) => decoder.DecodeToObject <T>(new JwtParts(token), key, verify);
/// <summary> /// Given a JWT, decodes it and return the payload as an object. /// </summary> /// <typeparam name="T">The type to return</typeparam> /// <param name="decoder">The decoder instance</param> /// <param name="token">The JWT</param> /// <param name="key">The key that was used to sign the JWT</param> /// <param name="verify">Whether to verify the signature (default is true)</param> /// <returns>An object representing the payload</returns> public static T DecodeToObject <T>(this IJwtDecoder decoder, string token, string key, bool verify) => decoder.DecodeToObject <T>(token, GetBytes(key), verify);
/// <summary> /// Given a JWT, decodes it and return the payload as a dictionary. /// </summary> /// <param name="decoder">The decoder instance</param> /// <param name="token">The JWT</param> /// <param name="keys">The keys that were used to sign the JWT</param> /// <param name="verify">Whether to verify the signature (default is true)</param> /// <returns>A string containing the JSON payload</returns> /// <exception cref="ArgumentException" /> /// <exception cref="ArgumentOutOfRangeException" /> /// <exception cref="InvalidTokenPartsException" /> public static IDictionary <string, object> DecodeToObject(this IJwtDecoder decoder, string token, byte[][] keys, bool verify) => decoder.DecodeToObject <Dictionary <string, object> >(new JwtParts(token), keys, verify);
/// <summary> /// Given a JWT, decodes it and return the payload. /// </summary> /// <param name="decoder">The decoder instance</param> /// <param name="token">The JWT</param> /// <param name="keys">The keys that were used to sign the JWT</param> /// <param name="verify">Whether to verify the signature (default is true)</param> /// <returns>A string containing the JSON payload</returns> /// <exception cref="ArgumentException" /> /// <exception cref="ArgumentOutOfRangeException" /> /// <exception cref="InvalidTokenPartsException" /> public static string Decode(this IJwtDecoder decoder, string token, byte[][] keys, bool verify) => decoder.Decode(new JwtParts(token), keys, verify);
public TokenFactory(IJwtEncoder encoder, IJwtDecoder decoder) { _encoder = encoder; _decoder = decoder; }
/// <summary> /// Given a JWT, decodes it and return the payload as an dictionary. /// </summary> /// <param name="decoder">The decoder instance</param> /// <param name="token">The JWT</param> /// <param name="keys">The key which one of them was used to sign the JWT</param> /// <param name="verify">Whether to verify the signature (default is true)</param> /// <returns>An object representing the payload</returns> /// <exception cref="ArgumentException" /> /// <exception cref="ArgumentOutOfRangeException" /> public static string Decode(this IJwtDecoder decoder, string token, string[] keys, bool verify) => decoder.Decode(token, GetBytes(keys), verify);
public LoggedInHelper(IHttpContextAccessor httpContextAccessor, CurrentEnvironment environment, IJwtDecoder decoder, ILogger <LoggedInHelper> logger) { _httpContextAccessor = httpContextAccessor; _environment = environment; _decoder = decoder; _logger = logger; }
/// <summary> /// Given a JWT, decodes it and return the payload as a dictionary. /// </summary> /// <param name="decoder">The decoder instance</param> /// <param name="token">The JWT</param> /// <returns>An object representing the payload</returns> public static IDictionary <string, object> DecodeToObject(this IJwtDecoder decoder, string token) => decoder.DecodeToObject <Dictionary <string, object> >(token);
public TokenJwtBinder(string secret) { validator = new JwtValidator(serializer, provider); decoder = new JwtDecoder(serializer, validator, urlEncoder); _secret = secret; }