outpost/embedded: fix login URL not being set correctly from outpost config
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
c079f9e339
commit
7e62b82d56
|
@ -24,8 +24,9 @@ const ConfigErrorReportingEnvironment = "error_reporting_environment"
|
||||||
|
|
||||||
// APIController main controller which connects to the authentik api via http and ws
|
// APIController main controller which connects to the authentik api via http and ws
|
||||||
type APIController struct {
|
type APIController struct {
|
||||||
Client *api.APIClient
|
Client *api.APIClient
|
||||||
token string
|
Outpost api.Outpost
|
||||||
|
token string
|
||||||
|
|
||||||
Server Outpost
|
Server Outpost
|
||||||
|
|
||||||
|
@ -72,6 +73,7 @@ func NewAPIController(akURL url.URL, token string) *APIController {
|
||||||
|
|
||||||
reloadOffset: time.Duration(rand.Intn(10)) * time.Second,
|
reloadOffset: time.Duration(rand.Intn(10)) * time.Second,
|
||||||
instanceUUID: uuid.New(),
|
instanceUUID: uuid.New(),
|
||||||
|
Outpost: outpost,
|
||||||
}
|
}
|
||||||
ac.logger.Debugf("HA Reload offset: %s", ac.reloadOffset)
|
ac.logger.Debugf("HA Reload offset: %s", ac.reloadOffset)
|
||||||
ac.initWS(akURL, strfmt.UUID(outpost.Pk))
|
ac.initWS(akURL, strfmt.UUID(outpost.Pk))
|
||||||
|
|
|
@ -2,7 +2,6 @@ package proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -37,9 +36,13 @@ func intToPointer(i int) *int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pb *providerBundle) replaceLocal(url string) string {
|
func (pb *providerBundle) replaceLocal(url string) string {
|
||||||
if strings.Contains(url, "localhost:8000") {
|
if strings.HasPrefix(url, "http://localhost:8000") {
|
||||||
f := strings.ReplaceAll(url, "localhost:8000", pb.s.ak.Client.GetConfig().Host)
|
authentikHost, c := pb.s.ak.Outpost.Config["authentik_host"]
|
||||||
f = strings.ReplaceAll(f, "http://", fmt.Sprintf("%s://", pb.s.ak.Client.GetConfig().Scheme))
|
if !c {
|
||||||
|
pb.log.Warning("Outpost has localhost API Connection but no authentik_host is configured.")
|
||||||
|
return url
|
||||||
|
}
|
||||||
|
f := strings.ReplaceAll(url, "http://localhost:8000", authentikHost.(string))
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
return url
|
return url
|
||||||
|
|
Reference in New Issue