Skip to content

Commit ebdab89

Browse files
Inon SharonyInon Sharony
Inon Sharony
authored and
Inon Sharony
committed
Applied code review comment: Change HTTPAuthExpiry to time.Duration
1 parent edc8b7e commit ebdab89

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

cmd/serv.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func runServ(c *cli.Context) error {
268268
claims := jwt.MapClaims{
269269
"repo": repo.ID,
270270
"op": lfsVerb,
271-
"exp": now.Add(time.Duration(setting.LFS.HTTPAuthExpiryMinutes) * time.Minute).Unix(),
271+
"exp": now.Add(setting.LFS.HTTPAuthExpiry).Unix(),
272272
"nbf": now.Unix(),
273273
}
274274
if user != nil {

custom/conf/app.ini.sample

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ LFS_START_SERVER = false
189189
LFS_CONTENT_PATH = data/lfs
190190
; LFS authentication secret, change this yourself
191191
LFS_JWT_SECRET =
192-
; LFS authentication validity period in minutes, pushes taking longer than this may fail.
193-
LFS_HTTP_AUTH_EXPIRY_MINUTES = 20
192+
; LFS authentication validity period (in time.Duration), pushes taking longer than this may fail.
193+
LFS_HTTP_AUTH_EXPIRY = 20m
194194

195195
; Define allowed algorithms and their minimum key length (use -1 to disable a type)
196196
[ssh.minimum_key_sizes]

modules/setting/setting.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ var (
136136
}
137137

138138
LFS struct {
139-
StartServer bool `ini:"LFS_START_SERVER"`
140-
ContentPath string `ini:"LFS_CONTENT_PATH"`
141-
JWTSecretBase64 string `ini:"LFS_JWT_SECRET"`
142-
JWTSecretBytes []byte `ini:"-"`
143-
HTTPAuthExpiryMinutes int `ini:"LFS_HTTP_AUTH_EXPIRY_MINUTES"`
139+
StartServer bool `ini:"LFS_START_SERVER"`
140+
ContentPath string `ini:"LFS_CONTENT_PATH"`
141+
JWTSecretBase64 string `ini:"LFS_JWT_SECRET"`
142+
JWTSecretBytes []byte `ini:"-"`
143+
HTTPAuthExpiry time.Duration `ini:"LFS_HTTP_AUTH_EXPIRY"`
144144
}
145145

146146
// Security settings
@@ -828,7 +828,9 @@ func NewContext() {
828828
if !filepath.IsAbs(LFS.ContentPath) {
829829
LFS.ContentPath = filepath.Join(AppWorkPath, LFS.ContentPath)
830830
}
831-
LFS.HTTPAuthExpiryMinutes = sec.Key("LFS_HTTP_AUTH_EXPIRY_MINUTES").MustInt(5)
831+
832+
sec = Cfg.Section("LFS")
833+
LFS.HTTPAuthExpiry = sec.Key("LFS_HTTP_AUTH_EXPIRY").MustDuration(20 * time.Minute)
832834

833835
if LFS.StartServer {
834836

0 commit comments

Comments
 (0)