mirror of
https://github.com/paralus/paralus.git
synced 2026-08-24 15:47:19 +00:00
added ability to conifigure SA account lifetime with validation
Signed-off-by: mabhi <abhijit.mukherjee@infracloud.io>
This commit is contained in:
@@ -40,11 +40,19 @@ func UpdateKubeconfigRevocation(ctx context.Context, db bun.IDB, kr *models.Kube
|
||||
|
||||
func GetKubeconfigSetting(ctx context.Context, db bun.IDB, orgID, accountID uuid.UUID, issSSO bool) (*models.KubeconfigSetting, error) {
|
||||
var ks models.KubeconfigSetting
|
||||
err := db.NewSelect().Model(&ks).
|
||||
Where("organization_id = ?", orgID).
|
||||
Where("account_id = ?", accountID).
|
||||
Where("is_sso_user= ?", issSSO).
|
||||
Scan(ctx)
|
||||
var err error = nil
|
||||
if len(accountID.String()) > 0 {
|
||||
err = db.NewSelect().Model(&ks).
|
||||
Where("organization_id = ?", orgID).
|
||||
Where("account_id = ?", accountID).
|
||||
Where("is_sso_user= ?", issSSO).
|
||||
Scan(ctx)
|
||||
} else {
|
||||
err = db.NewSelect().Model(&ks).
|
||||
Where("organization_id = ?", orgID).
|
||||
Where("is_sso_user= ?", issSSO).
|
||||
Scan(ctx)
|
||||
}
|
||||
return &ks, err
|
||||
}
|
||||
|
||||
@@ -67,6 +75,7 @@ func UpdateKubeconfigSetting(ctx context.Context, db bun.IDB, ks *models.Kubecon
|
||||
|
||||
q = q.Set("modified_at = ?", time.Now()).
|
||||
Set("validity_seconds = ?", ks.ValiditySeconds).
|
||||
Set("sa_validity_seconds = ?", ks.SaValiditySeconds).
|
||||
Set("enforce_rsid = ?", ks.EnforceRsId).
|
||||
Set("is_sso_user = ?", ks.IsSSOUser).
|
||||
Set("disable_web_kubectl = ?", ks.DisableWebKubectl).
|
||||
|
||||
@@ -15,7 +15,8 @@ type KubeconfigSetting struct {
|
||||
PartnerId uuid.UUID `bun:"partner_id,type:uuid,notnull"`
|
||||
AccountId uuid.UUID `bun:"account_id,type:uuid,notnull"`
|
||||
Scope string `bun:"scope,notnull"`
|
||||
ValiditySeconds int64 `bun:"validity_seconds,notnull,default:0"`
|
||||
ValiditySeconds int64 `bun:"validity_seconds,notnull,default:28800"`
|
||||
SaValiditySeconds int64 `bun:"sa_validity_seconds,notnull,default:28800"`
|
||||
CreatedAt time.Time `bun:"created_at,notnull,default:current_timestamp"`
|
||||
ModifiedAt time.Time `bun:"modified_at"`
|
||||
DeletedAt time.Time `bun:"deleted_at"`
|
||||
|
||||
Reference in New Issue
Block a user