Module: Mumukit::Login::Provider
- Defined in:
- lib/mumukit/login/provider.rb
Defined Under Namespace
Classes: Auth0, Base, Cas, Developer, Google, Saml
Constant Summary collapse
- PROVIDERS =
%w( developer auth0 saml cas google )
Class Method Summary collapse
-
.default_enabled_providers ⇒ Object
This is a list of the default enabled login providers It depends only on the current environment.
-
.enabled_providers ⇒ Object
This is a list of the login providers enabled on the current instance of the platform It is obtained from the environment, and if unset, it defaults to default_enabled_providers.
- .from_env ⇒ Object
-
.login_provider_string ⇒ Object
This is the default login provider used when it is not overriden in the organization’s config It is obtained from env, and defaults to the first of the current enabled providers It should always be a provider within the enabled_providers list.
- .parse_login_provider(login_provider) ⇒ Object
- .setup_providers!(omniauth) ⇒ Object
Class Method Details
.default_enabled_providers ⇒ Object
This is a list of the default enabled login providers It depends only on the current environment
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mumukit/login/provider.rb', line 16 def self.default_enabled_providers case ENV['RACK_ENV'] || ENV['RAILS_ENV'] when 'production' PROVIDERS - %w(developer) when 'test' PROVIDERS else %w(developer) end end |
.enabled_providers ⇒ Object
This is a list of the login providers enabled on the current instance of the platform It is obtained from the environment, and if unset, it defaults to default_enabled_providers
29 30 31 32 33 34 35 |
# File 'lib/mumukit/login/provider.rb', line 29 def self.enabled_providers if ENV['MUMUKI_ENABLED_LOGIN_PROVIDERS'].blank? default_enabled_providers else ENV['MUMUKI_ENABLED_LOGIN_PROVIDERS'].split ',' end end |
.from_env ⇒ Object
10 11 12 |
# File 'lib/mumukit/login/provider.rb', line 10 def self.from_env parse_login_provider(login_provider_string) end |
.login_provider_string ⇒ Object
This is the default login provider used when it is not overriden in the organization’s config It is obtained from env, and defaults to the first of the current enabled providers It should always be a provider within the enabled_providers list
40 41 42 43 44 45 46 |
# File 'lib/mumukit/login/provider.rb', line 40 def self.login_provider_string if ENV['MUMUKI_LOGIN_PROVIDER'].blank? enabled_providers.first else ENV['MUMUKI_LOGIN_PROVIDER'] end end |
.parse_login_provider(login_provider) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/mumukit/login/provider.rb', line 48 def self.parse_login_provider(login_provider) if enabled_providers.include?(login_provider.to_s) "Mumukit::Login::Provider::#{login_provider.capitalize}".constantize.new else raise "Unknown login_provider `#{login_provider}`" end end |
.setup_providers!(omniauth) ⇒ Object
56 57 58 |
# File 'lib/mumukit/login/provider.rb', line 56 def self.setup_providers!(omniauth) enabled_providers.each { |it| parse_login_provider(it).configure_omniauth!(omniauth) } end |