diff options
author | randx <dmitriy.zaporozhets@gmail.com> | 2012-09-10 09:06:11 +0300 |
---|---|---|
committer | randx <dmitriy.zaporozhets@gmail.com> | 2012-09-10 09:06:11 +0300 |
commit | b565f33472d960e37ed41a8a0c09fbbc3ea65f1e (patch) | |
tree | d209e55133eb80b15ea963cf46c308e847375795 /lib/api/helpers.rb | |
parent | 80685596d3df23f05f2bd9978c8d8f483e799028 (diff) | |
download | gitlab-ce-b565f33472d960e37ed41a8a0c09fbbc3ea65f1e.tar.gz |
Auth for API
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r-- | lib/api/helpers.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index ce7b7b497fc..c0ba874790a 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -21,5 +21,21 @@ module Gitlab def authenticate! error!({'message' => '401 Unauthorized'}, 401) unless current_user end + + def authorize! action, subject + unless abilities.allowed?(current_user, action, subject) + error!({'message' => '403 Forbidden'}, 403) + end + end + + private + + def abilities + @abilities ||= begin + abilities = Six.new + abilities << Ability + abilities + end + end end end |