36 Star 395 Fork 71

GVPrancher / rancher

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
token.go 860 Bytes
Copy Edit Raw Blame History
Craig Jellick authored 2018-06-20 15:10 . Improve auth logging
package auth
import (
tokenUtil "github.com/rancher/rancher/pkg/auth/tokens"
"github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/rancher/types/config"
)
const (
tokenController = "mgmt-auth-tokens-controller"
)
type TokenController struct {
tokens v3.TokenInterface
}
func newTokenController(mgmt *config.ManagementContext) *TokenController {
n := &TokenController{
tokens: mgmt.Management.Tokens(""),
}
return n
}
//sync is called periodically and on real updates
func (n *TokenController) sync(key string, obj *v3.Token) error {
if obj == nil || obj.DeletionTimestamp != nil {
return nil
}
if obj.TTLMillis != 0 && obj.ExpiresAt == "" {
//compute and save expiresAt
newObj := obj.DeepCopy()
tokenUtil.SetTokenExpiresAt(newObj)
if _, err := n.tokens.Update(newObj); err != nil {
return err
}
}
return nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.1.2-rc16

Search

344bd9b3 5694891 D2dac590 5694891