feat: include user ID with web token (#17535)

pull/17555/head
Gavin Cabbage 2020-04-01 13:43:46 -04:00 committed by GitHub
parent 02946a48a2
commit 5f1eaa7be3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -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