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
Require an enterprise plan for nextcloud SSO authentication
Jan Sandbrink0933bfa908d3
diff --git a/Gemfile b/Gemfileindex e23ea0f32fc..9bee54144a9 100644--- a/Gemfile+++ b/Gemfile@@ -201,7 +201,7 @@ gem "aws-sdk-core", "~> 3.107"# File upload via fog + screenshots on travisgem "aws-sdk-s3", "~> 1.91"-gem "openproject-token", "~> 5.3.0"+gem "openproject-token", "~> 5.4.0"gem "plaintext", "~> 0.3.2"diff --git a/Gemfile.lock b/Gemfile.lockindex 8e702fdfbda..60bbbc6f6e2 100644--- a/Gemfile.lock+++ b/Gemfile.lock@@ -865,7 +865,7 @@ GEMactivesupport (>= 7.1.0)openproject-octicons (>= 19.25.0)view_component (>= 3.1, < 4.0)- openproject-token (5.3.0)+ openproject-token (5.4.0)activemodelopenssl (3.3.0)openssl-signature_algorithm (1.3.0)@@ -1453,7 +1453,7 @@ DEPENDENCIESopenproject-reporting!openproject-storages!openproject-team_planner!- openproject-token (~> 5.3.0)+ openproject-token (~> 5.4.0)openproject-two_factor_authentication!openproject-webhooks!openproject-xls_export!@@ -1824,7 +1824,7 @@ CHECKSUMSopenproject-reporting (1.0.0)openproject-storages (1.0.0)openproject-team_planner (1.0.0)- openproject-token (5.3.0) sha256=5fe2f33992e6bd8926ef56c44afd098ac868bd91b07f4abff5577c171663901a+ openproject-token (5.4.0) sha256=0054e24adaaaa5d7e23cc09108d2c34f6a73c7687e300be23ffd970d509bde93openproject-two_factor_authentication (1.0.0)openproject-webhooks (1.0.0)openproject-xls_export (1.0.0)diff --git a/app/assets/images/enterprise/nextcloud-sso-authentication.png b/app/assets/images/enterprise/nextcloud-sso-authentication.pngnew file mode 100644index 00000000000..65da457890dBinary files /dev/null and b/app/assets/images/enterprise/nextcloud-sso-authentication.png differdiff --git a/config/locales/en.yml b/config/locales/en.ymlindex 44405e749df..2c7b53865a2 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1218,6 +1218,7 @@ en:error_conflict: "Information has been updated by at least one other user in the meantime."email: "is not a valid email address."empty: "can't be empty."+ enterprise_plan_required: "requires at least the %{plan_name}."even: "must be even."exclusion: "is reserved."feature_disabled: is not available.@@ -2075,6 +2076,7 @@ en:edit_attribute_groups: Edit Attribute Groupsgantt_pdf_export: Gantt PDF Exportldap_groups: LDAP users and group sync+ nextcloud_sso: Single Sign-On for Nextcloud Storageone_drive_sharepoint_file_storage: OneDrive/SharePoint File Storageplaceholder_users: Placeholder Usersproject_list_sharing: Project List Sharing@@ -2123,6 +2125,9 @@ en:custom_actions:title: "Custom actions"description: "Custom actions are one-click shortcuts to a set of pre-defined actions that you can make available on certain work packages based on status, role, type or project."+ nextcloud_sso:+ title: "Single Sign-On for Nextcloud Storage"+ description: "Enable seamless and secure authentication for your Nextcloud storage with Single Sign-On. Simplify access management and enhance user convenience."virus_scanning:description: "Ensure uploaded files in OpenProject are scanned for viruses before being accessible by other users."placeholder_users:diff --git a/config/static_links.yml b/config/static_links.ymlindex 43a91cd09dd..e0d657f8250 100644--- a/config/static_links.yml+++ b/config/static_links.yml@@ -157,6 +157,8 @@ enterprise_features:href: https://www.openproject.org/docs/system-admin-guide/custom-fields/#hierarchy-custom-field-enterprise-add-oninternal_comments:href: https://www.openproject.org/docs/user-guide/activity/#work-package-activity+ nextcloud_sso:+ href: https://www.openproject.org/docs/system-admin-guide/integrations/nextcloud/oidc-ssosysadmin_docs:saml:href: https://www.openproject.org/docs/system-admin-guide/authentication/saml/diff --git a/modules/storages/app/components/storages/admin/forms/general_info_form_component.html.erb b/modules/storages/app/components/storages/admin/forms/general_info_form_component.html.erbindex 048aeb1a5a3..16ef4f502a1 100644--- a/modules/storages/app/components/storages/admin/forms/general_info_form_component.html.erb+++ b/modules/storages/app/components/storages/admin/forms/general_info_form_component.html.erb@@ -35,6 +35,10 @@general_info_row.with_row(mb: 3) dorender(Storages::Admin::NextcloudAuthenticationMethodInputForm.new(form))end++ general_info_row.with_row(mb: 3) do+ render(EnterpriseEdition::BannerComponent.new(:nextcloud_sso, variant: :medium, image: "enterprise/nextcloud-sso-authentication.png"))+ endendif storage.provider_type_one_drive?diff --git a/modules/storages/app/contracts/storages/storages/nextcloud_general_information_contract.rb b/modules/storages/app/contracts/storages/storages/nextcloud_general_information_contract.rbindex a9c4a8c673b..3903440a4b0 100644--- a/modules/storages/app/contracts/storages/storages/nextcloud_general_information_contract.rb+++ b/modules/storages/app/contracts/storages/storages/nextcloud_general_information_contract.rb@@ -40,5 +40,16 @@ module Storages::Storagesattribute :authentication_methodvalidates :authentication_method, presence: true, inclusion: { in: ::Storages::NextcloudStorage::AUTHENTICATION_METHODS }++ validate :require_ee_token_for_sso++ def require_ee_token_for_sso+ return if EnterpriseToken.allows_to?(:nextcloud_sso)+ return unless model.authenticate_via_idp?+ return unless model.authentication_method_changed?++ plan_name = I18n.t("ee.upsell.plan_name", plan: OpenProject::Token.lowest_plan_for(:nextcloud_sso)&.capitalize)+ errors.add(:authentication_method, :enterprise_plan_required, plan_name:)+ endendenddiff --git a/modules/storages/app/forms/storages/admin/nextcloud_authentication_method_input_form.rb b/modules/storages/app/forms/storages/admin/nextcloud_authentication_method_input_form.rbindex 9a5b13464c4..623e3309ee5 100644--- a/modules/storages/app/forms/storages/admin/nextcloud_authentication_method_input_form.rb+++ b/modules/storages/app/forms/storages/admin/nextcloud_authentication_method_input_form.rb@@ -40,7 +40,11 @@ module Storages::Admininput_width: :large) do |list|::Storages::NextcloudStorage::AUTHENTICATION_METHODS.each do |m|- list.option(label: I18n.t("activerecord.attributes.storages/nextcloud_storage.authentication_methods.#{m}"), value: m)+ disabled = !EnterpriseToken.allows_to?(:nextcloud_sso) &&+ m != ::Storages::NextcloudStorage::AUTHENTICATION_METHOD_TWO_WAY_OAUTH2+ list.option label: I18n.t("activerecord.attributes.storages/nextcloud_storage.authentication_methods.#{m}"),+ value: m,+ disabled:endendenddiff --git a/modules/storages/spec/contracts/storages/storages/nextcloud_contract_spec.rb b/modules/storages/spec/contracts/storages/storages/nextcloud_contract_spec.rbindex d99745ee0c4..c27283dcfe6 100644--- a/modules/storages/spec/contracts/storages/storages/nextcloud_contract_spec.rb+++ b/modules/storages/spec/contracts/storages/storages/nextcloud_contract_spec.rb@@ -158,7 +158,19 @@ RSpec.describe Storages::Storages::NextcloudContract, :storage_server_helpers, :before { storage.storage_audience = "valid_audience" }- it { is_expected.to be_valid }+ it { is_expected.not_to be_valid }++ context "and there is a valid enterprise token", with_ee: [:nextcloud_sso] do+ it { is_expected.to be_valid }+ end++ context "and the authentication_method has been oauth2_sso before" do+ before do+ storage.save! # storage is already persisted with this auth method+ end++ it { is_expected.to be_valid }+ endendcontext "when the authentication method is unknown" do@@ -195,7 +207,7 @@ RSpec.describe Storages::Storages::NextcloudContract, :storage_server_helpers, :endend- context "when authentication happens through a common IDP" do+ context "when authentication happens through a common IDP", with_ee: [:nextcloud_sso] dolet(:authentication_method) { "oauth2_sso" }context "and there is no storage_audience" dodiff --git a/modules/storages/spec/features/storages/admin/create_storage_spec.rb b/modules/storages/spec/features/storages/admin/create_storage_spec.rbindex 866303b780e..ce0354b9971 100644--- a/modules/storages/spec/features/storages/admin/create_storage_spec.rb+++ b/modules/storages/spec/features/storages/admin/create_storage_spec.rb@@ -91,6 +91,9 @@ RSpec.describe "Admin Create a new file storage",aggregate_failures "General information" dowithin_test_selector("storage-general-info-form") do+ expect(page).to have_enterprise_banner(:corporate)+ expect(page).to have_css("option:disabled[value=oauth2_sso]") # expect SSO option to be disabled+fill_in "Name", with: "My Nextcloud", fill_options: { clear: :backspace }click_on "Save and continue"@@ -189,7 +192,7 @@ RSpec.describe "Admin Create a new file storage",endend- it "renders a Nextcloud specific multi-step form when using OAuth 2.0 SSO", :webmock do+ it "renders a Nextcloud specific multi-step form when using OAuth 2.0 SSO", :webmock, with_ee: [:nextcloud_sso] do# Same setup as in default case, but without expectationsvisit admin_settings_storages_path@@ -199,6 +202,8 @@ RSpec.describe "Admin Create a new file storage",endwithin_test_selector("storage-general-info-form") do+ expect(page).not_to have_enterprise_banner+fill_in "Name", with: "My Nextcloud", fill_options: { clear: :backspace }mock_server_capabilities_response("https://example.com")diff --git a/modules/storages/spec/features/storages/admin/edit_storage_spec.rb b/modules/storages/spec/features/storages/admin/edit_storage_spec.rbindex e3f214f1d58..7f1201dd58b 100644--- a/modules/storages/spec/features/storages/admin/edit_storage_spec.rb+++ b/modules/storages/spec/features/storages/admin/edit_storage_spec.rb@@ -112,6 +112,9 @@ RSpec.describe "Admin Edit File storage",# Update a storage - happy pathfind_test_selector("storage-edit-host-button").clickwithin_test_selector("storage-general-info-form") do+ expect(page).to have_enterprise_banner(:corporate)+ expect(page).to have_css("option:disabled[value=oauth2_sso]") # expect SSO option to be disabled+fill_in "Name", with: "My Nextcloud"click_on "Save and continue"end@@ -288,6 +291,14 @@ RSpec.describe "Admin Edit File storage",# Only testing interaction with components not tested# in Two-Way OAuth 2.0 case+ aggregate_failures "General information" do+ find_test_selector("storage-edit-host-button").click+ within_test_selector("storage-general-info-form") do+ # We use a previously configured SSO storage, even though our current token does not support it+ expect(page).to have_enterprise_banner(:corporate)+ end+ end+aggregate_failures "Storage Audience" dofind_test_selector("storage-edit-storage-audience-button").clickwithin_test_selector("storage-audience-form") do@@ -356,6 +367,17 @@ RSpec.describe "Admin Edit File storage",)endend++ context "and when there is an appropriate enterprise token", with_ee: [:nextcloud_sso] do+ it "shows no enterprise banner", :webmock do+ visit edit_admin_settings_storage_path(storage)++ find_test_selector("storage-edit-host-button").click+ within_test_selector("storage-general-info-form") do+ expect(page).not_to have_enterprise_banner+ end+ end+ endendcontext "with Nextcloud Storage and not automatically managed" dodiff --git a/modules/storages/spec/requests/api/v3/storages/storages_api_spec.rb b/modules/storages/spec/requests/api/v3/storages/storages_api_spec.rbindex 5623c226a80..901fe3117e2 100644--- a/modules/storages/spec/requests/api/v3/storages/storages_api_spec.rb+++ b/modules/storages/spec/requests/api/v3/storages/storages_api_spec.rb@@ -190,7 +190,7 @@ RSpec.describe "API v3 storages resource", :storage_server_helpers, :webmock, coendend- context "when creating a storage for SSO authentication" do+ context "when creating a storage for SSO authentication", with_ee: [:nextcloud_sso] dolet(:params) dosuper().tap do |p|p[:storageAudience] = "the-audience"@@ -206,6 +206,16 @@ RSpec.describe "API v3 storages resource", :storage_server_helpers, :webmock, coexpect(Storages::NextcloudStorage.last.authentication_method).to eq("oauth2_sso")expect(Storages::NextcloudStorage.last.storage_audience).to eq("the-audience")end++ context "and when the instance lacks a valid enterprise token", with_ee: [] do+ it "indicates an HTTP error" do+ expect(last_response).to have_http_status(422)+ end++ it "creates no storage" do+ expect { last_response }.not_to change(Storages::NextcloudStorage, :count)+ end+ endendend