-
Notifications
You must be signed in to change notification settings - Fork 28
/
token.go
30 lines (22 loc) · 926 Bytes
/
token.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// SPDX-License-Identifier: Apache-2.0
package main
import (
"github.com/golang-jwt/jwt/v5"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
"github.com/go-vela/server/internal/token"
)
// helper function to setup the tokenmanager from the CLI arguments.
func setupTokenManager(c *cli.Context) *token.Manager {
logrus.Debug("Creating token manager from CLI configuration")
tm := &token.Manager{
PrivateKey: c.String("vela-server-private-key"),
SignMethod: jwt.SigningMethodHS256,
UserAccessTokenDuration: c.Duration("user-access-token-duration"),
UserRefreshTokenDuration: c.Duration("user-refresh-token-duration"),
BuildTokenBufferDuration: c.Duration("build-token-buffer-duration"),
WorkerAuthTokenDuration: c.Duration("worker-auth-token-duration"),
WorkerRegisterTokenDuration: c.Duration("worker-register-token-duration"),
}
return tm
}