mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-05 18:20:37 +01:00
Update expiration schema to bigint and default unit to minute
Signed-off-by: wang yan <wangyan@vmware.com>
This commit is contained in:
parent
47a09b5891
commit
36a778b482
@ -3,7 +3,7 @@ CREATE TABLE robot (
|
||||
name varchar(255),
|
||||
description varchar(1024),
|
||||
project_id int,
|
||||
expiration int,
|
||||
expiration bigint,
|
||||
disabled boolean DEFAULT false NOT NULL,
|
||||
creation_time timestamp default CURRENT_TIMESTAMP,
|
||||
update_time timestamp default CURRENT_TIMESTAMP,
|
||||
|
@ -130,6 +130,7 @@ var (
|
||||
{Name: "with_chartmuseum", Scope: SystemScope, Group: BasicGroup, EnvKey: "WITH_CHARTMUSEUM", DefaultValue: "false", ItemType: &BoolType{}, Editable: true},
|
||||
{Name: "with_clair", Scope: SystemScope, Group: BasicGroup, EnvKey: "WITH_CLAIR", DefaultValue: "false", ItemType: &BoolType{}, Editable: true},
|
||||
{Name: "with_notary", Scope: SystemScope, Group: BasicGroup, EnvKey: "WITH_NOTARY", DefaultValue: "false", ItemType: &BoolType{}, Editable: true},
|
||||
{Name: "robot_token_expiration", Scope: UserScope, Group: BasicGroup, EnvKey: "ROBOT_TOKEN_EXPIRATION", DefaultValue: "30", ItemType: &IntType{}, Editable: true},
|
||||
// the unit of expiration is minute, 43200 minutes = 30 days
|
||||
{Name: "robot_token_expiration", Scope: UserScope, Group: BasicGroup, EnvKey: "ROBOT_TOKEN_EXPIRATION", DefaultValue: "43200", ItemType: &IntType{}, Editable: true},
|
||||
}
|
||||
)
|
||||
|
@ -106,8 +106,8 @@ func (r *RobotAPI) Post() {
|
||||
}
|
||||
|
||||
var robotReq models.RobotReq
|
||||
// Expiration in days
|
||||
tokenExpiration := time.Duration(config.RobotTokenExpiration()) * 24 * time.Hour
|
||||
// Expiration in minutes
|
||||
tokenExpiration := time.Duration(config.RobotTokenExpiration()) * time.Minute
|
||||
expiresAt := time.Now().UTC().Add(tokenExpiration).Unix()
|
||||
r.DecodeJSONReq(&robotReq)
|
||||
createdName := common.RobotPrefix + robotReq.Name
|
||||
|
@ -225,7 +225,7 @@ func TokenExpiration() (int, error) {
|
||||
return cfgMgr.Get(common.TokenExpiration).GetInt(), nil
|
||||
}
|
||||
|
||||
// RobotTokenExpiration returns the token expiration time of robot account (in day)
|
||||
// RobotTokenExpiration returns the token expiration time of robot account (in minute)
|
||||
func RobotTokenExpiration() int {
|
||||
return cfgMgr.Get(common.RobotTokenExpiration).GetInt()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user