From 45f2c5bae7cde131aaef4654ab0a767337d0fcf4 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 15 Feb 2022 23:24:27 +0100 Subject: [PATCH] web/admin: fix invalid URLs in example proxy config Signed-off-by: Jens Langhammer --- internal/outpost/proxyv2/application/oauth.go | 5 ++++- internal/outpost/proxyv2/templates/templates.go | 3 ++- web/src/pages/providers/proxy/ProxyProviderViewPage.ts | 9 ++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/internal/outpost/proxyv2/application/oauth.go b/internal/outpost/proxyv2/application/oauth.go index a018f792d..48931daf0 100644 --- a/internal/outpost/proxyv2/application/oauth.go +++ b/internal/outpost/proxyv2/application/oauth.go @@ -66,7 +66,10 @@ func (a *Application) handleRedirect(rw http.ResponseWriter, r *http.Request) { } func (a *Application) handleCallback(rw http.ResponseWriter, r *http.Request) { - s, _ := a.sessions.Get(r, constants.SeesionName) + s, err := a.sessions.Get(r, constants.SeesionName) + if err != nil { + a.log.WithError(err).Trace("failed to get session") + } state, ok := s.Values[constants.SessionOAuthState] if !ok { a.log.Warning("No state saved in session") diff --git a/internal/outpost/proxyv2/templates/templates.go b/internal/outpost/proxyv2/templates/templates.go index 455bedfe3..f9ae7bcad 100644 --- a/internal/outpost/proxyv2/templates/templates.go +++ b/internal/outpost/proxyv2/templates/templates.go @@ -3,7 +3,8 @@ package templates import ( _ "embed" "html/template" - "log" + + log "github.com/sirupsen/logrus" ) //go:embed error.html diff --git a/web/src/pages/providers/proxy/ProxyProviderViewPage.ts b/web/src/pages/providers/proxy/ProxyProviderViewPage.ts index b8909bb43..a76022ea9 100644 --- a/web/src/pages/providers/proxy/ProxyProviderViewPage.ts +++ b/web/src/pages/providers/proxy/ProxyProviderViewPage.ts @@ -92,16 +92,19 @@ export class ProxyProviderViewPage extends LitElement { } renderConfigTemplate(markdown: MarkdownDocument): MarkdownDocument { + const extHost = new URL(this.provider?.externalHost || "http://a"); // See website/docs/providers/proxy/forward_auth.mdx if (this.provider?.mode === ProxyMode.ForwardSingle) { markdown.html = markdown.html .replaceAll("authentik.company", window.location.hostname) - .replaceAll("outpost.company", window.location.hostname) - .replaceAll("app.company", this.provider?.externalHost || ""); + .replaceAll("http://outpost.company:9000", window.location.hostname) + .replaceAll("https://app.company", extHost.toString()) + .replaceAll("app.company", extHost.hostname); } else if (this.provider?.mode == ProxyMode.ForwardDomain) { markdown.html = markdown.html .replaceAll("authentik.company", window.location.hostname) - .replaceAll("outpost.company", this.provider?.externalHost || ""); + .replaceAll("https://app.company", extHost.hostname) + .replaceAll("http://outpost.company:9000", extHost.toString()); } return markdown; }