chore: remove access token after sign out

This commit is contained in:
Steven
2024-05-20 08:53:29 +08:00
parent 21838d0aae
commit fb15386db2
2 changed files with 16 additions and 3 deletions

View File

@@ -24,6 +24,7 @@ const (
// The key name used to store username in the context
// user id is extracted from the jwt token subject field.
usernameContextKey ContextKey = iota
accessTokenContextKey
)
// GRPCAuthInterceptor is the auth interceptor for gRPC server.
@@ -74,9 +75,9 @@ func (in *GRPCAuthInterceptor) AuthenticationInterceptor(ctx context.Context, re
return nil, errors.Errorf("user %q is not admin", username)
}
// Stores userID into context.
childCtx := context.WithValue(ctx, usernameContextKey, username)
return handler(childCtx, request)
ctx = context.WithValue(ctx, usernameContextKey, username)
ctx = context.WithValue(ctx, accessTokenContextKey, accessToken)
return handler(ctx, request)
}
func (in *GRPCAuthInterceptor) authenticate(ctx context.Context, accessToken string) (string, error) {