From 5f1eaa7be38b4eb2a060b273051bd5ea7901a32e Mon Sep 17 00:00:00 2001 From: Gavin Cabbage Date: Wed, 1 Apr 2020 13:43:46 -0400 Subject: [PATCH] feat: include user ID with web token (#17535) --- jsonweb/token.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jsonweb/token.go b/jsonweb/token.go index 05f8b6d7e6..3bd28da5c9 100644 --- a/jsonweb/token.go +++ b/jsonweb/token.go @@ -89,6 +89,8 @@ type Token struct { KeyID string `json:"kid"` // Permissions is the set of authorized permissions for the token Permissions []influxdb.Permission `json:"permissions"` + // UserID for the token + UserID influxdb.ID `json:"uid,omitempty"` } // Allowed returns whether or not a permission is allowed based @@ -118,10 +120,9 @@ func (t *Token) Identifier() influxdb.ID { return *id } -// GetUserID returns an invalid id as tokens are generated -// with permissions rather than for or by a particular user +// GetUserID returns the user ID for the token func (t *Token) GetUserID() influxdb.ID { - return influxdb.InvalidID() + return t.UserID } // Kind returns the string "jwt" which is used for auditing