diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-02-15 16:15:55 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-02-15 16:15:55 +0300 |
commit | c34c50e1b88dfd7a4a453437b40a12708428a74f (patch) | |
tree | 61014e73bbbf1e9d332ba9f7fe5560b69c6ea8a1 /lib | |
parent | ab06c9b654c5f26fbe9e3fce22a54f7944ee4dab (diff) | |
parent | 1cfa3c76a151a1c7ddf2099e3547fe1f5d691c25 (diff) |
Merge branch '57353-git-push-fails-on-large-lfs-files-where-the-push-take-a-long-time' into 'master'
Provide expires_in in LFS authentication payload
Closes #57353
See merge request gitlab-org/gitlab-ce!25082
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/internal.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/lfs_token.rb | 13 |
2 files changed, 12 insertions, 9 deletions
diff --git a/lib/api/internal.rb b/lib/api/internal.rb index 9488b3469d9..b44ef2a6ea4 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -117,13 +117,7 @@ module API raise ActiveRecord::RecordNotFound.new("No key_id or user_id passed!") end - token_handler = Gitlab::LfsToken.new(actor) - - { - username: token_handler.actor_name, - lfs_token: token_handler.token, - repository_http_path: project.http_url_to_repo - } + Gitlab::LfsToken.new(actor).authentication_payload(project.http_url_to_repo) end # rubocop: enable CodeReuse/ActiveRecord diff --git a/lib/gitlab/lfs_token.rb b/lib/gitlab/lfs_token.rb index 26b81847d37..31e6fc9d8c7 100644 --- a/lib/gitlab/lfs_token.rb +++ b/lib/gitlab/lfs_token.rb @@ -30,8 +30,8 @@ module Gitlab end end - def token(expire_time: DEFAULT_EXPIRE_TIME) - HMACToken.new(actor).token(expire_time) + def token + HMACToken.new(actor).token(DEFAULT_EXPIRE_TIME) end def token_valid?(token_to_check) @@ -47,6 +47,15 @@ module Gitlab user? ? :lfs_token : :lfs_deploy_token end + def authentication_payload(repository_http_path) + { + username: actor_name, + lfs_token: token, + repository_http_path: repository_http_path, + expires_in: DEFAULT_EXPIRE_TIME + } + end + private # rubocop:disable Lint/UselessAccessModifier class HMACToken |