Class: Mumukit::Login::Provider::Base
- Inherits:
-
Object
- Object
- Mumukit::Login::Provider::Base
show all
- Defined in:
- lib/mumukit/login/provider/base.rb
Instance Method Summary
collapse
Instance Method Details
#auth_path ⇒ Object
24
25
26
|
# File 'lib/mumukit/login/provider/base.rb', line 24
def auth_path
"/auth/#{name}"
end
|
36
37
38
|
# File 'lib/mumukit/login/provider/base.rb', line 36
def button_html(controller, title, clazz)
%Q{<a class="#{clazz}" href="#{login_path(controller)}">#{title}</a>}
end
|
#callback_path ⇒ Object
28
29
30
|
# File 'lib/mumukit/login/provider/base.rb', line 28
def callback_path
"/auth/#{name}/callback"
end
|
#computed_settings(effective_settings) ⇒ Object
Provider settings that are computed based on effective settings - that is, the default settings merged with the organizations settings.
Override this method in order to provide settings that depend not only on the organization or defaults, but also commputed expressions.
These settings can not be overriden.
74
75
76
|
# File 'lib/mumukit/login/provider/base.rb', line 74
def computed_settings(effective_settings)
{}
end
|
#default_settings ⇒ Object
Default provider settings that come from the environment
Override this method in order to read ENV and in order to provide default settings
These setting can be overriden by organization’s ‘provider_settings` and by the provider’s ‘computed_settings`
63
64
65
|
# File 'lib/mumukit/login/provider/base.rb', line 63
def default_settings
{}
end
|
40
41
42
|
# File 'lib/mumukit/login/provider/base.rb', line 40
def (*)
nil
end
|
44
45
46
|
# File 'lib/mumukit/login/provider/base.rb', line 44
def (*)
nil
end
|
#login_path(controller) ⇒ Object
13
14
15
|
# File 'lib/mumukit/login/provider/base.rb', line 13
def login_path(controller)
create_uri '/login', login_path_params(controller)
end
|
#login_path_params(controller) ⇒ Object
17
18
19
20
21
22
|
# File 'lib/mumukit/login/provider/base.rb', line 17
def login_path_params(controller)
{
origin: create_uri(controller.request.path, controller.request.params),
organization: Mumukit::Platform::Organization.current.name
}
end
|
#logout_redirection_path ⇒ Object
32
33
34
|
# File 'lib/mumukit/login/provider/base.rb', line 32
def logout_redirection_path
'/'
end
|
#name ⇒ Object
3
4
5
|
# File 'lib/mumukit/login/provider/base.rb', line 3
def name
@name ||= self.class.name.demodulize.downcase
end
|
#request_authentication!(controller, _login_settings) ⇒ Object
9
10
11
|
# File 'lib/mumukit/login/provider/base.rb', line 9
def request_authentication!(controller, _login_settings)
controller.redirect! auth_path
end
|
#setup_proc ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'lib/mumukit/login/provider/base.rb', line 48
def setup_proc
proc do |env|
options = env['omniauth.strategy'].options
effective_settings = default_settings.to_h.merge(setup_phase_login_settings(env))
options.merge!(effective_settings)
options.merge!(computed_settings(effective_settings.to_struct))
end
end
|