Class: Platforms::Core::OmniAuthSetup
- Inherits:
-
Object
- Object
- Platforms::Core::OmniAuthSetup
- Defined in:
- lib/platforms/core/omni_auth_setup.rb
Overview
Handles the dynamic insertion of client ID and Client Secret into the OmniAuth regime.
Class Method Summary collapse
-
.call(env) ⇒ Object
OmniAuth expects the class passed to setup to respond to the #call method.
Instance Method Summary collapse
-
#default_certificate ⇒ Object
As a placeholder, return a blank certificate.
-
#find_credentials ⇒ Object
Use the subdomain in the request to find the account with credentials.
-
#initialize(env) ⇒ OmniAuthSetup
constructor
Assign variables and create a request object for use later.
-
#setup ⇒ Object
The main purpose of this method is to set the consumer key and secret.
Constructor Details
#initialize(env) ⇒ OmniAuthSetup
Assign variables and create a request object for use later. env - Rack environment
22 23 24 25 |
# File 'lib/platforms/core/omni_auth_setup.rb', line 22 def initialize(env) @env = env @request = ActionDispatch::Request.new(env) end |
Class Method Details
.call(env) ⇒ Object
OmniAuth expects the class passed to setup to respond to the #call method.
16 17 18 |
# File 'lib/platforms/core/omni_auth_setup.rb', line 16 def self.call(env) new(env).setup end |
Instance Method Details
#default_certificate ⇒ Object
As a placeholder, return a blank certificate
47 48 49 |
# File 'lib/platforms/core/omni_auth_setup.rb', line 47 def default_certificate Certificate.new end |
#find_credentials ⇒ Object
Use the subdomain in the request to find the account with credentials
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/platforms/core/omni_auth_setup.rb', line 33 def find_credentials strategy = @env['omniauth.strategy']..name subdomain = ActionDispatch::Http::URL.extract_subdomains(@env['SERVER_NAME'], 0).first certificate = Certificate.find_by( strategy: strategy, name: subdomain ) # If subdomain-specific certificate is not found, use default certificate ||= default_certificate return certificate.credentials end |
#setup ⇒ Object
The main purpose of this method is to set the consumer key and secret.
28 29 30 |
# File 'lib/platforms/core/omni_auth_setup.rb', line 28 def setup @env['omniauth.strategy']..merge!(find_credentials) end |