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
Storage Health Check: Check for presence of an OIDC IdP (#17884)
Marcello Rochabccdbaee0543
diff --git a/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rb b/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rbindex 5cf220ef915..883e585ecb1 100644--- a/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rb+++ b/modules/storages/app/common/storages/peripherals/nextcloud_connection_validator.rb@@ -54,10 +54,26 @@ module Storagesprivate+ def sso_misconfigured+ return None() unless @storage.authenticate_via_idp?++ openid_connect_idp_absent+ end++ def openid_connect_idp_absent+ return None() if OpenIDConnect::Provider.any?++ Some(ConnectionValidation.new(type: :error,+ error_code: :oidc_provider_missing,+ timestamp: Time.current,+ description: I18n.t("storages.health.connection_validation.oidc_provider_missing")))+ end+def has_base_configuration_error?host_url_not_found.or { missing_dependencies }.or { version_mismatch }+ .or { sso_misconfigured }.or { with_unexpected_content }.or { capabilities_request_failed_with_unknown_error }enddiff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.ymlindex 2ddc071ed56..81c6f90af78 100644--- a/modules/storages/config/locales/en.yml+++ b/modules/storages/config/locales/en.yml@@ -223,6 +223,7 @@ en:host_not_found: No Nextcloud server found at the configured host url. Please check the configuration.missing_dependencies: 'A required dependency is missing on the file storage. Please add the following dependency: %{dependency}.'not_configured: The connection could not be validated. Please finish configuration first.+ oidc_provider_missing: There is no OpenID Connect Identity Provider configured.placeholder: Check your connection against the server.subtitle: Connection validationtenant_id_wrong: The configured directory (tenant) id is invalid. Please check the configuration.diff --git a/modules/storages/spec/common/storages/peripherals/nextcloud_connection_validator_spec.rb b/modules/storages/spec/common/storages/peripherals/nextcloud_connection_validator_spec.rbindex 2a72da8c9ef..2b1dcc7d00d 100644--- a/modules/storages/spec/common/storages/peripherals/nextcloud_connection_validator_spec.rb+++ b/modules/storages/spec/common/storages/peripherals/nextcloud_connection_validator_spec.rb@@ -230,6 +230,31 @@ RSpec.describe Storages::Peripherals::NextcloudConnectionValidator doendend+ context "when OpenID Connect is enabled" do+ let(:storage) { create(:nextcloud_storage_configured, :oidc_enabled) }+ let(:app_version) { Storages::SemanticVersion.parse("2.6.3") }+ let(:capabilities_response) do+ ServiceResult.success(result: Storages::NextcloudCapabilities.new(+ app_enabled?: true,+ app_version:,+ group_folder_enabled?: false,+ group_folder_version: nil+ ))+ end++ it "succeeds when a provider is available" do+ create(:oidc_provider)++ expect(subject.type).to eq(:healthy)+ end++ it "errors if no Provider is available" do+ expect(subject.type).to eq(:error)+ expect(subject.error_code).to eq(:oidc_provider_missing)+ expect(subject.description).to eq(I18n.t("storages.health.connection_validation.oidc_provider_missing"))+ end+ end+privatedef build_failure(code:, payload:)diff --git a/modules/storages/spec/contracts/storages/storages/nextcloud_contract_spec.rb b/modules/storages/spec/contracts/storages/storages/nextcloud_contract_spec.rbindex 8499a238cba..a2fee562eb4 100644--- a/modules/storages/spec/contracts/storages/storages/nextcloud_contract_spec.rb+++ b/modules/storages/spec/contracts/storages/storages/nextcloud_contract_spec.rb@@ -156,6 +156,8 @@ RSpec.describe Storages::Storages::NextcloudContract, :storage_server_helpers, :context "when the authentication method is oauth2_sso" dolet(:authentication_method) { "oauth2_sso" }+ before { storage.nextcloud_audience = "valid_audience" }+it { is_expected.to be_valid }enddiff --git a/modules/storages/spec/factories/storage_factory.rb b/modules/storages/spec/factories/storage_factory.rbindex 8dae7ab0714..5571b532653 100644--- a/modules/storages/spec/factories/storage_factory.rb+++ b/modules/storages/spec/factories/storage_factory.rb@@ -92,7 +92,12 @@ FactoryBot.define doprovider_type { Storages::Storage::PROVIDER_TYPE_NEXTCLOUD }sequence(:host) { |n| "https://host#{n}.example.com/" }authentication_method { "two_way_oauth2" }- nextcloud_audience { "nextcloud" }+ nextcloud_audience { nil }++ trait :oidc_enabled do+ nextcloud_audience { "nextcloud" }+ authentication_method { "oauth2_sso" }+ endtrait :as_automatically_managed doautomatic_management_enabled { true }