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
add documentation to API::RootApi.authorize helper
Christophe Bliard7efd14a792e9
diff --git a/lib/api/root_api.rb b/lib/api/root_api.rbindex 97f9866cafa..6a87e1706e9 100644--- a/lib/api/root_api.rb+++ b/lib/api/root_api.rb@@ -46,7 +46,7 @@ module APIuse OpenProject::Authentication::Managerhelpers API::Caching::Helpers- helpers do+ module Helpersdef current_userUser.currentend@@ -116,11 +116,30 @@ module APIcurrent_user && (current_user.admin? || !current_user.anonymous?)end+ # Checks that the current user has the given permission or raise+ # {API::Errors::Unauthorized}.+ #+ # @param permission [String] the permission name+ #+ # @param context [Project, Array<Project>, nil] can be:+ # * a project : returns true if user is allowed to do the specified+ # action on this project+ # * a group of projects : returns true if user is allowed on every+ # project+ # * +nil+ with +options[:global]+ set: check if user has at least one+ # role allowed for this action, or falls back to Non Member /+ # Anonymous permissions depending if the user is logged+ #+ # @param global [Boolean] when +true+ and with +context+ set to +nil+:+ # checks that the current user is allowed to do the specified action on+ # any project+ #+ # @raise [API::Errors::Unauthorized] when permission is not metdef authorize(permission, context: nil, global: false, user: current_user, &block)auth_service = AuthorizationService.new(permission,- context: context,- global: global,- user: user)+ context:,+ global:,+ user:)authorize_by_with_raise auth_service, &blockend@@ -184,6 +203,8 @@ module APIendend+ helpers Helpers+def self.auth_headerslambda doheader = OpenProject::Authentication::WWWAuthenticate