Separation of RSS/API auth actions.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6197 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
01d34d65d9
commit
93c2b92a4b
@ -1,7 +1,24 @@
|
|||||||
|
# Redmine - project management software
|
||||||
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
class ActivitiesController < ApplicationController
|
class ActivitiesController < ApplicationController
|
||||||
menu_item :activity
|
menu_item :activity
|
||||||
before_filter :find_optional_project
|
before_filter :find_optional_project
|
||||||
accept_key_auth :index
|
accept_rss_auth :index
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@days = Setting.activity_days_default.to_i
|
@days = Setting.activity_days_default.to_i
|
||||||
|
@ -71,11 +71,11 @@ class ApplicationController < ActionController::Base
|
|||||||
user = User.try_to_autologin(cookies[:autologin])
|
user = User.try_to_autologin(cookies[:autologin])
|
||||||
session[:user_id] = user.id if user
|
session[:user_id] = user.id if user
|
||||||
user
|
user
|
||||||
elsif params[:format] == 'atom' && request.get? && params[:key] && accept_key_auth_actions.include?(params[:action])
|
elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth?
|
||||||
# RSS key authentication does not start a session
|
# RSS key authentication does not start a session
|
||||||
User.find_by_rss_key(params[:key])
|
User.find_by_rss_key(params[:key])
|
||||||
elsif Setting.rest_api_enabled? && api_request?
|
elsif Setting.rest_api_enabled? && accept_api_auth?
|
||||||
if (key = api_key_from_request) && accept_key_auth_actions.include?(params[:action])
|
if (key = api_key_from_request)
|
||||||
# Use API key
|
# Use API key
|
||||||
User.find_by_api_key(key)
|
User.find_by_api_key(key)
|
||||||
else
|
else
|
||||||
@ -332,14 +332,41 @@ class ApplicationController < ActionController::Base
|
|||||||
@title = options[:title] || Setting.app_title
|
@title = options[:title] || Setting.app_title
|
||||||
render :template => "common/feed.atom.rxml", :layout => false, :content_type => 'application/atom+xml'
|
render :template => "common/feed.atom.rxml", :layout => false, :content_type => 'application/atom+xml'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: remove in Redmine 1.4
|
||||||
def self.accept_key_auth(*actions)
|
def self.accept_key_auth(*actions)
|
||||||
actions = actions.flatten.map(&:to_s)
|
ActiveSupport::Deprecaction.warn "ApplicationController.accept_key_auth is deprecated and will be removed in Redmine 1.4. Use accept_rss_auth (or accept_api_auth) instead."
|
||||||
write_inheritable_attribute('accept_key_auth_actions', actions)
|
accept_rss_auth(*actions)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: remove in Redmine 1.4
|
||||||
def accept_key_auth_actions
|
def accept_key_auth_actions
|
||||||
self.class.read_inheritable_attribute('accept_key_auth_actions') || []
|
ActiveSupport::Deprecaction.warn "ApplicationController.accept_key_auth_actions is deprecated and will be removed in Redmine 1.4. Use accept_rss_auth (or accept_api_auth) instead."
|
||||||
|
self.class.accept_rss_auth
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.accept_rss_auth(*actions)
|
||||||
|
if actions.any?
|
||||||
|
write_inheritable_attribute('accept_rss_auth_actions', actions)
|
||||||
|
else
|
||||||
|
read_inheritable_attribute('accept_rss_auth_actions') || []
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def accept_rss_auth?(action=action_name)
|
||||||
|
self.class.accept_rss_auth.include?(action.to_sym)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.accept_api_auth(*actions)
|
||||||
|
if actions.any?
|
||||||
|
write_inheritable_attribute('accept_api_auth_actions', actions)
|
||||||
|
else
|
||||||
|
read_inheritable_attribute('accept_api_auth_actions') || []
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def accept_api_auth?(action=action_name)
|
||||||
|
self.class.accept_api_auth.include?(action.to_sym)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the number of objects that should be displayed
|
# Returns the number of objects that should be displayed
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@ -18,7 +18,7 @@
|
|||||||
class BoardsController < ApplicationController
|
class BoardsController < ApplicationController
|
||||||
default_search_scope :messages
|
default_search_scope :messages
|
||||||
before_filter :find_project, :find_board_if_available, :authorize
|
before_filter :find_project, :find_board_if_available, :authorize
|
||||||
accept_key_auth :index, :show
|
accept_rss_auth :index, :show
|
||||||
|
|
||||||
helper :messages
|
helper :messages
|
||||||
include MessagesHelper
|
include MessagesHelper
|
||||||
|
@ -19,7 +19,7 @@ class IssueRelationsController < ApplicationController
|
|||||||
before_filter :find_issue, :find_project_from_association, :authorize, :only => [:index, :create]
|
before_filter :find_issue, :find_project_from_association, :authorize, :only => [:index, :create]
|
||||||
before_filter :find_relation, :except => [:index, :create]
|
before_filter :find_relation, :except => [:index, :create]
|
||||||
|
|
||||||
accept_key_auth :index, :show, :create, :destroy
|
accept_api_auth :index, :show, :create, :destroy
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@relations = @issue.relations
|
@relations = @issue.relations
|
||||||
|
@ -27,7 +27,8 @@ class IssuesController < ApplicationController
|
|||||||
before_filter :find_optional_project, :only => [:index]
|
before_filter :find_optional_project, :only => [:index]
|
||||||
before_filter :check_for_default_issue_status, :only => [:new, :create]
|
before_filter :check_for_default_issue_status, :only => [:new, :create]
|
||||||
before_filter :build_new_issue_from_params, :only => [:new, :create]
|
before_filter :build_new_issue_from_params, :only => [:new, :create]
|
||||||
accept_key_auth :index, :show, :create, :update, :destroy
|
accept_rss_auth :index, :show
|
||||||
|
accept_api_auth :index, :show, :create, :update, :destroy
|
||||||
|
|
||||||
rescue_from Query::StatementInvalid, :with => :query_statement_invalid
|
rescue_from Query::StatementInvalid, :with => :query_statement_invalid
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ class JournalsController < ApplicationController
|
|||||||
before_filter :find_issue, :only => [:new]
|
before_filter :find_issue, :only => [:new]
|
||||||
before_filter :find_optional_project, :only => [:index]
|
before_filter :find_optional_project, :only => [:index]
|
||||||
before_filter :authorize, :only => [:new, :edit, :diff]
|
before_filter :authorize, :only => [:new, :edit, :diff]
|
||||||
accept_key_auth :index
|
accept_rss_auth :index
|
||||||
menu_item :issues
|
menu_item :issues
|
||||||
|
|
||||||
helper :issues
|
helper :issues
|
||||||
|
@ -23,7 +23,8 @@ class NewsController < ApplicationController
|
|||||||
before_filter :find_project, :only => [:new, :create]
|
before_filter :find_project, :only => [:new, :create]
|
||||||
before_filter :authorize, :except => [:index]
|
before_filter :authorize, :except => [:index]
|
||||||
before_filter :find_optional_project, :only => :index
|
before_filter :find_optional_project, :only => :index
|
||||||
accept_key_auth :index
|
accept_rss_auth :index
|
||||||
|
accept_api_auth :index
|
||||||
|
|
||||||
helper :watchers
|
helper :watchers
|
||||||
|
|
||||||
|
@ -24,7 +24,8 @@ class ProjectsController < ApplicationController
|
|||||||
before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
|
before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
|
||||||
before_filter :authorize_global, :only => [:new, :create]
|
before_filter :authorize_global, :only => [:new, :create]
|
||||||
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
|
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
|
||||||
accept_key_auth :index, :show, :create, :update, :destroy
|
accept_rss_auth :index
|
||||||
|
accept_api_auth :index, :show, :create, :update, :destroy
|
||||||
|
|
||||||
after_filter :only => [:create, :edit, :update, :archive, :unarchive, :destroy] do |controller|
|
after_filter :only => [:create, :edit, :update, :archive, :unarchive, :destroy] do |controller|
|
||||||
if controller.request.post?
|
if controller.request.post?
|
||||||
|
@ -20,7 +20,7 @@ class QueriesController < ApplicationController
|
|||||||
before_filter :find_query, :except => [:new, :index]
|
before_filter :find_query, :except => [:new, :index]
|
||||||
before_filter :find_optional_project, :only => :new
|
before_filter :find_optional_project, :only => :new
|
||||||
|
|
||||||
accept_key_auth :index
|
accept_api_auth :index
|
||||||
|
|
||||||
def index
|
def index
|
||||||
case params[:format]
|
case params[:format]
|
||||||
|
@ -30,7 +30,7 @@ class RepositoriesController < ApplicationController
|
|||||||
before_filter :find_repository, :except => :edit
|
before_filter :find_repository, :except => :edit
|
||||||
before_filter :find_project, :only => :edit
|
before_filter :find_project, :only => :edit
|
||||||
before_filter :authorize
|
before_filter :authorize
|
||||||
accept_key_auth :revisions
|
accept_rss_auth :revisions
|
||||||
|
|
||||||
rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed
|
rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2010 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@ -22,7 +22,8 @@ class TimelogController < ApplicationController
|
|||||||
before_filter :find_time_entries, :only => [:bulk_edit, :bulk_update, :destroy]
|
before_filter :find_time_entries, :only => [:bulk_edit, :bulk_update, :destroy]
|
||||||
before_filter :authorize, :except => [:index]
|
before_filter :authorize, :except => [:index]
|
||||||
before_filter :find_optional_project, :only => [:index]
|
before_filter :find_optional_project, :only => [:index]
|
||||||
accept_key_auth :index, :show, :create, :update, :destroy
|
accept_rss_auth :index
|
||||||
|
accept_api_auth :index, :show, :create, :update, :destroy
|
||||||
|
|
||||||
helper :sort
|
helper :sort
|
||||||
include SortHelper
|
include SortHelper
|
||||||
|
@ -20,7 +20,7 @@ class UsersController < ApplicationController
|
|||||||
|
|
||||||
before_filter :require_admin, :except => :show
|
before_filter :require_admin, :except => :show
|
||||||
before_filter :find_user, :only => [:show, :edit, :update, :destroy, :edit_membership, :destroy_membership]
|
before_filter :find_user, :only => [:show, :edit, :update, :destroy, :edit_membership, :destroy_membership]
|
||||||
accept_key_auth :index, :show, :create, :update, :destroy
|
accept_api_auth :index, :show, :create, :update, :destroy
|
||||||
|
|
||||||
helper :sort
|
helper :sort
|
||||||
include SortHelper
|
include SortHelper
|
||||||
|
@ -23,7 +23,7 @@ class VersionsController < ApplicationController
|
|||||||
before_filter :find_project, :only => [:index, :new, :create, :close_completed]
|
before_filter :find_project, :only => [:index, :new, :create, :close_completed]
|
||||||
before_filter :authorize
|
before_filter :authorize
|
||||||
|
|
||||||
accept_key_auth :index, :create, :update, :destroy
|
accept_api_auth :index, :create, :update, :destroy
|
||||||
|
|
||||||
helper :custom_fields
|
helper :custom_fields
|
||||||
helper :projects
|
helper :projects
|
||||||
|
Loading…
x
Reference in New Issue
Block a user