Use server-host as source for public links and warn if it is set to localhost (#251)

* Use server-host as source for public links

* use config and rm GetURL()

* fix: solve import cycle

Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
Anbraten
2021-08-20 16:32:52 +02:00
committed by GitHub
co-authored by 6543
parent 0e8c17e7e8
commit 1a67fc6e99
13 changed files with 48 additions and 98 deletions
+2 -4
View File
@@ -23,7 +23,7 @@ import (
"github.com/woodpecker-ci/woodpecker/model"
"github.com/woodpecker-ci/woodpecker/remote"
"github.com/woodpecker-ci/woodpecker/remote/coding/internal"
"github.com/woodpecker-ci/woodpecker/shared/httputil"
"github.com/woodpecker-ci/woodpecker/server"
"golang.org/x/net/context"
"golang.org/x/oauth2"
@@ -62,8 +62,6 @@ func New(opts Opts) (remote.Remote, error) {
remote.URL = strings.TrimSuffix(opts.URL, "/")
}
// Hack to enable oauth2 access in coding's implementation
oauth2.RegisterBrokenAuthHeaderProvider(remote.URL)
return remote, nil
}
@@ -81,7 +79,7 @@ type Coding struct {
// Login authenticates the session and returns the
// remote user details.
func (c *Coding) Login(res http.ResponseWriter, req *http.Request) (*model.User, error) {
config := c.newConfig(httputil.GetURL(req))
config := c.newConfig(server.Config.Server.Host)
// get the OAuth errors
if err := req.FormValue("error"); err != "" {