Skip to content

Commit

Permalink
set token ttl
Browse files Browse the repository at this point in the history
  • Loading branch information
michelia authored and guangbochen committed Sep 30, 2020
1 parent 54166a3 commit 53b301b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/auth/jwe/tokenmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package jwe

import (
"fmt"
"strconv"
"time"

dashboardapi "github.com/kubernetes/dashboard/src/app/backend/auth/api"
dashboardjwt "github.com/kubernetes/dashboard/src/app/backend/auth/jwe"
Expand All @@ -22,5 +24,15 @@ func NewJWETokenManager(secrets ctlcorev1.SecretClient, namespace string) (token
synchronizer := authsync.NewSecretSynchronizer(secrets, namespace, settings.AuthSecretName.Get())
keyHolder := dashboardjwt.NewRSAKeyHolder(synchronizer)
tokenManager = dashboardjwt.NewJWETokenManager(keyHolder)
tokenManager.SetTokenTTL(GetTokenMaxTTL())
return
}

func GetTokenMaxTTL() time.Duration {
ttlStr := settings.AuthTokenMaxTTLMinutes.Get()
ttl, err := strconv.ParseInt(ttlStr, 10, 32)
if err != nil {
ttl = 720
}
return time.Duration(ttl) * time.Minute
}

0 comments on commit 53b301b

Please sign in to comment.