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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Feature spec
Oliver Günther6fe5456dc972
diff --git a/modules/openid_connect/app/components/openid_connect/providers/view_component.html.erb b/modules/openid_connect/app/components/openid_connect/providers/view_component.html.erbindex 3291270d85f..2c6e794ee0a 100644--- a/modules/openid_connect/app/components/openid_connect/providers/view_component.html.erb+++ b/modules/openid_connect/app/components/openid_connect/providers/view_component.html.erb@@ -165,7 +165,7 @@edit_state:,next_edit_state: :client_details,edit_mode:,- banner: provider.metadata_configured? ? t("openid_connect.providers.section_texts.configuration_metadata") : nil,+ banner: provider.metadata_url.present? ? t("openid_connect.providers.section_texts.configuration_metadata") : nil,banner_scheme: :default,heading: nil))diff --git a/modules/openid_connect/app/models/openid_connect/provider.rb b/modules/openid_connect/app/models/openid_connect/provider.rbindex d6faaed5d0c..05e6e196097 100644--- a/modules/openid_connect/app/models/openid_connect/provider.rb+++ b/modules/openid_connect/app/models/openid_connect/provider.rb@@ -44,6 +44,8 @@ module OpenIDConnectenddef metadata_configured?+ return false unless metadata_url.present?+DISCOVERABLE_ATTRIBUTES_MANDATORY.all? do |mandatory_attribute|public_send(mandatory_attribute).present?enddiff --git a/modules/openid_connect/app/services/openid_connect/providers/update_service.rb b/modules/openid_connect/app/services/openid_connect/providers/update_service.rbindex b3f0fe25e00..689f73bae2f 100644--- a/modules/openid_connect/app/services/openid_connect/providers/update_service.rb+++ b/modules/openid_connect/app/services/openid_connect/providers/update_service.rb@@ -50,7 +50,8 @@ module OpenIDConnectjson = beginresponse.jsonrescue HTTPX::Error- call.errors.add(:metadata_url, :response_is_json)+ binding.pry+ call.errors.add(:metadata_url, :response_is_not_json)call.success = falseendresult = AttributesContract.new.call(json)diff --git a/modules/openid_connect/config/locales/en.yml b/modules/openid_connect/config/locales/en.ymlindex 4a7bfe91dab..5ab34f68ef5 100644--- a/modules/openid_connect/config/locales/en.yml+++ b/modules/openid_connect/config/locales/en.yml@@ -66,9 +66,11 @@ en:name: Microsoft Entracustom:name: Custom+ upsale:+ description: Connect OpenProject to an OpenID connect identity providerlabel_add_new: Add a new OpenID providerlabel_edit: Edit OpenID provider %{name}- label_empty_title: No OIDC providers configured yet.+ label_empty_title: No OpenID providers configured yet.label_empty_description: Add a provider to see them here.label_metadata: OpenID Connect Discovery Endpointlabel_automatic_configuration: Automatic configurationdiff --git a/modules/openid_connect/spec/features/administration/oidc_custom_crud_spec.rb b/modules/openid_connect/spec/features/administration/oidc_custom_crud_spec.rbnew file mode 100644index 00000000000..05b8c23b15a--- /dev/null+++ b/modules/openid_connect/spec/features/administration/oidc_custom_crud_spec.rb@@ -0,0 +1,156 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require "spec_helper"+require_module_spec_helper++RSpec.describe "OIDC administration CRUD",+ :js,+ :with_cuprite do+ shared_let(:user) { create(:admin) }++ before do+ login_as(user)+ end++ context "with EE", with_ee: %i[sso_auth_providers] do+ it "can manage OIDC providers through the UI" do+ visit "/admin/openid_connect/providers"+ expect(page).to have_text "No OpenID providers configured yet."+ click_link_or_button "OpenID provider"+ click_link_or_button "Custom"++ fill_in "Display name", with: "My provider"+ click_link_or_button "Continue"++ # Skip metadata+ click_link_or_button "Continue"++ # Fill out configuration+ fill_in "Authorization endpoint", with: "https://example.com/sso"+ fill_in "User information endpoint", with: "https://example.com/sso/userinfo"+ fill_in "Token endpoint", with: "https://example.com/sso/token"+ fill_in "Issuer", with: "foobar"++ click_link_or_button "Continue"++ # Client credentials+ fill_in "Client ID", with: "client_id"+ fill_in "Client secret", with: "client secret"++ click_link_or_button "Continue"++ # Mapping form+ fill_in "Mapping for: Username", with: "login"+ fill_in "Mapping for: Email", with: "mail"+ fill_in "Mapping for: First name", with: "myName"+ fill_in "Mapping for: Last name", with: "myLastName"+ click_link_or_button "Finish setup"++ # We're now on the show page+ within_test_selector("openid_connect_provider_metadata") do+ expect(page).to have_text "Not configured"+ end++ # Back to index+ visit "/admin/openid_connect/providers"+ expect(page).to have_text "My provider"+ expect(page).to have_css(".users", text: 0)+ expect(page).to have_css(".creator", text: user.name)++ click_link_or_button "My provider"++ provider = OpenIDConnect::Provider.find_by!(display_name: "My provider")+ expect(provider.slug).to eq "oidc-my-provider"+ expect(provider.authorization_endpoint).to eq "https://example.com/sso"+ expect(provider.token_endpoint).to eq "https://example.com/sso/token"+ expect(provider.userinfo_endpoint).to eq "https://example.com/sso/userinfo"++ expect(provider.issuer).to eq "foobar"+ expect(provider.client_id).to eq "client_id"+ expect(provider.client_secret).to eq "client secret"++ expect(provider.mapping_login).to eq "login"+ expect(provider.mapping_email).to eq "mail"+ expect(provider.mapping_first_name).to eq "myName"+ expect(provider.mapping_last_name).to eq "myLastName"++ accept_confirm do+ click_link_or_button "Delete"+ end++ expect(page).to have_text "No OpenID providers configured yet."+ end++ it "can import metadata from URL", :webmock do+ visit "/admin/openid_connect/providers"++ click_link_or_button "OpenID provider"+ click_link_or_button "Custom"++ fill_in "Display name", with: "My provider"+ click_link_or_button "Continue"++ url = "https://example.com/metadata"+ metadata = Rails.root.join("modules/openid_connect/spec/fixtures/keycloak_localhost.json").read+ stub_request(:get, url).to_return(status: 200, body: metadata, headers: { "Content-Type" => "application/json" })++ choose "I have a discovery endpoint URL"+ fill_in "openid_connect_provider_metadata_url", with: url++ click_link_or_button "Continue"+ expect(page).to have_text "The information has been pre-filled using the supplied discovery endpoint."+ expect(page).to have_field "Authorization endpoint", with: "http://localhost:8080/realms/test/protocol/openid-connect/auth"+ expect(page).to have_field "Token endpoint", with: "http://localhost:8080/realms/test/protocol/openid-connect/token"+ expect(page).to have_field "User information endpoint", with: "http://localhost:8080/realms/test/protocol/openid-connect/userinfo"+ expect(page).to have_field "End session endpoint", with: "http://localhost:8080/realms/test/protocol/openid-connect/logout"+ expect(page).to have_field "Issuer", with: "http://localhost:8080/realms/test"++ expect(WebMock).to have_requested(:get, url)+ end++ context "when provider exists already" do+ let!(:provider) { create(:oidc_provider, display_name: "My provider") }++ it "shows an error trying to use the same name" do+ visit "/admin/openid_connect/providers/new"+ fill_in "Display name", with: "My provider"+ click_link_or_button "Continue"++ expect(page).to have_text "Display name has already been taken."+ end+ end+ end++ context "without EE", without_ee: %i[sso_auth_providers] do+ it "renders the upsale page" do+ visit "/admin/openid_connect/providers"+ expect(page).to have_text "OpenID providers is an Enterprise add-on"+ end+ end+enddiff --git a/modules/openid_connect/spec/fixtures/keycloak_localhost.json b/modules/openid_connect/spec/fixtures/keycloak_localhost.jsonnew file mode 100644index 00000000000..af264638159--- /dev/null+++ b/modules/openid_connect/spec/fixtures/keycloak_localhost.json@@ -0,0 +1,290 @@+{+ "issuer": "http://localhost:8080/realms/test",+ "authorization_endpoint": "http://localhost:8080/realms/test/protocol/openid-connect/auth",+ "token_endpoint": "http://localhost:8080/realms/test/protocol/openid-connect/token",+ "introspection_endpoint": "http://localhost:8080/realms/test/protocol/openid-connect/token/introspect",+ "userinfo_endpoint": "http://localhost:8080/realms/test/protocol/openid-connect/userinfo",+ "end_session_endpoint": "http://localhost:8080/realms/test/protocol/openid-connect/logout",+ "frontchannel_logout_session_supported": true,+ "frontchannel_logout_supported": true,+ "jwks_uri": "http://localhost:8080/realms/test/protocol/openid-connect/certs",+ "check_session_iframe": "http://localhost:8080/realms/test/protocol/openid-connect/login-status-iframe.html",+ "grant_types_supported": [+ "authorization_code",+ "implicit",+ "refresh_token",+ "password",+ "client_credentials",+ "urn:ietf:params:oauth:grant-type:device_code",+ "urn:openid:params:grant-type:ciba"+ ],+ "acr_values_supported": [+ "0",+ "1"+ ],+ "response_types_supported": [+ "code",+ "none",+ "id_token",+ "token",+ "id_token token",+ "code id_token",+ "code token",+ "code id_token token"+ ],+ "subject_types_supported": [+ "public",+ "pairwise"+ ],+ "id_token_signing_alg_values_supported": [+ "PS384",+ "ES384",+ "RS384",+ "HS256",+ "HS512",+ "ES256",+ "RS256",+ "HS384",+ "ES512",+ "PS256",+ "PS512",+ "RS512"+ ],+ "id_token_encryption_alg_values_supported": [+ "RSA-OAEP",+ "RSA-OAEP-256",+ "RSA1_5"+ ],+ "id_token_encryption_enc_values_supported": [+ "A256GCM",+ "A192GCM",+ "A128GCM",+ "A128CBC-HS256",+ "A192CBC-HS384",+ "A256CBC-HS512"+ ],+ "userinfo_signing_alg_values_supported": [+ "PS384",+ "ES384",+ "RS384",+ "HS256",+ "HS512",+ "ES256",+ "RS256",+ "HS384",+ "ES512",+ "PS256",+ "PS512",+ "RS512",+ "none"+ ],+ "userinfo_encryption_alg_values_supported": [+ "RSA-OAEP",+ "RSA-OAEP-256",+ "RSA1_5"+ ],+ "userinfo_encryption_enc_values_supported": [+ "A256GCM",+ "A192GCM",+ "A128GCM",+ "A128CBC-HS256",+ "A192CBC-HS384",+ "A256CBC-HS512"+ ],+ "request_object_signing_alg_values_supported": [+ "PS384",+ "ES384",+ "RS384",+ "HS256",+ "HS512",+ "ES256",+ "RS256",+ "HS384",+ "ES512",+ "PS256",+ "PS512",+ "RS512",+ "none"+ ],+ "request_object_encryption_alg_values_supported": [+ "RSA-OAEP",+ "RSA-OAEP-256",+ "RSA1_5"+ ],+ "request_object_encryption_enc_values_supported": [+ "A256GCM",+ "A192GCM",+ "A128GCM",+ "A128CBC-HS256",+ "A192CBC-HS384",+ "A256CBC-HS512"+ ],+ "response_modes_supported": [+ "query",+ "fragment",+ "form_post",+ "query.jwt",+ "fragment.jwt",+ "form_post.jwt",+ "jwt"+ ],+ "registration_endpoint": "http://localhost:8080/realms/test/clients-registrations/openid-connect",+ "token_endpoint_auth_methods_supported": [+ "private_key_jwt",+ "client_secret_basic",+ "client_secret_post",+ "tls_client_auth",+ "client_secret_jwt"+ ],+ "token_endpoint_auth_signing_alg_values_supported": [+ "PS384",+ "ES384",+ "RS384",+ "HS256",+ "HS512",+ "ES256",+ "RS256",+ "HS384",+ "ES512",+ "PS256",+ "PS512",+ "RS512"+ ],+ "introspection_endpoint_auth_methods_supported": [+ "private_key_jwt",+ "client_secret_basic",+ "client_secret_post",+ "tls_client_auth",+ "client_secret_jwt"+ ],+ "introspection_endpoint_auth_signing_alg_values_supported": [+ "PS384",+ "ES384",+ "RS384",+ "HS256",+ "HS512",+ "ES256",+ "RS256",+ "HS384",+ "ES512",+ "PS256",+ "PS512",+ "RS512"+ ],+ "authorization_signing_alg_values_supported": [+ "PS384",+ "ES384",+ "RS384",+ "HS256",+ "HS512",+ "ES256",+ "RS256",+ "HS384",+ "ES512",+ "PS256",+ "PS512",+ "RS512"+ ],+ "authorization_encryption_alg_values_supported": [+ "RSA-OAEP",+ "RSA-OAEP-256",+ "RSA1_5"+ ],+ "authorization_encryption_enc_values_supported": [+ "A256GCM",+ "A192GCM",+ "A128GCM",+ "A128CBC-HS256",+ "A192CBC-HS384",+ "A256CBC-HS512"+ ],+ "claims_supported": [+ "aud",+ "sub",+ "iss",+ "auth_time",+ "name",+ "given_name",+ "family_name",+ "preferred_username",+ "email",+ "acr"+ ],+ "claim_types_supported": [+ "normal"+ ],+ "claims_parameter_supported": true,+ "scopes_supported": [+ "openid",+ "email",+ "roles",+ "microprofile-jwt",+ "web-origins",+ "profile",+ "offline_access",+ "phone",+ "address",+ "acr"+ ],+ "request_parameter_supported": true,+ "request_uri_parameter_supported": true,+ "require_request_uri_registration": true,+ "code_challenge_methods_supported": [+ "plain",+ "S256"+ ],+ "tls_client_certificate_bound_access_tokens": true,+ "revocation_endpoint": "http://localhost:8080/realms/test/protocol/openid-connect/revoke",+ "revocation_endpoint_auth_methods_supported": [+ "private_key_jwt",+ "client_secret_basic",+ "client_secret_post",+ "tls_client_auth",+ "client_secret_jwt"+ ],+ "revocation_endpoint_auth_signing_alg_values_supported": [+ "PS384",+ "ES384",+ "RS384",+ "HS256",+ "HS512",+ "ES256",+ "RS256",+ "HS384",+ "ES512",+ "PS256",+ "PS512",+ "RS512"+ ],+ "backchannel_logout_supported": true,+ "backchannel_logout_session_supported": true,+ "device_authorization_endpoint": "http://localhost:8080/realms/test/protocol/openid-connect/auth/device",+ "backchannel_token_delivery_modes_supported": [+ "poll",+ "ping"+ ],+ "backchannel_authentication_endpoint": "http://localhost:8080/realms/test/protocol/openid-connect/ext/ciba/auth",+ "backchannel_authentication_request_signing_alg_values_supported": [+ "PS384",+ "ES384",+ "RS384",+ "ES256",+ "RS256",+ "ES512",+ "PS256",+ "PS512",+ "RS512"+ ],+ "require_pushed_authorization_requests": false,+ "pushed_authorization_request_endpoint": "http://localhost:8080/realms/test/protocol/openid-connect/ext/par/request",+ "mtls_endpoint_aliases": {+ "token_endpoint": "http://localhost:8080/realms/test/protocol/openid-connect/token",+ "revocation_endpoint": "http://localhost:8080/realms/test/protocol/openid-connect/revoke",+ "introspection_endpoint": "http://localhost:8080/realms/test/protocol/openid-connect/token/introspect",+ "device_authorization_endpoint": "http://localhost:8080/realms/test/protocol/openid-connect/auth/device",+ "registration_endpoint": "http://localhost:8080/realms/test/clients-registrations/openid-connect",+ "userinfo_endpoint": "http://localhost:8080/realms/test/protocol/openid-connect/userinfo",+ "pushed_authorization_request_endpoint": "http://localhost:8080/realms/test/protocol/openid-connect/ext/par/request",+ "backchannel_authentication_endpoint": "http://localhost:8080/realms/test/protocol/openid-connect/ext/ciba/auth"+ }+}