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
[64195] Create SharePoint's OAuthConfiguration (#19605)
Marcello Rochaeae94d52c163
diff --git a/modules/storages/app/common/storages/adapters/providers/share_point/base.rb b/modules/storages/app/common/storages/adapters/providers/share_point/base.rbnew file mode 100644index 00000000000..515dcc20320--- /dev/null+++ b/modules/storages/app/common/storages/adapters/providers/share_point/base.rb@@ -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.+#++++module Storages+ module Adapters+ module Providers+ module SharePoint+ class Base+ include TaggedLogging+ include Dry::Monads::Result(Results::Error)++ # @param storage [Storages::SharePointStorage]+ # @param auth_strategy [Result(Input::Strategy)]+ # @param input_data [Data]+ # @return [Success, Failure(Results::Error)]+ def self.call(storage:, auth_strategy:, input_data:)+ new(storage).call(auth_strategy:, input_data:)+ end++ # @param storage [Storages::SharePointStorage]+ def initialize(storage)+ @storage = storage+ end++ private++ # @param error [Results::Error]+ # @return [void]+ def log_storage_error(error, context = {})+ data = case error.payload+ in { status: Integer }+ { status: error.payload&.status, body: error.payload&.body.to_s }+ else+ error.payload.to_s+ end++ error_message = context.merge({ error_code: error.code, data: })+ error error_message+ end+ end+ end+ end+ end+enddiff --git a/modules/storages/app/common/storages/adapters/providers/share_point/oauth_configuration.rb b/modules/storages/app/common/storages/adapters/providers/share_point/oauth_configuration.rbnew file mode 100644index 00000000000..af3c43b4c9c--- /dev/null+++ b/modules/storages/app/common/storages/adapters/providers/share_point/oauth_configuration.rb@@ -0,0 +1,39 @@+# 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.+#++++module Storages+ module Adapters+ module Providers+ module SharePoint+ OAuthConfiguration = Providers::OneDrive::OAuthConfiguration+ end+ end+ end+enddiff --git a/modules/storages/app/common/storages/adapters/providers/share_point/share_point_registry.rb b/modules/storages/app/common/storages/adapters/providers/share_point/share_point_registry.rbnew file mode 100644index 00000000000..937d832a049--- /dev/null+++ b/modules/storages/app/common/storages/adapters/providers/share_point/share_point_registry.rb@@ -0,0 +1,44 @@+# 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.+#++++module Storages+ module Adapters+ module Providers+ module SharePoint+ SharePointRegistry = Dry::Container::Namespace.new("share_point") do+ namespace("authentication") do+ register(:userless, ->(use_cache = true) { Input::Strategy.build(key: :oauth_client_credentials, use_cache:) })+ register(:user_bound, ->(user, storage = nil) { Input::Strategy.build(key: :oauth_user_token, user:, storage:) })+ end+ end+ end+ end+ end+enddiff --git a/modules/storages/app/common/storages/adapters/registry.rb b/modules/storages/app/common/storages/adapters/registry.rbindex 646de98100c..8830aee615b 100644--- a/modules/storages/app/common/storages/adapters/registry.rb+++ b/modules/storages/app/common/storages/adapters/registry.rb@@ -60,8 +60,9 @@ module Storagesconfig.resolver = Resolver.new# Need to make this dynamic to ease new providers to be registered- import Providers::OneDrive::OneDriveRegistryimport Providers::Nextcloud::NextcloudRegistry+ import Providers::OneDrive::OneDriveRegistry+ import Providers::SharePoint::SharePointRegistryendendenddiff --git a/modules/storages/app/models/storages/share_point_storage.rb b/modules/storages/app/models/storages/share_point_storage.rbindex bd9bf7f2579..2eb504a6b2e 100644--- a/modules/storages/app/models/storages/share_point_storage.rb+++ b/modules/storages/app/models/storages/share_point_storage.rb@@ -1,6 +1,31 @@# 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.#++module Storages@@ -22,8 +47,9 @@ module Storagesendend+ def oauth_configuration = Adapters::Providers::SharePoint::OAuthConfiguration.new(self)+# To implement- # oauth_configuration# configuration_checks# automatic_management_new_record?# provider_fields_defaults