Class: Virgil::Jwt::JwtVerifier
- Inherits:
-
Object
- Object
- Virgil::Jwt::JwtVerifier
- Defined in:
- lib/virgil/jwt/jwt_verifier.rb
Instance Attribute Summary collapse
-
#access_token_signer ⇒ AccessTokenSigner
readonly
verify token signature.
-
#api_public_key ⇒ PublicKey
readonly
Public Key which should be used to verify signatures.
-
#api_public_key_id ⇒ String
readonly
Id of public key which should be used to verify signatures.
Instance Method Summary collapse
-
#initialize(access_token_signer:, api_public_key:, api_public_key_id:) ⇒ JwtVerifier
constructor
Initializes a new instance of the class.
-
#verify_token(jwt) ⇒ Object
Verifies specified token.
Constructor Details
#initialize(access_token_signer:, api_public_key:, api_public_key_id:) ⇒ JwtVerifier
Initializes a new instance of the class
55 56 57 58 59 |
# File 'lib/virgil/jwt/jwt_verifier.rb', line 55 def initialize(access_token_signer:, api_public_key:, api_public_key_id:) @access_token_signer = access_token_signer @api_public_key = api_public_key @api_public_key_id = api_public_key_id end |
Instance Attribute Details
#access_token_signer ⇒ AccessTokenSigner (readonly)
verify token signature.
41 42 43 |
# File 'lib/virgil/jwt/jwt_verifier.rb', line 41 def access_token_signer @access_token_signer end |
#api_public_key ⇒ PublicKey (readonly)
Public Key which should be used to verify signatures
45 46 47 |
# File 'lib/virgil/jwt/jwt_verifier.rb', line 45 def api_public_key @api_public_key end |
#api_public_key_id ⇒ String (readonly)
Id of public key which should be used to verify signatures
49 50 51 |
# File 'lib/virgil/jwt/jwt_verifier.rb', line 49 def api_public_key_id @api_public_key_id end |
Instance Method Details
#verify_token(jwt) ⇒ Object
Verifies specified token.
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/virgil/jwt/jwt_verifier.rb', line 64 def verify_token(jwt) if jwt.header_content.key_id != @api_public_key_id || jwt.header_content.algorithm != @access_token_signer.algorithm || jwt.header_content.content_type != JwtHeaderContent::VIRGIL_CONTENT_TYPE || jwt.header_content.type != JwtHeaderContent::JWT_TYPE return false end @access_token_signer.verify_token_signature(jwt.signature_data, jwt.unsigned_data, api_public_key) end |