diff --git a/modules/openid_connect/app/contracts/openid_connect/providers/base_contract.rb b/modules/openid_connect/app/contracts/openid_connect/providers/base_contract.rb index 8c7df80628a5..e61b68fd0d40 100644 --- a/modules/openid_connect/app/contracts/openid_connect/providers/base_contract.rb +++ b/modules/openid_connect/app/contracts/openid_connect/providers/base_contract.rb @@ -60,7 +60,6 @@ def self.model url: { allow_blank: true, allow_nil: true, schemes: %w[http https] }, if: -> { model.post_logout_redirect_uri_changed? } - OpenIDConnect::Provider::MAPPABLE_ATTRIBUTES.each do |attr| attribute :"mapping_#{attr}" end diff --git a/modules/openid_connect/app/services/openid_connect/configuration_mapper.rb b/modules/openid_connect/app/services/openid_connect/configuration_mapper.rb index 546916d048bb..5ee45847c192 100644 --- a/modules/openid_connect/app/services/openid_connect/configuration_mapper.rb +++ b/modules/openid_connect/app/services/openid_connect/configuration_mapper.rb @@ -35,7 +35,7 @@ def initialize(configuration) end def call! # rubocop:disable Metrics/AbcSize - options = mapped_options(configuration.deep_stringify_keys) + options = configuration.deep_stringify_keys { "slug" => options["name"], @@ -57,7 +57,12 @@ def call! # rubocop:disable Metrics/AbcSize "token_endpoint" => extract_url(options, "token_endpoint"), "userinfo_endpoint" => extract_url(options, "userinfo_endpoint"), "end_session_endpoint" => extract_url(options, "end_session_endpoint"), - "jwks_uri" => extract_url(options, "jwks_uri") + "jwks_uri" => extract_url(options, "jwks_uri"), + "mapping_login" => options.dig("attribute_map", "login"), + "mapping_mail" => options.dig("attribute_map", "email"), + "mapping_firstname" => options.dig("attribute_map", "first_name"), + "mapping_lastname" => options.dig("attribute_map", "last_name"), + "mapping_admin" => options.dig("attribute_map", "admin") }.compact end @@ -102,21 +107,5 @@ def base_url(options) scheme: options["scheme"] || "https" ).to_s end - - def mapped_options(options) - extract_mapping(options) - - options.compact - end - - def extract_mapping(options) - return unless options["attribute_map"] - - options["mapping_login"] = options["attribute_map"]["login"] - options["mapping_mail"] = options["attribute_map"]["email"] - options["mapping_firstname"] = options["attribute_map"]["first_name"] - options["mapping_lastname"] = options["attribute_map"]["last_name"] - options["mapping_admin"] = options["attribute_map"]["admin"] - end end end