@@ -381,9 +381,21 @@ func (s *Server) HTTPHandler() (http.Handler, error) {
381381 handler .InitPayload = resolver .InitPayload
382382 graphQLHandler := handler .NewHandlerFunc (schema , gql .NewHttpHandler (schema ))
383383 handle ("/api/graphql" , authHandlerWithUser (func (user * auth.User , w http.ResponseWriter , r * http.Request ) {
384- ctx := context . WithValue ( context . Background (), resolver . HeadersKey , map [string ]interface {}{
384+ headers := map [string ]interface {}{
385385 "Authorization" : fmt .Sprintf ("Bearer %s" , user .Token ),
386- })
386+ }
387+ if impUser := r .Header .Get ("Impersonate-User" ); impUser != "" {
388+ headers ["Impersonate-User" ] = impUser
389+ }
390+ if consoleGroups := r .Header .Get ("X-Console-Impersonate-Groups" ); consoleGroups != "" {
391+ groups := strings .Split (consoleGroups , "," )
392+ groups = append (groups , "system:authenticated" )
393+ headers ["Impersonate-Group" ] = groups
394+ } else if impGroups := r .Header .Values ("Impersonate-Group" ); len (impGroups ) > 0 {
395+ impGroups = append (impGroups , "system:authenticated" )
396+ headers ["Impersonate-Group" ] = impGroups
397+ }
398+ ctx := context .WithValue (context .Background (), resolver .HeadersKey , headers )
387399 graphQLHandler (w , r .WithContext (ctx ))
388400 }))
389401
0 commit comments