Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Setup providers

Oliver Günther150d5d1f5b26
diff --git a/modules/auth_plugins/lib/omni_auth/flexible_strategy.rb b/modules/auth_plugins/lib/omni_auth/flexible_strategy.rb
index 0ed4caee53f..1584fe66308 100644
--- a/modules/auth_plugins/lib/omni_auth/flexible_strategy.rb
+++ b/modules/auth_plugins/lib/omni_auth/flexible_strategy.rb
@@ -41,7 +41,7 @@ module OmniAuth
return false unless providers
@provider = providers.find do |p|
- (current_path =~ /#{path_for_provider(p.to_hash[:name])}/) == 0
+ current_path.match?(/#{path_for_provider(p.to_hash[:name])}(\/|\s*$)/)
end
if @provider
diff --git a/modules/auth_saml/app/models/saml/provider.rb b/modules/auth_saml/app/models/saml/provider.rb
index 3c7578fa455..e2011c17f9e 100644
--- a/modules/auth_saml/app/models/saml/provider.rb
+++ b/modules/auth_saml/app/models/saml/provider.rb
@@ -62,6 +62,11 @@ module Saml
idp_cert.present?
end
+ def assertion_consumer_service_url
+ root_url = OpenProject::StaticRouting::StaticUrlHelpers.new.root_url
+ URI.join(root_url, "/auth/#{slug}/callback").to_s
+ end
+
def to_h
options
.merge(
@@ -72,6 +77,7 @@ module Saml
check_sp_cert_expiration: true,
metadata_signed: true
)
+ .symbolize_keys
end
end
end
diff --git a/modules/auth_saml/lib/open_project/auth_saml/engine.rb b/modules/auth_saml/lib/open_project/auth_saml/engine.rb
index 34242d2b032..92e445ce864 100644
--- a/modules/auth_saml/lib/open_project/auth_saml/engine.rb
+++ b/modules/auth_saml/lib/open_project/auth_saml/engine.rb
@@ -3,7 +3,9 @@ module OpenProject
module AuthSaml
def self.configuration
RequestStore.fetch(:openproject_omniauth_saml_provider) do
- global_configuration.deep_merge(settings_from_db)
+ global_configuration
+ .deep_merge(settings_from_db)
+ .deep_merge(settings_from_providers)
end
end
@@ -18,20 +20,18 @@ module OpenProject
@global_configuration ||= Hash(settings_from_config || settings_from_yaml).with_indifferent_access
end
+ def self.settings_from_providers
+ Saml::Provider.all.each_with_object({}) do |provider, hash|
+ hash[provider.slug] = provider.to_h
+ end
+ end
+
def self.settings_from_db
value = Hash(Setting.plugin_openproject_auth_saml).with_indifferent_access[:providers]
value.is_a?(Hash) ? value : {}
end
- def self.providers
- configuration.map do |name, config|
- config['name'] = name
- readonly = global_configuration.keys.include?(name)
- ::Saml::Provider.new(readonly:, **config)
- end
- end
-
def self.settings_from_config
if OpenProject::Configuration["saml"].present?
Rails.logger.info("[auth_saml] Registering saml integration from configuration.yml")
@@ -62,8 +62,8 @@ module OpenProject
:plugin_saml,
:saml_providers_path,
parent: :authentication,
- caption: ->(*) { I18n.t('saml.menu_title') },
- enterprise_feature: 'openid_providers'
+ caption: ->(*) { I18n.t("saml.menu_title") },
+ enterprise_feature: "openid_providers"
end
assets %w(