Auth: Add expiry date for service accounts access tokens (#58885)

* Add new configuration option for SA tokens

* Add new expiry date option to frontend components

* Add backend validation


Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
This commit is contained in:
linoman
2022-11-22 10:08:40 +01:00
committed by GitHub
co-authored by Gabriel MABILLE
parent c1eabb893f
commit f8f61c1a69
10 changed files with 67 additions and 15 deletions
+12
View File
@@ -385,6 +385,9 @@ type Cfg struct {
HiddenUsers map[string]struct{}
CaseInsensitiveLogin bool // Login and Email will be considered case insensitive
// Service Accounts
SATokenExpirationDayLimit int
// Annotations
AnnotationCleanupJobBatchSize int64
AnnotationMaximumTagsLength int64
@@ -978,6 +981,9 @@ func (cfg *Cfg) Load(args CommandLineArgs) error {
if err := readUserSettings(iniFile, cfg); err != nil {
return err
}
if err := readServiceAccountSettings(iniFile, cfg); err != nil {
return err
}
if err := readAuthSettings(iniFile, cfg); err != nil {
return err
}
@@ -1481,6 +1487,12 @@ func readUserSettings(iniFile *ini.File, cfg *Cfg) error {
return nil
}
func readServiceAccountSettings(iniFile *ini.File, cfg *Cfg) error {
serviceAccount := iniFile.Section("service_accounts")
cfg.SATokenExpirationDayLimit = serviceAccount.Key("token_expiration_day_limit").MustInt(-1)
return nil
}
func (cfg *Cfg) readRenderingSettings(iniFile *ini.File) error {
renderSec := iniFile.Section("rendering")
cfg.RendererUrl = valueAsString(renderSec, "server_url", "")