Module: Rails::Auth::Credentials
- Included in:
- Rails::Auth
- Defined in:
- lib/rails/auth/credentials.rb
Overview
Functionality for storing credentials in the Rack environment
Instance Method Summary collapse
-
#add_credential(env, type, credential) ⇒ Object
Add a credential to the Rack environment.
-
#credentials(env) ⇒ Object
Obtain credentials from a Rack environment.
Instance Method Details
#add_credential(env, type, credential) ⇒ Object
Add a credential to the Rack environment
25 26 27 28 29 30 31 32 |
# File 'lib/rails/auth/credentials.rb', line 25 def add_credential(env, type, credential) credentials = env[CREDENTIALS_ENV_KEY] ||= {} fail ArgumentError, "credential #{type} already added to request" if credentials.key?(type) credentials[type] = credential env end |
#credentials(env) ⇒ Object
Obtain credentials from a Rack environment
15 16 17 |
# File 'lib/rails/auth/credentials.rb', line 15 def credentials(env) env.fetch(CREDENTIALS_ENV_KEY, {}) end |