Sha256: 18b3cef0664c8ae467e7d3f6edd9ef9847c6758ceed59019670674f64248f881

Contents?: true

Size: 822 Bytes

Versions: 3

Compression:

Stored size: 822 Bytes

Contents

module Rails
  # Modular resource-based authentication and authorization for Rails/Rack
  module Auth
    # Rack environment key for marking external authorization
    AUTHORIZED_ENV_KEY = "rails-auth.authorized".freeze

    # Functionality allowing external middleware to override our ACL check process
    module Override
      # Mark a request as externally authorized. Causes ACL checks to be skipped.
      #
      # @param [Hash] :env Rack environment
      #
      def authorized!(env)
        env[AUTHORIZED_ENV_KEY] = true
      end

      # Check whether a request has been externally authorized? Used to bypass
      # ACL check.
      #
      # @param [Hash] :env Rack environment
      #
      def authorized?(env)
        env.fetch(AUTHORIZED_ENV_KEY, false)
      end
    end

    extend Override
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails-auth-1.3.0 lib/rails/auth/override.rb
rails-auth-1.2.0 lib/rails/auth/override.rb
rails-auth-1.1.0 lib/rails/auth/override.rb