BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
project.rb
app/models/project.rb
+2
-1
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