|
|
@ -40,14 +40,14 @@ module OmniAuth |
|
|
|
|
|
|
|
|
|
|
|
module FlexibleStrategy |
|
|
|
module FlexibleStrategy |
|
|
|
def on_auth_path? |
|
|
|
def on_auth_path? |
|
|
|
(match_provider! || false) && super |
|
|
|
possible_auth_path? && (match_provider! || false) && super |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
## |
|
|
|
## |
|
|
|
# Tries to match the request path of the current request with one of the registered providers. |
|
|
|
# Tries to match the request path of the current request with one of the registered providers. |
|
|
|
# If a match is found the strategy is intialised with that provider to handle the request. |
|
|
|
# If a match is found the strategy is intialised with that provider to handle the request. |
|
|
|
def match_provider! |
|
|
|
def match_provider! |
|
|
|
return false unless @providers |
|
|
|
return false unless providers |
|
|
|
|
|
|
|
|
|
|
|
@provider = providers.find do |p| |
|
|
|
@provider = providers.find do |p| |
|
|
|
(current_path =~ /#{path_for_provider(p.to_hash[:name])}/) == 0 |
|
|
|
(current_path =~ /#{path_for_provider(p.to_hash[:name])}/) == 0 |
|
|
@ -72,6 +72,13 @@ module OmniAuth |
|
|
|
"#{path_prefix}/#{name}" |
|
|
|
"#{path_prefix}/#{name}" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## |
|
|
|
|
|
|
|
# Returns true if the current path could be an authentication request, |
|
|
|
|
|
|
|
# false otherwise (e.g. for resources). |
|
|
|
|
|
|
|
def possible_auth_path? |
|
|
|
|
|
|
|
current_path =~ /\A#{path_prefix}/ |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def providers |
|
|
|
def providers |
|
|
|
@providers ||= OpenProject::Plugins::AuthPlugin.providers_for(self.class) |
|
|
|
@providers ||= OpenProject::Plugins::AuthPlugin.providers_for(self.class) |
|
|
|
end |
|
|
|
end |
|
|
@ -87,7 +94,6 @@ module OmniAuth |
|
|
|
def dup |
|
|
|
def dup |
|
|
|
super.tap do |s| |
|
|
|
super.tap do |s| |
|
|
|
s.extend FlexibleStrategy |
|
|
|
s.extend FlexibleStrategy |
|
|
|
s.providers = providers |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|