-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
56 changed files
with
2,085 additions
and
789 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
db/migrate/20240829140616_migrate_oidc_settings_to_providers.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# frozen_string_literal: true | ||
|
||
#-- 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. | ||
#++ | ||
|
||
class MigrateOidcSettingsToProviders < ActiveRecord::Migration[7.1] | ||
def up | ||
providers = Hash(Setting.plugin_openproject_openid_connect).with_indifferent_access[:providers] | ||
return if providers.blank? | ||
|
||
providers.each do |name, configuration| | ||
configuration.delete(:name) | ||
migrate_provider!(name, configuration) | ||
end | ||
end | ||
|
||
def down | ||
# This migration does not yet remove Setting.plugin_openproject_openid_connect | ||
# so it can be retried. | ||
end | ||
|
||
private | ||
|
||
def migrate_provider!(name, configuration) | ||
Rails.logger.debug { "Trying to migrate OpenID provider #{name} from previous settings format..." } | ||
call = ::OpenIDConnect::SyncService.new(name, configuration).call | ||
|
||
if call.success | ||
Rails.logger.debug { <<~SUCCESS } | ||
Successfully migrated OpenID provider #{name} from previous settings format. | ||
You can now manage this provider in the new administrative UI within OpenProject under | ||
the "Administration -> Authentication -> OpenID providers" section. | ||
SUCCESS | ||
else | ||
raise <<~ERROR | ||
Failed to create or update OpenID provider #{name} from previous settings format. | ||
The error message was: #{call.message} | ||
Please check the logs for more information and open a bug report in our community: | ||
https://www.openproject.org/docs/development/report-a-bug/ | ||
If you would like to skip migrating the OpenID provider setting and discard them instead, you can use our documentation | ||
to unset any previous OpenID provider settings: | ||
https://www.openproject.org/docs/system-admin-guide/authentication/openid-providers/ | ||
ERROR | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+6.33 KB
modules/openid_connect/app/assets/images/openid_connect/auth_provider-custom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-1.22 KB
modules/openid_connect/app/assets/images/openid_connect/auth_provider-heroku.png
Binary file not shown.
40 changes: 40 additions & 0 deletions
40
modules/openid_connect/app/components/openid_connect/providers/base_form.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#-- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2012-2024 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. | ||
#++ | ||
|
||
module OpenIDConnect | ||
module Providers | ||
class BaseForm < ApplicationForm | ||
attr_reader :provider | ||
|
||
def initialize(provider:) | ||
super() | ||
@provider = provider | ||
end | ||
end | ||
end | ||
end |
53 changes: 53 additions & 0 deletions
53
modules/openid_connect/app/components/openid_connect/providers/client_details_form.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#-- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2012-2024 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. | ||
#++ | ||
|
||
module OpenIDConnect | ||
module Providers | ||
class ClientDetailsForm < BaseForm | ||
form do |f| | ||
%i[client_id client_secret].each do |attr| | ||
f.text_field( | ||
name: attr, | ||
label: I18n.t("activemodel.attributes.openid_connect/provider.#{attr}"), | ||
caption: I18n.t("openid_connect.instructions.#{attr}"), | ||
disabled: provider.seeded_from_env?, | ||
required: true, | ||
input_width: :large | ||
) | ||
end | ||
f.check_box( | ||
name: :limit_self_registration, | ||
label: I18n.t("activemodel.attributes.openid_connect/provider.limit_self_registration"), | ||
caption: I18n.t("openid_connect.instructions.limit_self_registration"), | ||
disabled: provider.seeded_from_env?, | ||
required: true | ||
) | ||
end | ||
end | ||
end | ||
end |
45 changes: 45 additions & 0 deletions
45
modules/openid_connect/app/components/openid_connect/providers/metadata_details_form.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#-- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2012-2024 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. | ||
#++ | ||
|
||
module OpenIDConnect | ||
module Providers | ||
class MetadataDetailsForm < BaseForm | ||
form do |f| | ||
OpenIDConnect::Provider::DISCOVERABLE_ATTRIBUTES_ALL.each do |attr| | ||
f.text_field( | ||
name: attr, | ||
label: I18n.t("activemodel.attributes.openid_connect/provider.#{attr}"), | ||
disabled: provider.seeded_from_env?, | ||
required: OpenIDConnect::Provider::DISCOVERABLE_ATTRIBUTES_MANDATORY.include?(attr), | ||
input_width: :large | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
58 changes: 58 additions & 0 deletions
58
modules/openid_connect/app/components/openid_connect/providers/metadata_options_form.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#-- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2012-2024 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. | ||
#++ | ||
|
||
module OpenIDConnect | ||
module Providers | ||
class MetadataOptionsForm < BaseForm | ||
form do |f| | ||
f.radio_button_group( | ||
name: "metadata", | ||
scope_name_to_model: false, | ||
disabled: provider.seeded_from_env?, | ||
visually_hide_label: true | ||
) do |radio_group| | ||
radio_group.radio_button( | ||
value: "none", | ||
checked: @provider.metadata_url.blank?, | ||
label: I18n.t("openid_connect.settings.metadata_none"), | ||
disabled: provider.seeded_from_env?, | ||
data: { "show-when-value-selected-target": "cause" } | ||
) | ||
|
||
radio_group.radio_button( | ||
value: "url", | ||
checked: @provider.metadata_url.present?, | ||
label: I18n.t("openid_connect.settings.metadata_url"), | ||
disabled: provider.seeded_from_env?, | ||
data: { "show-when-value-selected-target": "cause" } | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
44 changes: 44 additions & 0 deletions
44
modules/openid_connect/app/components/openid_connect/providers/metadata_url_form.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#-- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2012-2024 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. | ||
#++ | ||
|
||
module OpenIDConnect | ||
module Providers | ||
class MetadataUrlForm < BaseForm | ||
form do |f| | ||
f.text_field( | ||
name: :metadata_url, | ||
label: I18n.t("openid_connect.settings.endpoint_url"), | ||
required: false, | ||
disabled: provider.seeded_from_env?, | ||
caption: I18n.t("openid_connect.instructions.endpoint_url"), | ||
input_width: :xlarge | ||
) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.