static op/authentication

pull/10420/head
ulferts 3 years ago
parent 3492d08fdd
commit 49471bbd66
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 16
      config/application.rb
  2. 8
      config/initializers/00-load_plugins.rb
  3. 44
      config/initializers/warden.rb
  4. 26
      lib_static/open_project/authentication.rb
  5. 0
      lib_static/open_project/authentication/failure_app.rb
  6. 0
      lib_static/open_project/authentication/manager.rb
  7. 0
      lib_static/open_project/authentication/session_expiry.rb
  8. 0
      lib_static/open_project/authentication/strategies/warden/anonymous_fallback.rb
  9. 0
      lib_static/open_project/authentication/strategies/warden/basic_auth_failure.rb
  10. 0
      lib_static/open_project/authentication/strategies/warden/doorkeeper_oauth.rb
  11. 0
      lib_static/open_project/authentication/strategies/warden/global_basic_auth.rb
  12. 0
      lib_static/open_project/authentication/strategies/warden/session.rb
  13. 0
      lib_static/open_project/authentication/strategies/warden/user_basic_auth.rb
  14. 18
      modules/bim/lib/open_project/bim/engine.rb

@ -39,18 +39,6 @@ ActiveSupport::Deprecation.silenced =
(Rails.env.test? && ENV['CI'])
if defined?(Bundler)
# lib directory has to be added to the load path so that
# the open_project/plugins files can be found (places under lib).
# Now it would be possible to remove that and use require with
# lib included but some plugins already use
#
# require 'open_project/plugins'
#
# to ensure the code to be loaded. So we provide a compatibility
# layer here. One might remove this later.
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
require 'open_project/plugins'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups(:opf_plugins))
@ -103,6 +91,10 @@ module OpenProject
config.paths.add Rails.root.join('lib').to_s, eager_load: true
config.paths.add Rails.root.join('lib/constraints').to_s, eager_load: true
# Constants in lib_static should only be loaded once and never be unloaded.
# That directory contains configurations and patches to rails core functionality.
config.autoload_once_paths << Rails.root.join('lib_static').to_s
# Use our own error rendering for prettier error pages
config.exceptions_app = routes

@ -28,14 +28,6 @@
# TODO: check if this can be postponed and if some plugins can make use of the ActiveSupport.on_load hooks
require Rails.root.join('lib_static/redmine/i18n')
require Rails.root.join('lib_static/redmine/diff')
require Rails.root.join('lib_static/redmine/diff/diffable')
require Rails.root.join('lib_static/redmine/diff/array_string_diff')
require Rails.root.join('lib_static/plugins/load_path_helper')
require Rails.root.join('lib_static/open_project/notifications')
# Loads the core plugins located in lib_static/plugins
Dir.glob(Rails.root.join('lib_static/plugins/*')).each do |directory|
if File.directory?(directory)

@ -1,32 +1,20 @@
require 'open_project/authentication'
Rails.application.config.after_initialize do
WS = OpenProject::Authentication::Strategies::Warden
# Strategies provided by OpenProject:
require 'open_project/authentication/strategies/warden/basic_auth_failure'
require 'open_project/authentication/strategies/warden/global_basic_auth'
require 'open_project/authentication/strategies/warden/user_basic_auth'
require 'open_project/authentication/strategies/warden/doorkeeper_oauth'
require 'open_project/authentication/strategies/warden/session'
strategies = [
[:basic_auth_failure, WS::BasicAuthFailure, 'Basic'],
[:global_basic_auth, WS::GlobalBasicAuth, 'Basic'],
[:user_basic_auth, WS::UserBasicAuth, 'Basic'],
[:oauth, WS::DoorkeeperOAuth, 'OAuth'],
[:anonymous_fallback, WS::AnonymousFallback, 'Basic'],
[:session, WS::Session, 'Session']
]
WS = OpenProject::Authentication::Strategies::Warden
strategies.each do |name, clazz, auth_scheme|
OpenProject::Authentication.add_strategy name, clazz, auth_scheme
end
strategies = [
[:basic_auth_failure, WS::BasicAuthFailure, 'Basic'],
[:global_basic_auth, WS::GlobalBasicAuth, 'Basic'],
[:user_basic_auth, WS::UserBasicAuth, 'Basic'],
[:oauth, WS::DoorkeeperOAuth, 'OAuth'],
[:anonymous_fallback, WS::AnonymousFallback, 'Basic'],
[:session, WS::Session, 'Session']
]
strategies.each do |name, clazz, auth_scheme|
OpenProject::Authentication.add_strategy name, clazz, auth_scheme
end
include OpenProject::Authentication::Scope
api_v3_options = {
store: false
}
OpenProject::Authentication.update_strategies(API_V3, api_v3_options) do |_strategies|
%i[global_basic_auth user_basic_auth basic_auth_failure oauth session anonymous_fallback]
OpenProject::Authentication.update_strategies(OpenProject::Authentication::Scope::API_V3, { store: false }) do |_|
%i[global_basic_auth user_basic_auth basic_auth_failure oauth session anonymous_fallback]
end
end

@ -1,3 +1,29 @@
# OpenProject is an open source project management software.
# Copyright (C) 2022 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.
require 'open_project/authentication/manager'
module OpenProject

@ -199,16 +199,18 @@ module OpenProject::Bim
Mime::Type.register "application/octet-stream", :bcfzip unless Mime::Type.lookup_by_extension(:bcfzip)
end
initializer 'bim.bcf.add_api_scope' do
Doorkeeper.configuration.scopes.add(:bcf_v2_1)
initializer 'bim.bcf.add_api_scope' do |app|
app.config.before_initialize do
Doorkeeper.configuration.scopes.add(:bcf_v2_1)
module OpenProject::Authentication::Scope
BCF_V2_1 = :bcf_v2_1
end
module OpenProject::Authentication::Scope
BCF_V2_1 = :bcf_v2_1
end
OpenProject::Authentication.update_strategies(OpenProject::Authentication::Scope::BCF_V2_1,
store: false) do |_strategies|
%i[oauth session]
OpenProject::Authentication.update_strategies(OpenProject::Authentication::Scope::BCF_V2_1,
store: false) do |_strategies|
%i[oauth session]
end
end
end

Loading…
Cancel
Save