Class: PrefixApiKey::Check
- Inherits:
-
Object
- Object
- PrefixApiKey::Check
- Defined in:
- lib/prefix_api_key/check.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.call(token: nil, hash: nil) ⇒ Object
6 7 8 |
# File 'lib/prefix_api_key/check.rb', line 6 def self.call(token: nil, hash: nil) new.call(token: token, hash: hash) end |
Instance Method Details
#call(token: nil, hash: nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/prefix_api_key/check.rb', line 10 def call(token: nil, hash: nil) token = token.split("_") prefix = token[0] short_token = token[1] long_token = token[2] short_token_valid = short_token_valid(prefix: prefix, short_token: short_token) digest_hash = ::Digest::SHA2.hexdigest(long_token) short_token_valid == short_token && hash == digest_hash end |