+11
-1
appview/oauth/oauth.go
+11
-1
appview/oauth/oauth.go
···
224
s.service = service
225
}
226
}
227
func WithExp(exp int64) ServiceClientOpt {
228
return func(s *ServiceClientOpts) {
229
-
s.exp = exp
230
}
231
}
232
···
264
authorizedClient, err := o.AuthorizedClient(r)
265
if err != nil {
266
return nil, err
267
}
268
269
resp, err := authorizedClient.ServerGetServiceAuth(r.Context(), opts.Audience(), opts.exp, opts.lxm)
···
224
s.service = service
225
}
226
}
227
+
228
+
// Specify the Duration in seconds for the expiry of this token
229
+
//
230
+
// The time of expiry is calculated as time.Now().Unix() + exp
231
func WithExp(exp int64) ServiceClientOpt {
232
return func(s *ServiceClientOpts) {
233
+
s.exp = time.Now().Unix() + exp
234
}
235
}
236
···
268
authorizedClient, err := o.AuthorizedClient(r)
269
if err != nil {
270
return nil, err
271
+
}
272
+
273
+
// force expiry to atleast 60 seconds in the future
274
+
sixty := time.Now().Unix() + 60
275
+
if opts.exp < sixty {
276
+
opts.exp = sixty
277
}
278
279
resp, err := authorizedClient.ServerGetServiceAuth(r.Context(), opts.Audience(), opts.exp, opts.lxm)
+2
appview/repo/repo.go
+2
appview/repo/repo.go
···
1062
r,
1063
oauth.WithService(f.Spindle),
1064
oauth.WithLxm(lxm),
1065
oauth.WithDev(rp.config.Core.Dev),
1066
)
1067
if err != nil {
···
1270
r,
1271
oauth.WithService(f.Spindle),
1272
oauth.WithLxm(tangled.RepoListSecretsNSID),
1273
oauth.WithDev(rp.config.Core.Dev),
1274
); err != nil {
1275
log.Println("failed to create spindle client", err)
···
1062
r,
1063
oauth.WithService(f.Spindle),
1064
oauth.WithLxm(lxm),
1065
+
oauth.WithExp(60),
1066
oauth.WithDev(rp.config.Core.Dev),
1067
)
1068
if err != nil {
···
1271
r,
1272
oauth.WithService(f.Spindle),
1273
oauth.WithLxm(tangled.RepoListSecretsNSID),
1274
+
oauth.WithExp(60),
1275
oauth.WithDev(rp.config.Core.Dev),
1276
); err != nil {
1277
log.Println("failed to create spindle client", err)