Skip authorization for callback actions during project build. Refactor. Refs #2261

This commit is contained in:
Pavel Chipiga 2011-11-30 02:56:57 +02:00
parent 4971fbbbde
commit 7535fc124a
2 changed files with 11 additions and 8 deletions

View File

@ -1,12 +1,14 @@
class BuildListsController < ApplicationController class BuildListsController < ApplicationController
before_filter :authenticate_user!, :except => [:status_build, :pre_build, :post_build, :circle_build, :new_bbdt] CALLBACK_ACTIONS = [:status_build, :pre_build, :post_build, :circle_build, :new_bbdt]
before_filter :authenticate_build_service!, :only => [:status_build, :pre_build, :post_build, :circle_build, :new_bbdt]
before_filter :find_project, :only => [:index, :filter, :show, :publish]
before_filter :find_arches, :only => [:index, :filter, :all]
before_filter :find_project_versions, :only => [:index, :filter]
before_filter :find_build_list_by_bs, :only => [:status_build, :pre_build, :post_build]
load_and_authorize_resource before_filter :authenticate_user!, :except => CALLBACK_ACTIONS
before_filter :authenticate_build_service!, :only => CALLBACK_ACTIONS
before_filter :find_project, :only => [:index, :filter, :show, :publish]
before_filter :find_arches, :only => [:index, :filter, :all]
before_filter :find_project_versions, :only => [:index, :filter]
before_filter :find_build_list_by_bs, :only => [:status_build, :pre_build, :post_build]
load_and_authorize_resource :except => CALLBACK_ACTIONS
def all def all
if params[:filter] if params[:filter]

View File

@ -14,7 +14,8 @@ class Ability
can :forbidden, Platform can :forbidden, Platform
can :read, [Repository, Platform], :visibility => 'open' can :read, [Repository, Platform], :visibility => 'open'
can :auto_build, Project # TODO: This needs to be checked! # TODO remove because auth callbacks skipped
can :auto_build, Project
can [:status_build, :pre_build, :post_build, :circle_build, :new_bbdt], BuildList can [:status_build, :pre_build, :post_build, :circle_build, :new_bbdt], BuildList
# Guest rights # Guest rights