mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-27 04:11:03 +00:00
commit
76ea999c01
3 changed files with 16 additions and 7 deletions
|
@ -93,6 +93,12 @@ var flags = []cli.Flag{
|
||||||
Name: "open",
|
Name: "open",
|
||||||
Usage: "open user registration",
|
Usage: "open user registration",
|
||||||
},
|
},
|
||||||
|
cli.DurationFlag{
|
||||||
|
EnvVar: "DRONE_SESSION_EXPIRES",
|
||||||
|
Name: "session-expires",
|
||||||
|
Usage: "Set the session expiration time default 72h",
|
||||||
|
Value: time.Hour * 72,
|
||||||
|
},
|
||||||
cli.StringSliceFlag{
|
cli.StringSliceFlag{
|
||||||
EnvVar: "DRONE_ESCALATE",
|
EnvVar: "DRONE_ESCALATE",
|
||||||
Name: "escalate",
|
Name: "escalate",
|
||||||
|
@ -632,6 +638,7 @@ func setupEvilGlobals(c *cli.Context, v store.Store, r remote.Remote) {
|
||||||
droneserver.Config.Server.Pass = c.String("agent-secret")
|
droneserver.Config.Server.Pass = c.String("agent-secret")
|
||||||
droneserver.Config.Server.Host = strings.TrimRight(c.String("server-host"), "/")
|
droneserver.Config.Server.Host = strings.TrimRight(c.String("server-host"), "/")
|
||||||
droneserver.Config.Server.Port = c.String("server-addr")
|
droneserver.Config.Server.Port = c.String("server-addr")
|
||||||
|
droneserver.Config.Server.SessionExpires = c.Duration("session-expires")
|
||||||
droneserver.Config.Pipeline.Networks = c.StringSlice("network")
|
droneserver.Config.Pipeline.Networks = c.StringSlice("network")
|
||||||
droneserver.Config.Pipeline.Volumes = c.StringSlice("volume")
|
droneserver.Config.Pipeline.Volumes = c.StringSlice("volume")
|
||||||
droneserver.Config.Pipeline.Privileged = c.StringSlice("escalate")
|
droneserver.Config.Pipeline.Privileged = c.StringSlice("escalate")
|
||||||
|
|
|
@ -112,7 +112,7 @@ func HandleAuth(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
exp := time.Now().Add(time.Hour * 72).Unix()
|
exp := time.Now().Add(Config.Server.SessionExpires).Unix()
|
||||||
token := token.New(token.SessToken, u.Login)
|
token := token.New(token.SessToken, u.Login)
|
||||||
tokenstr, err := token.SignExpires(u.Hash, exp)
|
tokenstr, err := token.SignExpires(u.Hash, exp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -152,7 +152,7 @@ func GetLoginToken(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
exp := time.Now().Add(time.Hour * 72).Unix()
|
exp := time.Now().Add(Config.Server.SessionExpires).Unix()
|
||||||
token := token.New(token.SessToken, user.Login)
|
token := token.New(token.SessToken, user.Login)
|
||||||
tokenstr, err := token.SignExpires(user.Hash, exp)
|
tokenstr, err := token.SignExpires(user.Hash, exp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import (
|
||||||
"github.com/drone/drone/model"
|
"github.com/drone/drone/model"
|
||||||
"github.com/drone/drone/remote"
|
"github.com/drone/drone/remote"
|
||||||
"github.com/drone/drone/store"
|
"github.com/drone/drone/store"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This file is a complete disaster because I'm trying to wedge in some
|
// This file is a complete disaster because I'm trying to wedge in some
|
||||||
|
@ -56,6 +57,7 @@ var Config = struct {
|
||||||
Host string
|
Host string
|
||||||
Port string
|
Port string
|
||||||
Pass string
|
Pass string
|
||||||
|
SessionExpires time.Duration
|
||||||
// Open bool
|
// Open bool
|
||||||
// Orgs map[string]struct{}
|
// Orgs map[string]struct{}
|
||||||
// Admins map[string]struct{}
|
// Admins map[string]struct{}
|
||||||
|
|
Loading…
Reference in a new issue