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

Know when metadata was requested last

Oliver Günther00e165f9dc80
diff --git a/modules/auth_saml/app/components/saml/providers/sections/form_component.html.erb b/modules/auth_saml/app/components/saml/providers/sections/form_component.html.erb
index 4bbd73674b0..5115da16160 100644
--- a/modules/auth_saml/app/components/saml/providers/sections/form_component.html.erb
+++ b/modules/auth_saml/app/components/saml/providers/sections/form_component.html.erb
@@ -14,6 +14,15 @@
end
end
+ if @banner
+ flex.with_row do
+ icon = @banner_scheme == :warning ? :alert : :info
+ render(Primer::Alpha::Banner.new(scheme: @banner_scheme, icon:)) do
+ @banner
+ end
+ end
+ end
+
flex.with_row do
render(@form_class.new(form, provider:))
end
diff --git a/modules/auth_saml/app/components/saml/providers/sections/form_component.rb b/modules/auth_saml/app/components/saml/providers/sections/form_component.rb
index 98e854d4ccf..07cabe0ad1f 100644
--- a/modules/auth_saml/app/components/saml/providers/sections/form_component.rb
+++ b/modules/auth_saml/app/components/saml/providers/sections/form_component.rb
@@ -32,7 +32,9 @@ module Saml::Providers::Sections
class FormComponent < SectionComponent
attr_reader :edit_state, :next_edit_state, :edit_mode
- def initialize(provider, edit_state:, form_class:, heading:, next_edit_state: nil, edit_mode: nil)
+ def initialize(provider, edit_state:, form_class:,
+ heading:, banner: nil, banner_scheme: :info,
+ next_edit_state: nil, edit_mode: nil)
super(provider)
@edit_state = edit_state
@@ -40,6 +42,8 @@ module Saml::Providers::Sections
@edit_mode = edit_mode
@form_class = form_class
@heading = heading
+ @banner = banner
+ @banner_scheme = banner_scheme
end
def url
diff --git a/modules/auth_saml/app/controllers/saml/providers_controller.rb b/modules/auth_saml/app/controllers/saml/providers_controller.rb
index efb09d7aa47..ef4cfce3057 100644
--- a/modules/auth_saml/app/controllers/saml/providers_controller.rb
+++ b/modules/auth_saml/app/controllers/saml/providers_controller.rb
@@ -162,7 +162,7 @@ module Saml
.call
if call.success?
- apply_metadata(call.result)
+ apply_metadata(call.result.compact_blank)
else
@edit_state = :metadata
@@ -171,11 +171,12 @@ module Saml
end
end
- def apply_metadata(params)
- new_options = @provider.options.merge(params.compact_blank)
+ def apply_metadata(params) # rubocop:disable Metrics/AbcSize
+ new_options = @provider.options.merge(params)
+ last_metadata_update = params.blank? ? nil : Time.current
call = Saml::Providers::UpdateService
.new(model: @provider, user: User.current)
- .call({ options: new_options })
+ .call({ options: new_options, last_metadata_update: })
if call.success?
flash[:notice] = I18n.t("saml.metadata_parser.success")
diff --git a/modules/auth_saml/app/models/saml/provider.rb b/modules/auth_saml/app/models/saml/provider.rb
index e2544a5028e..d56d36bffdd 100644
--- a/modules/auth_saml/app/models/saml/provider.rb
+++ b/modules/auth_saml/app/models/saml/provider.rb
@@ -8,6 +8,7 @@ module Saml
store_attribute :options, :name_identifier_format, :string
store_attribute :options, :metadata_url, :string
store_attribute :options, :metadata_xml, :string
+ store_attribute :options, :last_metadata_update, :datetime
store_attribute :options, :idp_sso_service_url, :string
store_attribute :options, :idp_slo_service_url, :string