Skip to content
Snippets Groups Projects

Add DPoP checks in GraphQL and API requests

Merged Ameya Darshan requested to merge ameya-dpop-2 into master
All threads resolved!
Compare and Show latest version
5 files
+ 21
27
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -12,10 +12,6 @@ class GraphqlController < ApplicationController
# Max size of the query text in characters
MAX_QUERY_SIZE = 10_000
# Headers to read private tokens in requests
PRIVATE_TOKEN_HEADER = 'HTTP_PRIVATE_TOKEN'
PRIVATE_TOKEN_PARAM = :private_token
# The query string of a standard IntrospectionQuery, used to compare incoming requests for caching
CACHED_INTROSPECTION_QUERY_STRING = CachedIntrospectionQuery.query_string
INTROSPECTION_QUERY_OPERATION_NAME = 'IntrospectionQuery'
@@ -35,9 +31,10 @@ class GraphqlController < ApplicationController
# must come first: current_user is set up here
before_action(only: [:execute]) { authenticate_sessionless_user!(:graphql_api) }
before_action(only: [:execute]) { check_dpop }
before_action :authorize_access_api!
# must come after authorize_access_api! to check for nil current_user
before_action(only: [:execute]) { :check_dpop! }
before_action :set_user_last_activity
before_action :track_vs_code_usage
before_action :track_jetbrains_usage
@@ -128,8 +125,8 @@ def feature_category
private
def check_dpop
::Auth::DpopAuthenticationService.new(current_user, request_authenticator.get_personal_access_token,
def check_dpop!
::Auth::DpopAuthenticationService.new(current_user, Gitlab::Auth::AuthFinders.get_personal_access_token,
request).execute
end
Loading