Module: ClientAuthenticator::ApiAuthenticable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/client_authenticator/api_authenticable.rb
Instance Method Summary collapse
Instance Method Details
#authenticate_client! ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/client_authenticator/api_authenticable.rb', line 7 def authenticate_client! client_id = request.headers[ClientAuthenticator.configuration.client_id_header] pass_key = request.headers[ClientAuthenticator.configuration.pass_key_header] if client_id.nil? || pass_key.nil? || (client_id, pass_key) render json: {'error' => 'unauthorized'}, status: :unauthorized end end |
#unauthorized?(client_id, pass_key) ⇒ Boolean
15 16 17 18 19 20 |
# File 'lib/client_authenticator/api_authenticable.rb', line 15 def (client_id, pass_key) ttl = ClientAuthenticator.configuration.cache_expiry_duration Rails.cache.fetch("#{client_id}_#{pass_key}", expires_in: ttl) do not ApiClient.authenticated?(client_id, pass_key) end end |