diff options
author | Patricio Cano <suprnova32@gmail.com> | 2016-08-10 19:03:32 -0500 |
---|---|---|
committer | Patricio Cano <suprnova32@gmail.com> | 2016-08-16 11:19:00 -0500 |
commit | c5a7a70d10cc59e940f85ce21bc25e392ab68978 (patch) | |
tree | 503a9472f9529bf5becef73ee1228d57c7288adc /lib | |
parent | b44b09b302e6f4d19c7e6b2dac3be62fe83b31b2 (diff) | |
download | gitlab-ce-c5a7a70d10cc59e940f85ce21bc25e392ab68978.tar.gz |
Allow Git over HTTP access using Personal Access Tokens
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/auth.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb index db1704af75e..926774837d0 100644 --- a/lib/gitlab/auth.rb +++ b/lib/gitlab/auth.rb @@ -14,6 +14,8 @@ module Gitlab result.type = :gitlab_or_ldap elsif result.user = oauth_access_token_check(login, password) result.type = :oauth + elsif result.user = personal_access_token_check(login, password) + result.type = :personal_token end rate_limit!(ip, success: !!result.user || (result.type == :ci), login: login) @@ -82,6 +84,13 @@ module Gitlab token && token.accessible? && User.find_by(id: token.resource_owner_id) end end + + def personal_access_token_check(login, password) + if login && password + user = User.find_by_personal_access_token(password) + user if user && user.username == login + end + end end end end |