Class: Talis::Authentication::PublicKey
- Defined in:
- lib/talis/authentication/public_key.rb
Overview
Provides the ability to fetch a public key to verify tokens. There is no need to use this class directly as it is used by the Token class to verify tokens.
Instance Method Summary collapse
-
#fetch(request_id: self.class.new_req_id) ⇒ String
Fetch a public key for use with token verification, either from the provided cache or remotely.
-
#initialize(cache_store) ⇒ PublicKey
constructor
Construct an empty public key object.
Methods inherited from Resource
Constructor Details
#initialize(cache_store) ⇒ PublicKey
Construct an empty public key object.
15 16 17 |
# File 'lib/talis/authentication/public_key.rb', line 15 def initialize(cache_store) @cache_store = cache_store end |
Instance Method Details
#fetch(request_id: self.class.new_req_id) ⇒ String
Fetch a public key for use with token verification, either from the provided cache or remotely.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/talis/authentication/public_key.rb', line 23 def fetch(request_id: self.class.new_req_id) # Token base URI may have changed after the class was loaded. self.class.base_uri(Token.base_uri) public_key = @cache_store.fetch(cache_key, ) do opts = { format: :plain, headers: { 'X-Request-Id' => request_id } } response = self.class.get('/oauth/keys', opts) self.class.handle_response(response) end OpenSSL::PKey.read(public_key) end |