feat(apikey): added route to list user api keys (#1708)

adding api key expiration date

Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
This commit is contained in:
peusebiu
2023-08-29 19:38:38 +03:00
committed by GitHub
parent 28858f695f
commit 6926bddd3a
15 changed files with 1132 additions and 153 deletions
+13 -7
View File
@@ -149,8 +149,12 @@ type UserDB interface { //nolint:interfacebloat
GetUserAPIKeyInfo(hashedKey string) (identity string, err error)
GetUserAPIKeys(ctx context.Context) ([]APIKeyDetails, error)
AddUserAPIKey(ctx context.Context, hashedKey string, apiKeyDetails *APIKeyDetails) error
IsAPIKeyExpired(ctx context.Context, hashedKey string) (bool, error)
UpdateUserAPIKeyLastUsed(ctx context.Context, hashedKey string) error
DeleteUserAPIKey(ctx context.Context, id string) error
@@ -252,11 +256,13 @@ type FilterData struct {
}
type APIKeyDetails struct {
CreatedAt time.Time `json:"createdAt"`
CreatorUA string `json:"creatorUa"`
GeneratedBy string `json:"generatedBy"`
LastUsed time.Time `json:"lastUsed"`
Label string `json:"label"`
Scopes []string `json:"scopes"`
UUID string `json:"uuid"`
CreatedAt time.Time `json:"createdAt"`
ExpirationDate time.Time `json:"expirationDate"`
IsExpired bool `json:"isExpired"`
CreatorUA string `json:"creatorUa"`
GeneratedBy string `json:"generatedBy"`
LastUsed time.Time `json:"lastUsed"`
Label string `json:"label"`
Scopes []string `json:"scopes"`
UUID string `json:"uuid"`
}