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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
7731bb59
Commit
7731bb59
authored
May 04, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use bearer token to access registry
parent
de008127
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
app/models/project.rb
app/models/project.rb
+2
-1
app/services/jwt/docker_authentication_service.rb
app/services/jwt/docker_authentication_service.rb
+11
-0
No files found.
app/models/project.rb
View file @
7731bb59
...
...
@@ -371,7 +371,8 @@ class Project < ActiveRecord::Base
end
def
image_repository
@registry
||=
ImageRegistry
::
Registry
.
new
(
Gitlab
.
config
.
registry
.
api_url
)
@registry_token
||=
Jwt
::
DockerAuthenticationService
.
full_access_token
(
path_with_namespace
)
@registry
||=
ImageRegistry
::
Registry
.
new
(
Gitlab
.
config
.
registry
.
api_url
,
token:
@registry_token
)
@image_repository
||=
ImageRegistry
::
Repository
.
new
(
@registry
,
path_with_namespace
)
end
...
...
app/services/jwt/docker_authentication_service.rb
View file @
7731bb59
...
...
@@ -8,6 +8,17 @@ module Jwt
{
token:
token
.
encoded
}
end
def
self
.
full_access_token
(
*
names
)
registry
=
Gitlab
.
config
.
registry
token
=
::
Jwt
::
RSAToken
.
new
(
registry
.
key
)
token
.
issuer
=
registry
.
issuer
token
.
audience
=
'docker'
token
[
:access
]
=
names
.
map
do
|
name
|
{
type:
'repository'
,
name:
name
,
actions:
%w(pull push)
}
end
token
.
encoded
end
private
def
token
...
...
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