diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /app/controllers/jwt_controller.rb | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'app/controllers/jwt_controller.rb')
-rw-r--r-- | app/controllers/jwt_controller.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/controllers/jwt_controller.rb b/app/controllers/jwt_controller.rb index da39d64c93d..3e7755046cd 100644 --- a/app/controllers/jwt_controller.rb +++ b/app/controllers/jwt_controller.rb @@ -4,7 +4,9 @@ class JwtController < ApplicationController skip_around_action :set_session_storage skip_before_action :authenticate_user! skip_before_action :verify_authenticity_token - before_action :authenticate_project_or_user + + # Add this before other actions, since we want to have the user or project + prepend_before_action :auth_user, :authenticate_project_or_user SERVICES = { Auth::ContainerRegistryAuthenticationService::AUDIENCE => Auth::ContainerRegistryAuthenticationService @@ -75,4 +77,11 @@ class JwtController < ApplicationController Array(Rack::Utils.parse_query(request.query_string)['scope']) end + + def auth_user + strong_memoize(:auth_user) do + actor = @authentication_result&.actor + actor.is_a?(User) ? actor : nil + end + end end |