mumukit-login 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/mumukit/login.rb +83 -0
- data/lib/mumukit/login/controller.rb +30 -0
- data/lib/mumukit/login/form.rb +48 -0
- data/lib/mumukit/login/framework.rb +4 -0
- data/lib/mumukit/login/framework/rails.rb +56 -0
- data/lib/mumukit/login/helpers.rb +2 -0
- data/lib/mumukit/login/helpers/authentication_helpers.rb +46 -0
- data/lib/mumukit/login/helpers/login_controller_helpers.rb +31 -0
- data/lib/mumukit/login/origin_redirector.rb +21 -0
- data/lib/mumukit/login/profile.rb +10 -0
- data/lib/mumukit/login/provider.rb +33 -0
- data/lib/mumukit/login/provider/auth0.rb +41 -0
- data/lib/mumukit/login/provider/base.rb +43 -0
- data/lib/mumukit/login/provider/developer.rb +8 -0
- data/lib/mumukit/login/provider/saml.rb +39 -0
- data/lib/mumukit/login/settings.rb +56 -0
- data/lib/mumukit/login/version.rb +5 -0
- metadata +215 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a3ee9172809ea39874cd16d18c98a2b180d645fb
|
4
|
+
data.tar.gz: d9abbc2b9dbc329c2e2e402330880c759fa12f07
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d1860be5880a0f25c6e408f8b8e60efaaae81eafd1d38e2a671368f4754a3bb574b79f31b196228aef83d8ba456370a6230aa717cafc7c1ef7bb9ab939cbb35c
|
7
|
+
data.tar.gz: fcc2e6f167b9235d77b7120ccfcebf713285897e65007d7819a959402d855ca2ca5d14fe7f8373e22ab41dbd76d7e586c901f558639f964a9cdcb5186a93dfc7
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'rack/request'
|
2
|
+
require 'addressable/uri'
|
3
|
+
|
4
|
+
require 'omniauth'
|
5
|
+
require 'omniauth-auth0'
|
6
|
+
require 'omniauth-saml'
|
7
|
+
|
8
|
+
require 'mumukit/core'
|
9
|
+
|
10
|
+
module Mumukit::Login
|
11
|
+
def self.configure
|
12
|
+
@config ||= defaults
|
13
|
+
yield @config
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.defaults
|
17
|
+
struct.tap do |config|
|
18
|
+
config.provider = Mumukit::Login::Provider.from_env
|
19
|
+
config.saml = struct base_url: ENV['MUMUKI_SAML_BASE_URL'],
|
20
|
+
idp_sso_target_url: ENV['MUMUKI_SAML_IDP_SSO_TARGET_URL'],
|
21
|
+
idp_slo_target_url: ENV['MUMUKI_SAML_IDP_SLO_TARGET_URL'],
|
22
|
+
translation_name: ENV['MUMUKI_SAML_TRANSLATION_NAME'] || 'name',
|
23
|
+
translation_email: ENV['MUMUKI_SAML_TRANSLATION_EMAIL'] || 'email',
|
24
|
+
translation_image: ENV['MUMUKI_SAML_TRANSLATION_IMAGE'] || 'image'
|
25
|
+
config.auth0 = struct client_id: ENV['MUMUKI_AUTH0_CLIENT_ID'],
|
26
|
+
client_secret: ENV['MUMUKI_AUTH0_CLIENT_SECRET'],
|
27
|
+
domain: ENV['MUMUKI_AUTH0_DOMAIN']
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.config
|
32
|
+
@config
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
require_relative './login/controller'
|
37
|
+
require_relative './login/form'
|
38
|
+
require_relative './login/framework'
|
39
|
+
require_relative './login/origin_redirector'
|
40
|
+
require_relative './login/profile'
|
41
|
+
require_relative './login/provider'
|
42
|
+
require_relative './login/settings'
|
43
|
+
require_relative './login/helpers'
|
44
|
+
require_relative './login/version'
|
45
|
+
|
46
|
+
|
47
|
+
module Mumukit::Login
|
48
|
+
|
49
|
+
# Configures omniauth. This method typically configures
|
50
|
+
# and sets the omniauth provider. Typical config should look like this
|
51
|
+
#
|
52
|
+
# Rails.application.config.middleware.use OmniAuth::Builder do
|
53
|
+
# Mumukit::Login.configure_omniauth! self
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# @param [OmniAuth::Builder] omniauth
|
57
|
+
#
|
58
|
+
def self.configure_omniauth!(omniauth)
|
59
|
+
provider.configure_omniauth! omniauth
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.configure_login_routes!(native)
|
63
|
+
framework.configure_login_routes! native
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.configure_login_controller!(native)
|
67
|
+
framework.configure_login_controller!(native)
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.configure_controller!(native)
|
71
|
+
framework.configure_controller! native
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def self.framework
|
77
|
+
Mumukit::Login.config.framework
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.provider
|
81
|
+
Mumukit::Login.config.provider
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class Mumukit::Login::Controller
|
2
|
+
def initialize(framework, native)
|
3
|
+
@framework = framework
|
4
|
+
@native = native
|
5
|
+
end
|
6
|
+
|
7
|
+
def env
|
8
|
+
@framework.env @native
|
9
|
+
end
|
10
|
+
|
11
|
+
def redirect!(path)
|
12
|
+
@framework.redirect!(path, @native)
|
13
|
+
end
|
14
|
+
|
15
|
+
def render_html!(html)
|
16
|
+
@framework.render_html!(html, @native)
|
17
|
+
end
|
18
|
+
|
19
|
+
def request
|
20
|
+
Rack::Request.new(env)
|
21
|
+
end
|
22
|
+
|
23
|
+
def url_for(path)
|
24
|
+
URI.join(request.base_url, path).to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
def session
|
28
|
+
request.session
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
|
2
|
+
class Mumukit::Login::Form
|
3
|
+
|
4
|
+
#######################
|
5
|
+
## Visual components ##
|
6
|
+
#######################
|
7
|
+
|
8
|
+
# This object will configure the login button using the given login settings
|
9
|
+
# customizations, if possible
|
10
|
+
#
|
11
|
+
# @param [Mumukit::Login::Controller] controller a Mumukit::Login::Controller
|
12
|
+
# @param [Mumukit::Login::Settings] login_settings customizations for the login UI
|
13
|
+
def initialize(provider, controller, login_settings)
|
14
|
+
@provider = provider
|
15
|
+
@controller = controller
|
16
|
+
@login_settings = login_settings
|
17
|
+
end
|
18
|
+
|
19
|
+
# HTML <HEAD> customizations. Send this message
|
20
|
+
# in order to add login provider-specific code - like CSS and JS -
|
21
|
+
# to your page header.
|
22
|
+
#
|
23
|
+
def header_html
|
24
|
+
@provider.header_html(@controller, @login_settings)&.html_safe
|
25
|
+
end
|
26
|
+
|
27
|
+
def button_html(title, clazz)
|
28
|
+
@provider.button_html(@controller, title, clazz)&.html_safe
|
29
|
+
end
|
30
|
+
|
31
|
+
def footer_html
|
32
|
+
@provider.footer_html(@controller)&.html_safe
|
33
|
+
end
|
34
|
+
|
35
|
+
###############################
|
36
|
+
## Triggering Authentication ##
|
37
|
+
###############################
|
38
|
+
|
39
|
+
# Ask the user for authentication, by either rendering
|
40
|
+
# the login form or redirecting to it
|
41
|
+
#
|
42
|
+
# This method should be called from a controller action
|
43
|
+
# or action filter.
|
44
|
+
#
|
45
|
+
def show!
|
46
|
+
@controller.redirect! @provider.login_path(@controller)
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Mumukit::Login::Framework::Rails
|
2
|
+
|
3
|
+
def self.env(rails_controller)
|
4
|
+
rails_controller.request.env
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.redirect!(path, rails_controller)
|
8
|
+
rails_controller.redirect_to path
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.render_html!(content, rails_controller)
|
12
|
+
rails_controller.render html: content.html_safe, layout: true
|
13
|
+
end
|
14
|
+
|
15
|
+
# Configures the login routes.
|
16
|
+
# This method should be used this way:
|
17
|
+
#
|
18
|
+
# controller :sessions do
|
19
|
+
# Mumukit::Login.configure_session_controller_routes! self
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# @param [RailsRouter] rails_router
|
23
|
+
#
|
24
|
+
def self.configure_login_routes!(rails_router)
|
25
|
+
rails_router.controller :login do
|
26
|
+
rails_router.match 'auth/:provider/callback' => :callback, via: [:get, :post], as: 'auth_callback'
|
27
|
+
rails_router.get 'auth/failure' => :failure
|
28
|
+
rails_router.get 'logout' => :destroy
|
29
|
+
rails_router.get 'login' => :login
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.configure_login_controller!(controller_class)
|
34
|
+
controller_class.class_eval do
|
35
|
+
include Mumukit::Login::LoginControllerHelpers
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Configures forgery protection and mixes authentication methods.
|
40
|
+
#
|
41
|
+
# @param [ActionController::Base::Class] controller_class
|
42
|
+
#
|
43
|
+
def self.configure_controller!(controller_class)
|
44
|
+
Mumukit::Login.config.provider.configure_rails_forgery_protection!(controller_class)
|
45
|
+
controller_class.class_eval do
|
46
|
+
include Mumukit::Login::AuthenticationHelpers
|
47
|
+
|
48
|
+
helper_method :current_user,
|
49
|
+
:current_user?,
|
50
|
+
:current_user_uid,
|
51
|
+
:mumukit_controller,
|
52
|
+
:login_form
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Mumukit::Login::AuthenticationHelpers
|
2
|
+
|
3
|
+
def authenticate!
|
4
|
+
login_form.show! unless current_user?
|
5
|
+
end
|
6
|
+
|
7
|
+
def current_user?
|
8
|
+
current_user_uid.present?
|
9
|
+
end
|
10
|
+
|
11
|
+
def current_user
|
12
|
+
@current_user ||= Mumukit::Login.config.user_class.find_by_uid!(current_user_uid) if current_user?
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
# default
|
18
|
+
def current_user_uid
|
19
|
+
mumukit_controller.session[:user_uid]
|
20
|
+
end
|
21
|
+
|
22
|
+
# default
|
23
|
+
def login_settings
|
24
|
+
Mumukit::Login::Settings.new
|
25
|
+
end
|
26
|
+
|
27
|
+
def mumukit_controller
|
28
|
+
@mumukit_controller ||= Mumukit::Login::Controller.new login_framework, self
|
29
|
+
end
|
30
|
+
|
31
|
+
def login_form
|
32
|
+
@login_builder ||= Mumukit::Login::Form.new login_provider, mumukit_controller, login_settings
|
33
|
+
end
|
34
|
+
|
35
|
+
def origin_redirector
|
36
|
+
@after_login_redirector ||= Mumukit::Login::OriginRedirector.new mumukit_controller
|
37
|
+
end
|
38
|
+
|
39
|
+
def login_framework
|
40
|
+
Mumukit::Login.config.framework
|
41
|
+
end
|
42
|
+
|
43
|
+
def login_provider
|
44
|
+
Mumukit::Login.config.provider
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Mumukit::Login::LoginControllerHelpers
|
2
|
+
|
3
|
+
def login
|
4
|
+
origin_redirector.save_location!
|
5
|
+
login_provider.request_authentication! mumukit_controller, login_settings
|
6
|
+
end
|
7
|
+
|
8
|
+
def callback
|
9
|
+
profile = Mumukit::Login::Profile.from_omniauth(env['omniauth.auth'])
|
10
|
+
user = Mumukit::Login.config.user_class.for_profile profile
|
11
|
+
save_session_user_uid! user
|
12
|
+
origin_redirector.redirect!
|
13
|
+
end
|
14
|
+
|
15
|
+
def destroy
|
16
|
+
destroy_session_user_uid!
|
17
|
+
mumukit_controller.redirect! login_provider.logout_redirection_path
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# default
|
23
|
+
def destroy_session_user_uid!
|
24
|
+
mumukit_controller.session[:user_uid] = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
# default
|
28
|
+
def save_session_user_uid!(user)
|
29
|
+
mumukit_controller.session[:user_uid] = user.uid
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Mumukit::Login::OriginRedirector
|
2
|
+
def initialize(controller)
|
3
|
+
@controller = controller
|
4
|
+
end
|
5
|
+
|
6
|
+
def redirect!
|
7
|
+
location = @controller.session[:redirect_after_login]
|
8
|
+
@controller.session[:redirect_after_login] = nil
|
9
|
+
@controller.redirect!(location || '/')
|
10
|
+
end
|
11
|
+
|
12
|
+
def save_location!
|
13
|
+
@controller.session[:redirect_after_login] = Addressable::URI.heuristic_parse(origin).path
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def origin
|
19
|
+
@controller.request.params['origin']
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Mumukit::Login::Profile
|
2
|
+
def self.from_omniauth(omniauth)
|
3
|
+
struct provider: omniauth.provider,
|
4
|
+
name: omniauth.info.nickname || omniauth.info.name,
|
5
|
+
social_id: omniauth.uid,
|
6
|
+
email: omniauth.info.email,
|
7
|
+
uid: omniauth.info.email || omniauth.uid,
|
8
|
+
image_url: omniauth.info.image
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Mumukit::Login::Provider
|
2
|
+
def self.from_env
|
3
|
+
parse_login_provider(login_provider_string).tap do |provider|
|
4
|
+
puts "[Mumukit::Login] Using #{provider} as login provider"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.login_provider_string
|
9
|
+
if ENV['MUMUKI_LOGIN_PROVIDER'].blank? || ENV['RACK_ENV'] == 'test' || ENV['RAILS_ENV'] == 'test'
|
10
|
+
'developer'
|
11
|
+
else
|
12
|
+
ENV['MUMUKI_LOGIN_PROVIDER']
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.parse_login_provider(login_provider)
|
17
|
+
case login_provider
|
18
|
+
when 'developer'
|
19
|
+
Mumukit::Login::Provider::Developer.new
|
20
|
+
when 'saml'
|
21
|
+
Mumukit::Login::Provider::Saml.new
|
22
|
+
when 'auth0'
|
23
|
+
Mumukit::Login::Provider::Auth0.new
|
24
|
+
else
|
25
|
+
raise "Unknown login_provider `#{login_provider}`"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
require_relative './provider/base'
|
31
|
+
require_relative './provider/saml'
|
32
|
+
require_relative './provider/auth0'
|
33
|
+
require_relative './provider/developer'
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class Mumukit::Login::Provider::Auth0 < Mumukit::Login::Provider::Base
|
2
|
+
def configure_omniauth!(omniauth)
|
3
|
+
omniauth.provider :auth0,
|
4
|
+
auth0_config.client_id,
|
5
|
+
auth0_config.client_secret,
|
6
|
+
auth0_config.domain,
|
7
|
+
callback_path: callback_path
|
8
|
+
end
|
9
|
+
|
10
|
+
def request_authentication!(controller, login_settings)
|
11
|
+
settings = lock_settings(controller, login_settings, {closable: false})
|
12
|
+
controller.render_html! <<HTML
|
13
|
+
<script type="text/javascript">
|
14
|
+
new Auth0Lock('#{auth0_config.client_id}', '#{auth0_config.domain}').show(#{settings});
|
15
|
+
</script>
|
16
|
+
HTML
|
17
|
+
end
|
18
|
+
|
19
|
+
def header_html(*)
|
20
|
+
<<HTML
|
21
|
+
<script src="https://cdn.auth0.com/js/lock-7.12.min.js"></script>
|
22
|
+
</script>
|
23
|
+
HTML
|
24
|
+
end
|
25
|
+
|
26
|
+
def footer_html(*)
|
27
|
+
'<a href="https://auth0.com/" target="_blank">
|
28
|
+
<img height="40" alt="JWT Auth for open source projects" src="//cdn.auth0.com/oss/badges/a0-badge-light.png"/>
|
29
|
+
</a>'
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def auth0_config
|
35
|
+
Mumukit::Login.config.auth0
|
36
|
+
end
|
37
|
+
|
38
|
+
def lock_settings(controller, login_settings, options)
|
39
|
+
login_settings.to_lock_json(controller.url_for(callback_path), options)
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class Mumukit::Login::Provider::Base
|
2
|
+
def name
|
3
|
+
@name ||= self.class.name.demodulize.downcase
|
4
|
+
end
|
5
|
+
|
6
|
+
required :configure_omniauth!
|
7
|
+
|
8
|
+
def request_authentication!(controller, _login_settings)
|
9
|
+
controller.redirect! auth_path
|
10
|
+
end
|
11
|
+
|
12
|
+
def configure_rails_forgery_protection!(action_controller)
|
13
|
+
action_controller.protect_from_forgery with: :exception
|
14
|
+
end
|
15
|
+
|
16
|
+
def login_path(controller)
|
17
|
+
"/login?origin=#{controller.request.path}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def auth_path
|
21
|
+
"/auth/#{name}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def callback_path
|
25
|
+
"/auth/#{name}/callback"
|
26
|
+
end
|
27
|
+
|
28
|
+
def logout_redirection_path
|
29
|
+
'/'
|
30
|
+
end
|
31
|
+
|
32
|
+
def button_html(controller, title, clazz)
|
33
|
+
%Q{<a class="#{clazz}" href="#{login_path(controller)}">#{title}</a>}
|
34
|
+
end
|
35
|
+
|
36
|
+
def footer_html(*)
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def header_html(*)
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Mumukit::Login::Provider::Saml < Mumukit::Login::Provider::Base
|
2
|
+
def saml_config
|
3
|
+
Mumukit::Login.config.saml
|
4
|
+
end
|
5
|
+
|
6
|
+
def configure_omniauth!(omniauth)
|
7
|
+
omniauth.provider :saml,
|
8
|
+
# TODO: change the :assertion_consumer_service_url, the :issuer and the :slo_default_relay_state:
|
9
|
+
# => 1. we can not call any Organization method since there is none instantiated yet and
|
10
|
+
# => 2. we must use the absolut path to generate the right SAML metadata to set up the federation with the IdP
|
11
|
+
assertion_consumer_service_url: "#{saml_config.base_url}#{callback_path}",
|
12
|
+
single_logout_service_url: "#{saml_config.base_url}#{auth_path}/slo",
|
13
|
+
issuer: "#{saml_config.base_url}#{auth_path}",
|
14
|
+
idp_sso_target_url: saml_config.idp_sso_target_url,
|
15
|
+
idp_slo_target_url: saml_config.idp_slo_target_url,
|
16
|
+
slo_default_relay_state: saml_config.base_url,
|
17
|
+
idp_cert: File.read('./saml.crt'),
|
18
|
+
attribute_service_name: 'Mumuki',
|
19
|
+
request_attributes: [
|
20
|
+
{name: 'email', name_format: 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic', friendly_name: 'Email address'},
|
21
|
+
{name: 'name', name_format: 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic', friendly_name: 'Full name'},
|
22
|
+
{name: 'image', name_format: 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic', friendly_name: 'Avatar image'}
|
23
|
+
],
|
24
|
+
attribute_statements: {
|
25
|
+
name: [saml_config.translaton_name],
|
26
|
+
email: [saml_config.translaton_email],
|
27
|
+
image: [saml_config.translaton_image]
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def configure_rails_forgery_protection!(_controller_class)
|
32
|
+
# FIXME this is big security issue
|
33
|
+
# Do nothing (do not protect): the IdP calls the assertion_url via POST and without the CSRF token
|
34
|
+
end
|
35
|
+
|
36
|
+
def logout_redirection_path
|
37
|
+
"#{auth_path}/spslo"
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
|
2
|
+
class Mumukit::Login::Settings
|
3
|
+
LOCK_LOGIN_METHODS = {
|
4
|
+
facebook: 'facebook',
|
5
|
+
github: 'github',
|
6
|
+
google: 'google-oauth2',
|
7
|
+
twitter: 'twitter',
|
8
|
+
user_pass: 'Username-Password-Authentication'
|
9
|
+
}
|
10
|
+
|
11
|
+
attr_accessor :login_methods
|
12
|
+
|
13
|
+
def initialize(login_methods = Mumukit::Login::Settings.default_methods)
|
14
|
+
@login_methods = login_methods.map(&:to_sym)
|
15
|
+
end
|
16
|
+
|
17
|
+
def many_methods?
|
18
|
+
user_pass? && social_login_methods.size > 1
|
19
|
+
end
|
20
|
+
|
21
|
+
def user_pass?
|
22
|
+
login_methods.include? :user_pass
|
23
|
+
end
|
24
|
+
|
25
|
+
def social_login_methods
|
26
|
+
login_methods - [:user_pass]
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_lock_json(callback_url, options={})
|
30
|
+
lock_json
|
31
|
+
.merge(callbackURL: callback_url, responseType: 'code', authParams: {scope: 'openid profile'})
|
32
|
+
.merge(options)
|
33
|
+
.to_json
|
34
|
+
.html_safe
|
35
|
+
end
|
36
|
+
|
37
|
+
def lock_json
|
38
|
+
{dict: I18n.locale,
|
39
|
+
connections: lock_login_methods,
|
40
|
+
icon: '/logo-alt.png',
|
41
|
+
socialBigButtons: !many_methods?,
|
42
|
+
disableResetAction: false}
|
43
|
+
end
|
44
|
+
|
45
|
+
def lock_login_methods
|
46
|
+
login_methods.map { |it| LOCK_LOGIN_METHODS[it] }
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.login_methods
|
50
|
+
LOCK_LOGIN_METHODS.keys
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.default_methods
|
54
|
+
[:user_pass]
|
55
|
+
end
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mumukit-login
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Franco Leonardo Bulgarelli
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: codeclimate-test-reporter
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rack
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.5'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.5'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: addressable
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: omniauth
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.2'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.2'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: omniauth-auth0
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.1'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.1'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: omniauth-saml
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '1.6'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '1.6'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: mumukit-core
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0.5'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0.5'
|
167
|
+
description:
|
168
|
+
email:
|
169
|
+
- franco@mumuki.org
|
170
|
+
executables: []
|
171
|
+
extensions: []
|
172
|
+
extra_rdoc_files: []
|
173
|
+
files:
|
174
|
+
- lib/mumukit/login.rb
|
175
|
+
- lib/mumukit/login/controller.rb
|
176
|
+
- lib/mumukit/login/form.rb
|
177
|
+
- lib/mumukit/login/framework.rb
|
178
|
+
- lib/mumukit/login/framework/rails.rb
|
179
|
+
- lib/mumukit/login/helpers.rb
|
180
|
+
- lib/mumukit/login/helpers/authentication_helpers.rb
|
181
|
+
- lib/mumukit/login/helpers/login_controller_helpers.rb
|
182
|
+
- lib/mumukit/login/origin_redirector.rb
|
183
|
+
- lib/mumukit/login/profile.rb
|
184
|
+
- lib/mumukit/login/provider.rb
|
185
|
+
- lib/mumukit/login/provider/auth0.rb
|
186
|
+
- lib/mumukit/login/provider/base.rb
|
187
|
+
- lib/mumukit/login/provider/developer.rb
|
188
|
+
- lib/mumukit/login/provider/saml.rb
|
189
|
+
- lib/mumukit/login/settings.rb
|
190
|
+
- lib/mumukit/login/version.rb
|
191
|
+
homepage: http://github.com/mumuki/mumukit-login
|
192
|
+
licenses:
|
193
|
+
- MIT
|
194
|
+
metadata: {}
|
195
|
+
post_install_message:
|
196
|
+
rdoc_options: []
|
197
|
+
require_paths:
|
198
|
+
- lib
|
199
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
200
|
+
requirements:
|
201
|
+
- - ">="
|
202
|
+
- !ruby/object:Gem::Version
|
203
|
+
version: '0'
|
204
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
requirements: []
|
210
|
+
rubyforge_project:
|
211
|
+
rubygems_version: 2.5.1
|
212
|
+
signing_key:
|
213
|
+
specification_version: 4
|
214
|
+
summary: Library for login mumuki requests
|
215
|
+
test_files: []
|