Skip to content

Commit abfa825

Browse files
tphoneyactions-user
authored andcommitted
(feat) allow the api-server to impersonate an account to gateway (#802)
re https://github.com/overmindtech/workspace/issues/792 - gateway records impersonation for websockets ✅ - sdp-go middleware records impersonation for http ✅ - deploy allows api-server to perform scopes needed for queries and snapshots on gateway, ✅ - api-server has a helper method for impersonating an account. changeAnalysis uses it ✅ GitOrigin-RevId: 1c58a14cb3e984345c8897e59b1bd4a09be47c1b
1 parent 0fdea42 commit abfa825

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sdp-go/middleware.go

+8
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,17 @@ func ensureValidTokenHandler(config AuthConfig, next http.Handler) http.Handler
334334
attribute.String("ovm.auth.accountName", customClaims.AccountName),
335335
attribute.Int64("ovm.auth.expiry", claims.RegisteredClaims.Expiry),
336336
attribute.String("ovm.auth.scopes", customClaims.Scope),
337+
// subject is the auth0 client id or user id
337338
attribute.String("ovm.auth.subject", claims.RegisteredClaims.Subject),
338339
)
339340

341+
// if its a service impersonating an account, we should mark it as impersonation
342+
if strings.HasSuffix(claims.RegisteredClaims.Subject, "@clients") {
343+
trace.SpanFromContext(ctx).SetAttributes(
344+
attribute.Bool("ovm.auth.impersonation", true),
345+
)
346+
}
347+
340348
r = r.Clone(ctx)
341349

342350
next.ServeHTTP(w, r)

0 commit comments

Comments
 (0)