Sha256: 21be209f2aa5f01af93a7634ff0a9901251d752747599a9af023b4c416217dd7

Contents?: true

Size: 981 Bytes

Versions: 4

Compression:

Stored size: 981 Bytes

Contents

module Unimatrix::Authorization

  class Railtie < Rails::Railtie
    initializer "unimatrix.authorization.configure_controller" do | app |
      ActiveSupport.on_load :action_controller do
        include Unimatrix::Authorization
      end
    end
  end

  def retrieve_policies( resource_name, access_token, realm_uuid, resource_server )
    if resource_name && access_token
      key = [ resource_name, access_token, realm_uuid, resource_server ].join

      Rails.cache.fetch(
        "keymaker-policies-#{ Digest::SHA1.hexdigest( key ) }",
        expires_in: 1.minute
      ) do
        request_policies( resource_name, access_token, realm_uuid, resource_server )
      end
    end
  end

  def retrieve_resource_owner( access_token )
    if access_token
      Rails.cache.fetch(
        "keymaker-resource_owner-#{ Digest::SHA1.hexdigest( access_token ) }",
        expires_in: 1.minute
      ) do
        request_resource_owner( access_token )
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
unimatrix-2.9.0 lib/unimatrix/authorization/railtie.rb
unimatrix-2.8.0 lib/unimatrix/authorization/railtie.rb
unimatrix-2.7.1 lib/unimatrix/authorization/railtie.rb
unimatrix-2.7.0 lib/unimatrix/authorization/railtie.rb