Class: AuthenticatorServer::TokenVerifier
- Inherits:
-
Object
- Object
- AuthenticatorServer::TokenVerifier
- Defined in:
- lib/authenticator_server/token_verifier.rb
Constant Summary collapse
- ALGORITHM =
ALGORITHM = ‘RS256’
'HS512'
Class Method Summary collapse
-
.verify(token, token_verification_key) ⇒ Object
This method verifies the token using token_verification_key.
Class Method Details
.verify(token, token_verification_key) ⇒ Object
This method verifies the token using token_verification_key
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/authenticator_server/token_verifier.rb', line 21 def self.verify(token, token_verification_key) begin raise ArgumentError.new('String argument is expected') unless token_verification_key.kind_of? String # rsa_public_key = AuthenticatorServer::RSAKeyPairProvider.public_key_from_base64 token_verification_key output = JWT.decode(token, token_verification_key, true, { algorithm: ALGORITHM }) output.first rescue ArgumentError => e e rescue JWT::IncorrectAlgorithm => e e rescue JWT::ExpiredSignature => e e rescue JWT::VerificationError => e e rescue JWT::DecodeError => e e rescue Exception => e e end end |