Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
54f6d8c7
Commit
54f6d8c7
authored
Jan 27, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
an ability to clone project with oauth2 token
parent
1718075a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
2 deletions
+20
-2
db/migrate/20150116234545_add_gitlab_access_token_to_user.rb
db/migrate/20150116234545_add_gitlab_access_token_to_user.rb
+5
-0
db/schema.rb
db/schema.rb
+2
-1
lib/gitlab/backend/grack_auth.rb
lib/gitlab/backend/grack_auth.rb
+13
-1
No files found.
db/migrate/20150116234545_add_gitlab_access_token_to_user.rb
0 → 100644
View file @
54f6d8c7
class
AddGitlabAccessTokenToUser
<
ActiveRecord
::
Migration
def
change
add_column
:users
,
:gitlab_access_token
,
:string
end
end
db/schema.rb
View file @
54f6d8c7
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2015011623454
4
)
do
ActiveRecord
::
Schema
.
define
(
version:
2015011623454
5
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
@@ -434,6 +434,7 @@ ActiveRecord::Schema.define(version: 20150116234544) do
...
@@ -434,6 +434,7 @@ ActiveRecord::Schema.define(version: 20150116234544) do
t
.
string
"website_url"
,
default:
""
,
null:
false
t
.
string
"website_url"
,
default:
""
,
null:
false
t
.
datetime
"last_credential_check_at"
t
.
datetime
"last_credential_check_at"
t
.
string
"github_access_token"
t
.
string
"github_access_token"
t
.
string
"gitlab_access_token"
end
end
add_index
"users"
,
[
"admin"
],
name:
"index_users_on_admin"
,
using: :btree
add_index
"users"
,
[
"admin"
],
name:
"index_users_on_admin"
,
using: :btree
...
...
lib/gitlab/backend/grack_auth.rb
View file @
54f6d8c7
...
@@ -34,7 +34,7 @@ module Grack
...
@@ -34,7 +34,7 @@ module Grack
def
auth!
def
auth!
if
@auth
.
provided?
if
@auth
.
provided?
return
bad_request
unless
@auth
.
basic?
return
bad_request
unless
@auth
.
basic?
# Authentication with username and password
# Authentication with username and password
login
,
password
=
@auth
.
credentials
login
,
password
=
@auth
.
credentials
...
@@ -71,8 +71,20 @@ module Grack
...
@@ -71,8 +71,20 @@ module Grack
false
false
end
end
def
oauth_access_token_check
(
login
,
password
)
if
login
==
"oauth2"
&&
git_cmd
==
'git-upload-pack'
&&
password
.
present?
token
=
Doorkeeper
::
AccessToken
.
by_token
(
password
)
token
&&
token
.
accessible?
&&
User
.
find_by
(
id:
token
.
resource_owner_id
)
end
end
def
authenticate_user
(
login
,
password
)
def
authenticate_user
(
login
,
password
)
user
=
Gitlab
::
Auth
.
new
.
find
(
login
,
password
)
user
=
Gitlab
::
Auth
.
new
.
find
(
login
,
password
)
unless
user
user
=
oauth_access_token_check
(
login
,
password
)
end
return
user
if
user
.
present?
return
user
if
user
.
present?
# At this point, we know the credentials were wrong. We let Rack::Attack
# At this point, we know the credentials were wrong. We let Rack::Attack
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment