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

Extend form validation

Oliver Güntherdb8283017c6c
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 e4efc55cdd0..03f909a67bc 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
@@ -46,6 +46,31 @@ module OpenIDConnect
validates :metadata_url,
url: { allow_blank: true, allow_nil: true, schemes: %w[http https] },
if: -> { model.metadata_url_changed? }
+
+ attribute :authorization_endpoint
+ validates :authorization_endpoint,
+ url: { allow_blank: false, allow_nil: false, schemes: %w[http https] },
+ if: -> { model.authorization_endpoint_changed? }
+
+ attribute :userinfo_endpoint
+ validates :userinfo_endpoint,
+ url: { allow_blank: true, allow_nil: true, schemes: %w[http https] },
+ if: -> { model.userinfo_endpoint_changed? }
+
+ attribute :token_endpoint
+ validates :token_endpoint,
+ url: { allow_blank: true, allow_nil: true, schemes: %w[http https] },
+ if: -> { model.token_endpoint_changed? }
+
+ attribute :end_session_endpoint
+ validates :end_session_endpoint,
+ url: { allow_blank: true, allow_nil: true, schemes: %w[http https] },
+ if: -> { model.end_session_endpoint_changed? }
+
+ attribute :jwks_uri
+ validates :jwks_uri,
+ url: { allow_blank: true, allow_nil: true, schemes: %w[http https] },
+ if: -> { model.jwks_uri_changed? }
end
end
end
diff --git a/modules/openid_connect/app/models/openid_connect/provider.rb b/modules/openid_connect/app/models/openid_connect/provider.rb
index 9d5f5c4c867..dd446950ecb 100644
--- a/modules/openid_connect/app/models/openid_connect/provider.rb
+++ b/modules/openid_connect/app/models/openid_connect/provider.rb
@@ -1,6 +1,6 @@
module OpenIDConnect
class Provider < AuthProvider
- OIDC_PROVIDERS = ["google", "microsoft_entra", "custom"].freeze
+ OIDC_PROVIDERS = %w[google microsoft_entra custom].freeze
DISCOVERABLE_ATTRIBUTES_ALL = %i[authorization_endpoint
userinfo_endpoint
token_endpoint
@@ -8,7 +8,7 @@ module OpenIDConnect
jwks_uri
issuer].freeze
DISCOVERABLE_ATTRIBUTES_OPTIONAL = %i[end_session_endpoint].freeze
- DISCOVERABLE_ATTRIBUTES_MANDATORY = DISCOVERABLE_ATTRIBUTES_ALL - %i[end_session_endpoint]
+ DISCOVERABLE_ATTRIBUTES_MANDATORY = DISCOVERABLE_ATTRIBUTES_ALL - %i[end_session_endpoint jwks_uri]
store_attribute :options, :oidc_provider, :string
store_attribute :options, :metadata_url, :string