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
Boxiang Sun
gitlab-ce
Commits
368984e4
Commit
368984e4
authored
Aug 29, 2018
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the new gitaly auth scheme (v2)
parent
c2da9418
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
8 deletions
+22
-8
lib/gitlab/gitaly_client.rb
lib/gitlab/gitaly_client.rb
+22
-8
No files found.
lib/gitlab/gitaly_client.rb
View file @
368984e4
...
...
@@ -174,10 +174,29 @@ module Gitlab
end
private_class_method
:current_transaction_labels
# For some time related tasks we can't rely on `Time.now` since it will be
# affected by Timecop in some tests, and the clock of some gitaly-related
# components (grpc's c-core and gitaly server) use system time instead of
# timecop's time, so tests will fail.
# `Time.at(Process.clock_gettime(Process::CLOCK_REALTIME))` will circumvent
# timecop.
def
self
.
real_time
Time
.
at
(
Process
.
clock_gettime
(
Process
::
CLOCK_REALTIME
))
end
private_class_method
:real_time
def
self
.
authorization_token
(
storage
)
token
=
token
(
storage
).
to_s
issued_at
=
real_time
.
to_i
.
to_s
hmac
=
OpenSSL
::
HMAC
.
hexdigest
(
OpenSSL
::
Digest
::
SHA256
.
new
,
token
,
issued_at
)
"v2.
#{
hmac
}
.
#{
issued_at
}
"
end
private_class_method
:authorization_token
def
self
.
request_kwargs
(
storage
,
timeout
,
remote_storage:
nil
)
encoded_token
=
Base64
.
strict_encode64
(
token
(
storage
).
to_s
)
metadata
=
{
'authorization'
=>
"Bearer
#{
encoded_token
}
"
,
'authorization'
=>
"Bearer
#{
authorization_token
(
storage
)
}
"
,
'client_name'
=>
CLIENT_NAME
}
...
...
@@ -195,12 +214,7 @@ module Gitlab
return
result
unless
timeout
>
0
# Do not use `Time.now` for deadline calculation, since it
# will be affected by Timecop in some tests, but grpc's c-core
# uses system time instead of timecop's time, so tests will fail
# `Time.at(Process.clock_gettime(Process::CLOCK_REALTIME))` will
# circumvent timecop
deadline
=
Time
.
at
(
Process
.
clock_gettime
(
Process
::
CLOCK_REALTIME
))
+
timeout
deadline
=
real_time
+
timeout
result
[
:deadline
]
=
deadline
result
...
...
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