Add/Delete API keys to Service accounts (#44871)

* ServiceAccounts: move token handlers to specific file

* ServiceAccounts: move Add API key to Service account

* APIKeys: api keys can still be used even when service accounts are enabled

* APIKeys: legacy endpoint can't be used to add SA tokens

* ServiceAccount: add tests for creation with nil and non-nil service account ids

* ServiceAccounts: fix unnasigned cfg and AC typo

* Test: test service account token adding

* fix linting error

* ServiceAccounts: Handle Token deletion

* rename token funcs

* rename token funcs and api wrapping

* add token deletion tests

* review

Co-authored-by: eleijonmarck <eric.leijonmarck@gmail.com>

* remove bus

* Update pkg/api/apikey.go

Co-authored-by: eleijonmarck <eric.leijonmarck@gmail.com>
This commit is contained in:
J Guerreiro
2022-02-07 14:51:54 +01:00
committed by GitHub
co-authored by eleijonmarck
parent 12176e24ef
commit 94820e1f29
13 changed files with 453 additions and 59 deletions
+2 -2
View File
@@ -21,7 +21,7 @@ type ApiKey struct {
Created time.Time
Updated time.Time
Expires *int64
ServiceAccountId int64
ServiceAccountId *int64
}
// ---------------------
@@ -32,7 +32,7 @@ type AddApiKeyCommand struct {
OrgId int64 `json:"-"`
Key string `json:"-"`
SecondsToLive int64 `json:"secondsToLive"`
ServiceAccountId int64 `json:"-"`
ServiceAccountId *int64 `json:"-"`
Result *ApiKey `json:"-"`
}