mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-25 19:31:05 +00:00
Add flag to set oauth redirect host in dev mode (#586)
This commit is contained in:
parent
ad509fd86f
commit
3bee9044f1
6 changed files with 24 additions and 10 deletions
|
@ -79,12 +79,6 @@ var flags = []cli.Flag{
|
|||
Name: "quic",
|
||||
Usage: "enable quic",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
EnvVars: []string{"WOODPECKER_WWW_PROXY"},
|
||||
Name: "www-proxy",
|
||||
Usage: "serve the website by using a proxy (used for development)",
|
||||
Hidden: true,
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
EnvVars: []string{"WOODPECKER_ADMIN"},
|
||||
Name: "admin",
|
||||
|
@ -512,4 +506,18 @@ var flags = []cli.Flag{
|
|||
Name: "keepalive-min-time",
|
||||
Usage: "server-side enforcement policy on the minimum amount of time a client should wait before sending a keepalive ping.",
|
||||
},
|
||||
// development flags
|
||||
&cli.StringFlag{
|
||||
EnvVars: []string{"WOODPECKER_DEV_WWW_PROXY"},
|
||||
Name: "www-proxy",
|
||||
Usage: "serve the website by using a proxy (used for development)",
|
||||
Hidden: true,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
EnvVars: []string{"WOODPECKER_DEV_OAUTH_HOST"},
|
||||
Name: "server-dev-oauth-host",
|
||||
Usage: "server fully qualified url (<scheme>://<host>) used for oauth redirect (used for development)",
|
||||
Value: "",
|
||||
Hidden: true,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -290,6 +290,11 @@ func setupEvilGlobals(c *cli.Context, v store.Store, r remote.Remote) {
|
|||
server.Config.Server.Key = c.String("server-key")
|
||||
server.Config.Server.Pass = c.String("agent-secret")
|
||||
server.Config.Server.Host = c.String("server-host")
|
||||
if c.IsSet("server-dev-oauth-host") {
|
||||
server.Config.Server.OAuthHost = c.String("server-dev-oauth-host")
|
||||
} else {
|
||||
server.Config.Server.OAuthHost = c.String("server-host")
|
||||
}
|
||||
server.Config.Server.Port = c.String("server-addr")
|
||||
server.Config.Server.Docs = c.String("docs")
|
||||
server.Config.Server.SessionExpires = c.Duration("session-expires")
|
||||
|
|
|
@ -52,6 +52,7 @@ var Config = struct {
|
|||
Server struct {
|
||||
Key string
|
||||
Cert string
|
||||
OAuthHost string
|
||||
Host string
|
||||
Port string
|
||||
Pass string
|
||||
|
|
|
@ -99,7 +99,7 @@ func (c *Gitea) Login(ctx context.Context, w http.ResponseWriter, req *http.Requ
|
|||
AuthURL: fmt.Sprintf(authorizeTokenURL, c.URL),
|
||||
TokenURL: fmt.Sprintf(accessTokenURL, c.URL),
|
||||
},
|
||||
RedirectURL: fmt.Sprintf("%s/authorize", server.Config.Server.Host),
|
||||
RedirectURL: fmt.Sprintf("%s/authorize", server.Config.Server.OAuthHost),
|
||||
}
|
||||
|
||||
// get the OAuth errors
|
||||
|
|
|
@ -338,9 +338,9 @@ func (c *client) newConfig(req *http.Request) *oauth2.Config {
|
|||
|
||||
intendedURL := req.URL.Query()["url"]
|
||||
if len(intendedURL) > 0 {
|
||||
redirect = fmt.Sprintf("%s/authorize?url=%s", server.Config.Server.Host, intendedURL[0])
|
||||
redirect = fmt.Sprintf("%s/authorize?url=%s", server.Config.Server.OAuthHost, intendedURL[0])
|
||||
} else {
|
||||
redirect = fmt.Sprintf("%s/authorize", server.Config.Server.Host)
|
||||
redirect = fmt.Sprintf("%s/authorize", server.Config.Server.OAuthHost)
|
||||
}
|
||||
|
||||
return &oauth2.Config{
|
||||
|
|
|
@ -95,7 +95,7 @@ func (g *Gitlab) Login(ctx context.Context, res http.ResponseWriter, req *http.R
|
|||
Scope: defaultScope,
|
||||
AuthURL: fmt.Sprintf("%s/oauth/authorize", g.URL),
|
||||
TokenURL: fmt.Sprintf("%s/oauth/token", g.URL),
|
||||
RedirectURL: fmt.Sprintf("%s/authorize", server.Config.Server.Host),
|
||||
RedirectURL: fmt.Sprintf("%s/authorize", server.Config.Server.OAuthHost),
|
||||
}
|
||||
|
||||
// get the OAuth errors
|
||||
|
|
Loading…
Reference in a new issue