Feature #30086 » 30086-http-status-code-403-v2.patch
| app/controllers/application_controller.rb | ||
|---|---|---|
|
format.any(:atom, :pdf, :csv) {
|
||
|
redirect_to signin_path(:back_url => url)
|
||
|
}
|
||
|
format.xml { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
|
||
|
format.api {
|
||
|
if Setting.rest_api_enabled? && accept_api_auth?
|
||
|
head(:unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"')
|
||
|
else
|
||
|
head(:forbidden)
|
||
|
end
|
||
|
}
|
||
|
format.js { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
|
||
|
format.json { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
|
||
|
format.any { head :unauthorized }
|
||
|
end
|
||
|
return false
|
||
| test/integration/api_test/disabled_rest_api_test.rb | ||
|---|---|---|
|
@token = Token.create!(:user => @user, :action => 'api')
|
||
|
get "/news.xml?key=#{@token.value}"
|
||
|
assert_response :unauthorized
|
||
|
assert_response :forbidden
|
||
|
assert_equal User.anonymous, User.current
|
||
|
get "/news.json?key=#{@token.value}"
|
||
|
assert_response :unauthorized
|
||
|
assert_response :forbidden
|
||
|
assert_equal User.anonymous, User.current
|
||
|
end
|
||
| ... | ... | |
|
end
|
||
|
get "/news.xml", :headers => credentials(@user.login, 'my_password')
|
||
|
assert_response :unauthorized
|
||
|
assert_response :forbidden
|
||
|
assert_equal User.anonymous, User.current
|
||
|
get "/news.json", :headers => credentials(@user.login, 'my_password')
|
||
|
assert_response :unauthorized
|
||
|
assert_response :forbidden
|
||
|
assert_equal User.anonymous, User.current
|
||
|
end
|
||
| ... | ... | |
|
@token = Token.create!(:user => @user, :action => 'api')
|
||
|
get "/news.xml", :headers => credentials(@token.value, 'X')
|
||
|
assert_response :unauthorized
|
||
|
assert_response :forbidden
|
||
|
assert_equal User.anonymous, User.current
|
||
|
get "/news.json", :headers => credentials(@token.value, 'X')
|
||
|
assert_response :unauthorized
|
||
|
assert_response :forbidden
|
||
|
assert_equal User.anonymous, User.current
|
||
|
end
|
||
|
end
|
||
- « Previous
- 1
- 2
- Next »