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
forcing to specify allowed actions when forfeiting authorization check
ulfertsfdbd6b6d5ad0
diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rbindex 7c977c1fd01..a9b2423c55e 100644--- a/app/controllers/account_controller.rb+++ b/app/controllers/account_controller.rb@@ -36,19 +36,19 @@ class AccountController < ApplicationController# prevents login action to be filtered by check_if_login_required application scope filterskip_before_action :check_if_login_required- no_authorization_required! only: %i[login- internal_login- logout- lost_password- register- activate- consent- confirm_consent- decline_consent- stage_success- stage_failure- change_password- auth_source_sso_failed]+ no_authorization_required! :login,+ :internal_login,+ :logout,+ :lost_password,+ :register,+ :activate,+ :consent,+ :confirm_consent,+ :decline_consent,+ :stage_success,+ :stage_failure,+ :change_password,+ :auth_source_sso_failedbefore_action :apply_csp_appends, only: %i[login]before_action :disable_apidiff --git a/app/controllers/angular_controller.rb b/app/controllers/angular_controller.rbindex dc70f86e0c8..40e623c9027 100644--- a/app/controllers/angular_controller.rb+++ b/app/controllers/angular_controller.rb@@ -29,7 +29,7 @@class AngularController < ApplicationControllerbefore_action :require_login- no_authorization_required! only: %i[empty_layout notifications_layout]+ no_authorization_required! :empty_layout, :notifications_layoutdef empty_layout# Frontend will handle renderingdiff --git a/app/controllers/api_docs_controller.rb b/app/controllers/api_docs_controller.rbindex 5a1bec3d2ed..3a78ca1c7a5 100644--- a/app/controllers/api_docs_controller.rb+++ b/app/controllers/api_docs_controller.rb@@ -28,7 +28,7 @@class APIDocsController < ApplicationControllerbefore_action :require_login- no_authorization_required! only: :index+ no_authorization_required! :indexhelper API::APIDocsHelperdiff --git a/app/controllers/colors_controller.rb b/app/controllers/colors_controller.rbindex 569dacf9540..b911b9451cf 100644--- a/app/controllers/colors_controller.rb+++ b/app/controllers/colors_controller.rb@@ -28,7 +28,7 @@class ColorsController < ApplicationControllerbefore_action :require_admin_unless_readonly_api_request- authorization_checked! only: %i[index show new edit create update confirm_destroy destroy]+ authorization_checked! :index, :show, :new, :edit, :create, :update, :confirm_destroy, :destroylayout "admin"diff --git a/app/controllers/concerns/accounts/authorization.rb b/app/controllers/concerns/accounts/authorization.rbindex 8000d6ac766..afcc1f302f6 100644--- a/app/controllers/concerns/accounts/authorization.rb+++ b/app/controllers/concerns/accounts/authorization.rb@@ -144,14 +144,19 @@ module Accounts::Authorizationdef set_authorization_checked_if_covered(*names)return unless METHODS_ENFORCING_AUTHORIZATION.intersect?(names)- authorization_checked!(only: names.last.is_a?(Hash) ? Array(names.last[:only]) : [],- except: names.last.is_a?(Hash) ? Array(names.last[:except]) : [])+ authorization_checked_by_default_action(only: names.last.is_a?(Hash) ? Array(names.last[:only]) : [],+ except: names.last.is_a?(Hash) ? Array(names.last[:except]) : [])end- def no_authorization_required!(only: [], except: [])- only = Array(only)- except = Array(except)+ def no_authorization_required!(*actions)+ raise ArgumentError, "no_authorization_required! needs to have actions specified" unless actions.any?+ authorization_checked_by_default_action(only: actions)+ end++ alias :authorization_checked! :no_authorization_required!++ def authorization_checked_by_default_action(only: [], except: [])# A class_attribute is used so that inheritance works also for defined only/except actions.# But since the only/accept arrays are only modified in place, the same object would be used from the# ApplicationController downwards. So whenever it is detected that the controller the authorization_ensured@@ -165,19 +170,17 @@ module Accounts::Authorizationendend- alias :authorization_checked! :no_authorization_required!-def update_authorization_ensured_on_actions(only: [], except: [])update_authorization_ensured_on_action_only(only)update_authorization_ensured_on_action_except(only, except)enddef update_authorization_ensured_on_action_only(only)- authorization_ensured[:generally_allowed] = true if only.empty?-if only.any?authorization_ensured[:only] += onlyauthorization_ensured[:only].uniq!+ else+ update_authorization_ensured_on_allendenddiff --git a/app/controllers/concerns/accounts/omniauth_login.rb b/app/controllers/concerns/accounts/omniauth_login.rbindex 96a7a447531..c037b28196a 100644--- a/app/controllers/concerns/accounts/omniauth_login.rb+++ b/app/controllers/concerns/accounts/omniauth_login.rb@@ -44,7 +44,7 @@ module Accounts::OmniauthLogincheck_session_lifetime].each { |key| skip_before_action key, only: [:omniauth_login] }- no_authorization_required! only: %i[omniauth_login omniauth_failure]+ no_authorization_required! :omniauth_login, :omniauth_failurehelper :omniauthenddiff --git a/app/controllers/custom_styles_controller.rb b/app/controllers/custom_styles_controller.rbindex 228c47c8343..a8467ed35a7 100644--- a/app/controllers/custom_styles_controller.rb+++ b/app/controllers/custom_styles_controller.rb@@ -42,7 +42,7 @@ class CustomStylesController < ApplicationControllerexcept: UNGUARDED_ACTIONS + %i[upsale]skip_before_action :check_if_login_required,only: UNGUARDED_ACTIONS- no_authorization_required! only: UNGUARDED_ACTIONS+ no_authorization_required! *UNGUARDED_ACTIONSdef show@custom_style = CustomStyle.current || CustomStyle.newdiff --git a/app/controllers/favorites_controller.rb b/app/controllers/favorites_controller.rbindex 3dc66c8bdea..cdc157058e4 100644--- a/app/controllers/favorites_controller.rb+++ b/app/controllers/favorites_controller.rb@@ -29,7 +29,7 @@class FavoritesController < ApplicationControllerbefore_action :find_favored_by_objectbefore_action :require_login- no_authorization_required! only: %i[favorite unfavorite]+ no_authorization_required! :favorite, :unfavoritedef favoriteif @favored.visible?(User.current)diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rbindex ba45fc56000..778ddd6082c 100644--- a/app/controllers/groups_controller.rb+++ b/app/controllers/groups_controller.rb@@ -31,7 +31,7 @@ class GroupsController < ApplicationControllerlayout "admin"before_action :require_admin, except: %i[show]- no_authorization_required! only: %i[show]+ no_authorization_required! :showbefore_action :find_group, only: %i[destroy update show create_memberships destroy_membershipedit_membership add_users]diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rbindex ffcc23bfe19..3eb2c7b2885 100644--- a/app/controllers/help_controller.rb+++ b/app/controllers/help_controller.rb@@ -27,7 +27,7 @@#++class HelpController < ApplicationController- no_authorization_required! only: %i[keyboard_shortcuts text_formatting]+ no_authorization_required! :keyboard_shortcuts, :text_formattingdef keyboard_shortcutsredirect_to OpenProject::Static::Links[:shortcuts][:href]diff --git a/app/controllers/highlighting_controller.rb b/app/controllers/highlighting_controller.rbindex b67442cd91f..e859e429bb8 100644--- a/app/controllers/highlighting_controller.rb+++ b/app/controllers/highlighting_controller.rb@@ -29,7 +29,7 @@class HighlightingController < ApplicationControllerbefore_action :determine_freshnessskip_before_action :check_if_login_required, only: [:styles]- no_authorization_required! only: [:styles]+ no_authorization_required! :stylesdef stylesresponse.content_type = Mime[:css]diff --git a/app/controllers/homescreen_controller.rb b/app/controllers/homescreen_controller.rbindex a989230b62a..92660ae2ada 100644--- a/app/controllers/homescreen_controller.rb+++ b/app/controllers/homescreen_controller.rb@@ -28,7 +28,7 @@class HomescreenController < ApplicationControllerskip_before_action :check_if_login_required, only: [:robots]- no_authorization_required! only: %i[index robots]+ no_authorization_required! :index, :robotslayout "global"diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rbindex 5fbf7e6766f..d7ea7714252 100644--- a/app/controllers/journals_controller.rb+++ b/app/controllers/journals_controller.rb@@ -33,7 +33,7 @@ class JournalsController < ApplicationControllerbefore_action :find_journal,:ensure_permitted,only: [:diff]- authorization_checked! only: %i[diff]+ authorization_checked! :diffaccept_key_auth :indexmenu_item :issuesdiff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rbindex 397afab2373..980c69da2e8 100644--- a/app/controllers/messages_controller.rb+++ b/app/controllers/messages_controller.rb@@ -33,7 +33,7 @@ class MessagesController < ApplicationControllerbefore_action :find_object_and_scopebefore_action :authorize, except: %i[edit update destroy]# Checked inside the method.- no_authorization_required! only: %i[edit update destroy]+ no_authorization_required! :edit, :update, :destroyinclude AttachmentsHelperinclude PaginationHelperdiff --git a/app/controllers/my/auto_login_tokens_controller.rb b/app/controllers/my/auto_login_tokens_controller.rbindex f0222b9f856..d8c78fd8dd0 100644--- a/app/controllers/my/auto_login_tokens_controller.rb+++ b/app/controllers/my/auto_login_tokens_controller.rb@@ -1,7 +1,7 @@module Myclass AutoLoginTokensController < ::ApplicationControllerbefore_action :require_login- no_authorization_required! only: %i(destroy)+ no_authorization_required! :destroybefore_action :find_token, only: %i(destroy)diff --git a/app/controllers/my/sessions_controller.rb b/app/controllers/my/sessions_controller.rbindex 2c6094505d6..98d9a6307f6 100644--- a/app/controllers/my/sessions_controller.rb+++ b/app/controllers/my/sessions_controller.rb@@ -1,7 +1,9 @@module Myclass SessionsController < ::ApplicationControllerbefore_action :require_login- no_authorization_required! only: %i(index show destroy)+ no_authorization_required! :index,+ :show,+ :destroyself._model_object = ::Sessions::UserSessiondiff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rbindex 95bd8021132..ff46385f4a7 100644--- a/app/controllers/my_controller.rb+++ b/app/controllers/my_controller.rb@@ -39,21 +39,21 @@ class MyController < ApplicationControllerbefore_action :set_grouped_ical_tokens, only: %i[access_token]before_action :set_ical_token, only: %i[revoke_ical_token]- no_authorization_required! only: %i[account- update_account- settings- update_settings- password- change_password- access_token- delete_storage_token- notifications- reminders- generate_rss_key- revoke_rss_key- generate_api_key- revoke_api_key- revoke_ical_token]+ no_authorization_required! :account,+ :update_account,+ :settings,+ :update_settings,+ :password,+ :change_password,+ :access_token,+ :delete_storage_token,+ :notifications,+ :reminders,+ :generate_rss_key,+ :revoke_rss_key,+ :generate_api_key,+ :revoke_api_key,+ :revoke_ical_tokenmenu_item :account, only: [:account]menu_item :settings, only: [:settings]diff --git a/app/controllers/oauth/auth_base_controller.rb b/app/controllers/oauth/auth_base_controller.rbindex d2b703007a6..8ec97a4ceba 100644--- a/app/controllers/oauth/auth_base_controller.rb+++ b/app/controllers/oauth/auth_base_controller.rb@@ -37,9 +37,9 @@ module OAuthprepend_before_action :extend_content_security_policyskip_before_action :check_if_login_required- no_authorization_required! only: %i[new- create- show]+ no_authorization_required! :new,+ :create,+ :showlayout "only_logo"diff --git a/app/controllers/oauth/grants_controller.rb b/app/controllers/oauth/grants_controller.rbindex c4587b5e5e8..dc9206b1a48 100644--- a/app/controllers/oauth/grants_controller.rb+++ b/app/controllers/oauth/grants_controller.rb@@ -29,7 +29,7 @@module OAuthclass GrantsController < ::ApplicationControllerbefore_action :require_login- authorization_checked! only: %i[index revoke_application]+ authorization_checked! :index, :revoke_applicationlayout "my"menu_item :access_tokendiff --git a/app/controllers/oauth_clients_controller.rb b/app/controllers/oauth_clients_controller.rbindex afe14e36985..a2a09b3c1eb 100644--- a/app/controllers/oauth_clients_controller.rb+++ b/app/controllers/oauth_clients_controller.rb@@ -38,7 +38,7 @@ class OAuthClientsController < ApplicationControllerbefore_action :set_code, only: [:callback]before_action :set_connection_manager, only: [:callback]- no_authorization_required! only: %i[callback ensure_connection]+ no_authorization_required! :callback, :ensure_connectionafter_action :clear_oauth_state_cookie, only: [:callback]diff --git a/app/controllers/onboarding_controller.rb b/app/controllers/onboarding_controller.rbindex 95bc94725a4..59105b0a543 100644--- a/app/controllers/onboarding_controller.rb+++ b/app/controllers/onboarding_controller.rb@@ -27,7 +27,7 @@#++class OnboardingController < ApplicationController- no_authorization_required! only: %i[user_settings]+ no_authorization_required! :user_settingsdef user_settings@user = User.currentdiff --git a/app/controllers/placeholder_users_controller.rb b/app/controllers/placeholder_users_controller.rbindex daaf585fce5..9936ed29032 100644--- a/app/controllers/placeholder_users_controller.rb+++ b/app/controllers/placeholder_users_controller.rb@@ -30,7 +30,7 @@ class PlaceholderUsersController < ApplicationControllerinclude EnterpriseTrialHelperlayout "admin"before_action :authorize_global, except: %i[show]- no_authorization_required! only: %i[show]+ no_authorization_required! :showbefore_action :find_placeholder_user, only: %i[showeditdiff --git a/app/controllers/projects/menus_controller.rb b/app/controllers/projects/menus_controller.rbindex 08c92d81fc3..cdecdf19bbd 100644--- a/app/controllers/projects/menus_controller.rb+++ b/app/controllers/projects/menus_controller.rb@@ -29,7 +29,7 @@ module Projectsclass MenusController < ApplicationController# No authorize as every user (or logged in user)# is allowed to see the menu.- no_authorization_required! only: :show+ no_authorization_required! :showdef showprojects_menu = Menus::Projects.new(controller_path: params[:controller_path], params:, current_user:)diff --git a/app/controllers/projects/queries_controller.rb b/app/controllers/projects/queries_controller.rbindex 27b7018364e..04914ac7d6a 100644--- a/app/controllers/projects/queries_controller.rb+++ b/app/controllers/projects/queries_controller.rb@@ -30,7 +30,7 @@ class Projects::QueriesController < ApplicationControllerinclude Projects::QueryLoading# No need for a more specific authorization check. That is carried out in the contracts.- no_authorization_required! only: %i[show new create rename update publish unpublish destroy]+ no_authorization_required! :show, :new, :create, :rename, :update, :publish, :unpublish, :destroybefore_action :require_loginbefore_action :find_query, only: %i[show rename update destroy publish unpublish]before_action :build_query_or_deny_access, only: %i[new create]diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rbindex 04503237f79..49a816dff3d 100644--- a/app/controllers/projects_controller.rb+++ b/app/controllers/projects_controller.rb@@ -36,7 +36,7 @@ class ProjectsController < ApplicationControllerbefore_action :authorize_global, only: %i[new]before_action :require_admin, only: %i[destroy destroy_info]- no_authorization_required! only: %i[index]+ no_authorization_required! :indexinclude SortHelperinclude PaginationHelperdiff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rbindex 9f7ea9ea6ef..50a0f970613 100644--- a/app/controllers/users_controller.rb+++ b/app/controllers/users_controller.rb@@ -44,8 +44,8 @@ class UsersController < ApplicationControllerbefore_action :authorize_for_user, only: [:destroy]before_action :check_if_deletion_allowed, only: %i[deletion_infodestroy]- no_authorization_required! only: %i[show]- authorization_checked! only: %i[destroy deletion_info]+ no_authorization_required! :show+ authorization_checked! :destroy, :deletion_infobefore_action :set_current_activity_page, only: [:show]diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rbindex 9d367af4b51..ee4e32938ac 100644--- a/app/controllers/watchers_controller.rb+++ b/app/controllers/watchers_controller.rb@@ -32,7 +32,8 @@ class WatchersController < ApplicationController:require_login,:deny_access_unless_visible- authorization_checked! only: %i[watch unwatch]+ authorization_checked! :watch,+ :unwatchdef watchset_watcher(User.current, true)diff --git a/app/controllers/work_packages/auto_completes_controller.rb b/app/controllers/work_packages/auto_completes_controller.rbindex f5533e281c7..5a06d103d14 100644--- a/app/controllers/work_packages/auto_completes_controller.rb+++ b/app/controllers/work_packages/auto_completes_controller.rb@@ -30,7 +30,7 @@ require "rack/utils"class WorkPackages::AutoCompletesController < ApplicationController# Authorization is checked by the query.- no_authorization_required! only: :index+ no_authorization_required! :indexdef index@work_packages = work_packages_matching_query_propdiff --git a/app/controllers/work_packages/progress_controller.rb b/app/controllers/work_packages/progress_controller.rbindex f10dc61cf1e..194bbad8c1b 100644--- a/app/controllers/work_packages/progress_controller.rb+++ b/app/controllers/work_packages/progress_controller.rb@@ -37,7 +37,7 @@ class WorkPackages::ProgressController < ApplicationControllerlayout falsebefore_action :set_work_packagebefore_action :extract_persisted_progress_attributes, only: %i[edit create update]- authorization_checked! only: %i[new edit create update]+ authorization_checked! :new, :edit, :create, :updatehelper_method :modal_classdiff --git a/app/controllers/work_packages_controller.rb b/app/controllers/work_packages_controller.rbindex d67001318a2..513d5d9e174 100644--- a/app/controllers/work_packages_controller.rb+++ b/app/controllers/work_packages_controller.rb@@ -39,7 +39,7 @@ class WorkPackagesController < ApplicationControllerbefore_action :load_and_authorize_in_optional_project,:check_allowed_export,:protect_from_unauthorized_export, only: :index- authorization_checked! only: %i[index show]+ authorization_checked! :index, :showbefore_action :load_and_validate_query, only: :index, unless: -> { request.format.html? }before_action :load_work_packages, only: :index, if: -> { request.format.atom? }diff --git a/modules/avatars/app/controllers/avatars/avatar_controller.rb b/modules/avatars/app/controllers/avatars/avatar_controller.rbindex 3450061cddc..e76b67ea3b5 100644--- a/modules/avatars/app/controllers/avatars/avatar_controller.rb+++ b/modules/avatars/app/controllers/avatars/avatar_controller.rb@@ -3,7 +3,7 @@ module ::Avatarsbefore_action :ensure_enabledbefore_action :find_avatar- no_authorization_required! only: %i[show]+ no_authorization_required! :showdef showsend_file @avatar.diskfile,diff --git a/modules/avatars/app/controllers/avatars/my_avatar_controller.rb b/modules/avatars/app/controllers/avatars/my_avatar_controller.rbindex 9054b3c03a7..ba6bcda521d 100644--- a/modules/avatars/app/controllers/avatars/my_avatar_controller.rb+++ b/modules/avatars/app/controllers/avatars/my_avatar_controller.rb@@ -3,7 +3,9 @@ module ::Avatarsbefore_action :require_loginbefore_action :set_user- no_authorization_required! only: %i[show update destroy]+ no_authorization_required! :show,+ :update,+ :destroylayout "my"menu_item :avatardiff --git a/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb b/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rbindex 0e3ac8abe60..a2b62136608 100644--- a/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb+++ b/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb@@ -39,7 +39,8 @@ module Bimbefore_action :authorize, except: %i[direct_upload_finished set_direct_upload_file_name]before_action :require_login, only: [:set_direct_upload_file_name]skip_before_action :verify_authenticity_token, only: [:set_direct_upload_file_name] # AJAX request in page, so skip authenticity token- no_authorization_required! only: %i[set_direct_upload_file_name direct_upload_finished]+ no_authorization_required! :set_direct_upload_file_name,+ :direct_upload_finishedmenu_item :ifc_modelsdiff --git a/modules/budgets/app/controllers/budgets_controller.rb b/modules/budgets/app/controllers/budgets_controller.rbindex 2f2ee53bffc..6e94db62576 100644--- a/modules/budgets/app/controllers/budgets_controller.rb+++ b/modules/budgets/app/controllers/budgets_controller.rb@@ -42,7 +42,8 @@ class BudgetsController < ApplicationController:update_material_budget_item,:update_labor_budget_item]- no_authorization_required! only: %i[update_material_budget_item update_labor_budget_item]+ no_authorization_required! :update_material_budget_item,+ :update_labor_budget_itemhelper :sortinclude SortHelperdiff --git a/modules/calendar/app/controllers/calendar/ical_controller.rb b/modules/calendar/app/controllers/calendar/ical_controller.rbindex ad2deaffad1..1153dfb0422 100644--- a/modules/calendar/app/controllers/calendar/ical_controller.rb+++ b/modules/calendar/app/controllers/calendar/ical_controller.rb@@ -30,7 +30,7 @@ module ::Calendarclass ICalController < ApplicationController# Authentication and authorization is handled within the service.skip_before_action :check_if_login_required- no_authorization_required! only: :show+ no_authorization_required! :showdef showbegindiff --git a/modules/costs/app/controllers/hourly_rates_controller.rb b/modules/costs/app/controllers/hourly_rates_controller.rbindex b47f0cf22e6..dfc835f2601 100644--- a/modules/costs/app/controllers/hourly_rates_controller.rb+++ b/modules/costs/app/controllers/hourly_rates_controller.rb@@ -40,7 +40,9 @@ class HourlyRatesController < ApplicationController# #show, #edit and #update have their own authorizationbefore_action :authorize, except: %i[show edit update]- no_authorization_required! only: %i[show edit update]+ no_authorization_required! :show,+ :edit,+ :update# TODO: this should be an indexdef showdiff --git a/modules/recaptcha/app/controllers/recaptcha/request_controller.rb b/modules/recaptcha/app/controllers/recaptcha/request_controller.rbindex 63f81b212f1..55d423a9e67 100644--- a/modules/recaptcha/app/controllers/recaptcha/request_controller.rb+++ b/modules/recaptcha/app/controllers/recaptcha/request_controller.rb@@ -7,7 +7,8 @@ module ::Recaptcha# User is not yet logged in, so skip login required checkskip_before_action :check_if_login_required- no_authorization_required! only: %i[perform verify]+ no_authorization_required! :perform,+ :verify# Skip if recaptcha was disabledbefore_action :skip_if_disableddiff --git a/modules/storages/app/controllers/storages/project_storages_controller.rb b/modules/storages/app/controllers/storages/project_storages_controller.rbindex 530e79b8f18..8dbde0d3a26 100644--- a/modules/storages/app/controllers/storages/project_storages_controller.rb+++ b/modules/storages/app/controllers/storages/project_storages_controller.rb@@ -36,7 +36,7 @@ class Storages::ProjectStoragesController < ApplicationControllerbefore_action :find_model_objectbefore_action :find_project_by_project_idbefore_action :render_403, unless: -> { User.current.allowed_in_project?(:view_file_links, @project) }- no_authorization_required! only: %i[open]+ no_authorization_required! :open# rubocop:disable Metrics/AbcSizedef opendiff --git a/modules/two_factor_authentication/app/controllers/two_factor_authentication/authentication_controller.rb b/modules/two_factor_authentication/app/controllers/two_factor_authentication/authentication_controller.rbindex d94aa599058..a2cb5a50380 100644--- a/modules/two_factor_authentication/app/controllers/two_factor_authentication/authentication_controller.rb+++ b/modules/two_factor_authentication/app/controllers/two_factor_authentication/authentication_controller.rb@@ -11,12 +11,12 @@ module ::TwoFactorAuthentication# User is not yet logged in, so skip login required checkskip_before_action :check_if_login_required- no_authorization_required! only: %i[request_otp- confirm_otp- enter_backup_code- verify_backup_code- retry- webauthn_challenge]+ no_authorization_required! :request_otp,+ :confirm_otp,+ :enter_backup_code,+ :verify_backup_code,+ :retry,+ :webauthn_challenge# Avoid catch-all from core resulting in methodsbefore_action :only_post, only: :confirm_otpdiff --git a/modules/two_factor_authentication/app/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller.rb b/modules/two_factor_authentication/app/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller.rbindex 0a5f2363cae..35ec4564a37 100644--- a/modules/two_factor_authentication/app/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller.rb+++ b/modules/two_factor_authentication/app/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller.rb@@ -6,12 +6,12 @@ module ::TwoFactorAuthentication# Skip default loginskip_before_action :check_if_login_required- no_authorization_required! only: %i[register- new- confirm- web_authn- make_default- destroy]+ no_authorization_required! :register,+ :new,+ :confirm,+ :web_authn,+ :make_default,+ :destroybefore_action :find_device, only: [:confirm]diff --git a/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/backup_codes_controller.rb b/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/backup_codes_controller.rbindex a6eb12a0f84..0f46af2e804 100644--- a/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/backup_codes_controller.rb+++ b/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/backup_codes_controller.rb@@ -3,7 +3,7 @@ module ::TwoFactorAuthenticationclass BackupCodesController < ::ApplicationController# Ensure user is logged inbefore_action :require_login- no_authorization_required! only: %i[show create]+ no_authorization_required! :show, :create# Password confirmation helpers and actionsinclude PasswordConfirmationdiff --git a/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/remember_cookie_controller.rb b/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/remember_cookie_controller.rbindex eb23b6f50ba..e3d5ac206ee 100644--- a/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/remember_cookie_controller.rb+++ b/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/remember_cookie_controller.rb@@ -6,7 +6,7 @@ module ::TwoFactorAuthentication# Ensure user is logged inbefore_action :require_login- no_authorization_required! only: :destroy+ no_authorization_required! :destroylayout "my"menu_item :two_factor_authenticationdiff --git a/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/two_factor_devices_controller.rb b/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/two_factor_devices_controller.rbindex 4295a95a5eb..55e72a3cd47 100644--- a/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/two_factor_devices_controller.rb+++ b/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/two_factor_devices_controller.rb@@ -6,14 +6,14 @@ module ::TwoFactorAuthenticationbefore_action :set_user_variables# Authorization is not handled explicitly but as the user on which changes can be done is only the current user# (and that user needs to be logged in), no action harmful to other users can be done.- no_authorization_required! only: %i[new- index- create- register- confirm- destroy- make_default- webauthn_challenge]+ no_authorization_required! :new,+ :index,+ :create,+ :register,+ :confirm,+ :destroy,+ :make_default,+ :webauthn_challengebefore_action :find_device, except: %i[new index register webauthn_challenge]diff --git a/modules/webhooks/app/controllers/webhooks/incoming/hooks_controller.rb b/modules/webhooks/app/controllers/webhooks/incoming/hooks_controller.rbindex f1ef5786a89..bdea4697828 100644--- a/modules/webhooks/app/controllers/webhooks/incoming/hooks_controller.rb+++ b/modules/webhooks/app/controllers/webhooks/incoming/hooks_controller.rb@@ -37,7 +37,7 @@ module Webhooksskip_before_action :verify_authenticity_token# Authorization cannot be applied since authentication is skipped.# It is then to be ensured when handling the hook.- no_authorization_required! only: [:handle_hook]+ no_authorization_required! :handle_hook# Wrap the JSON body as 'payload' param# making it available as params[:payload]diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rbindex 0d39fe54a3f..b280a0c134c 100644--- a/spec/controllers/application_controller_spec.rb+++ b/spec/controllers/application_controller_spec.rb@@ -33,7 +33,7 @@ RSpec.describe ApplicationController do# Fake controller to test calling an actioncontroller do- no_authorization_required!+ no_authorization_required! :indexdef index# just do anything that doesn't require an extra template@@ -154,7 +154,7 @@ RSpec.describe ApplicationController docontroller doinclude OpenProjectErrorHelper- no_authorization_required!+ no_authorization_required! :indexdef indexop_handle_error "fail"diff --git a/spec/controllers/concerns/authorization_spec.rb b/spec/controllers/concerns/authorization_spec.rbindex 45296d7eaf8..de0e0fee0ae 100644--- a/spec/controllers/concerns/authorization_spec.rb+++ b/spec/controllers/concerns/authorization_spec.rb@@ -150,26 +150,6 @@ RSpec.describe ApplicationController, "enforcement of authorization" do # rubocoit_behaves_like "is prevented"end- context "when forfeiting authorization checks" do- controller do- no_authorization_required!-- include controller_setup- end-- it_behaves_like "succeeds"- end-- context "when stating that authorization has been checked" do- controller do- authorization_checked!-- include controller_setup- end-- it_behaves_like "succeeds"- end-context "with authorization check in the superclass" docontroller(described_class) dobefore_action :require_admin@@ -182,21 +162,19 @@ RSpec.describe ApplicationController, "enforcement of authorization" do # rubocoit_behaves_like "succeeds"end- context "when stating that authorization has been checked in the superclass" do- controller(described_class) do- authorization_checked!- end+ context "when forfeiting authorization checks on this specific action" do+ controller do+ no_authorization_required! :index- controller(controller_class) doinclude controller_setupendit_behaves_like "succeeds"end- context "when forfeiting authorization checks in the superclass" do+ context "when stating that authorization has been checked in the superclass" docontroller(described_class) do- no_authorization_required!+ authorization_checked! :indexendcontroller(controller_class) do@@ -206,39 +184,21 @@ RSpec.describe ApplicationController, "enforcement of authorization" do # rubocoit_behaves_like "succeeds"end- context "when forfeiting authorization checks on this specific action with only" do- controller do- no_authorization_required! only: %i[index]-- include controller_setup- end-- it_behaves_like "succeeds"- end-- context "when forfeiting authorization checks on another action with only" do- controller do- no_authorization_required! only: %i[some_other_action]-- include controller_setup+ context "when forfeiting authorization checks in the superclass" do+ controller(described_class) do+ no_authorization_required! :indexend- it_behaves_like "is prevented"- end-- context "when forfeiting authorization checks on all but another action with except" do- controller do- no_authorization_required! except: %i[some_other_action]-+ controller(controller_class) doinclude controller_setupendit_behaves_like "succeeds"end- context "when forfeiting authorization on all other actions with except" do+ context "when forfeiting authorization checks on another action" docontroller do- no_authorization_required! except: %i[index]+ no_authorization_required! :some_other_actioninclude controller_setupend