Sha256: 7ae5a09390b8711b3b792ff5dbdea6ed1f986e5f28474eb3f6f259a0dccf2746
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true module Rails # Modular resource-based authentication and authorization for Rails/Rack module Auth # Rack environment key for all rails-auth principals PRINCIPALS_ENV_KEY = "rails-auth.principals".freeze # Functionality for storing principals in the Rack environment module Principals # Obtain principals from a Rack environment # # @param [Hash] :env Rack environment # def principals(env) env.fetch(PRINCIPALS_ENV_KEY, {}) end # Add a principal to the Rack environment # # @param [Hash] :env Rack environment # @param [String] :type principal type to add to the environment # @param [Object] :principal principal object to add to the environment # def add_principal(env, type, principal) principals = env[PRINCIPALS_ENV_KEY] ||= {} fail ArgumentError, "principal #{type} already added to request" if principals.key?(type) principals[type] = principal end end # Include these functions in Rails::Auth for convenience extend Principals end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails-auth-0.0.1 | lib/rails/auth/principals.rb |