From 7d3c9e8db4521ec77ab928cad48fba498503e3dd Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 24 Feb 2024 18:40:45 +0100 Subject: [PATCH 01/20] initial subpath support Signed-off-by: Jens Langhammer --- authentik/lib/default.yml | 1 + authentik/lib/sentry.py | 3 ++- authentik/root/urls.py | 11 ++++++++--- cmd/server/healthcheck.go | 2 +- internal/config/struct.go | 5 +++++ internal/web/metrics.go | 2 +- internal/web/static.go | 2 +- internal/web/web.go | 3 ++- 8 files changed, 21 insertions(+), 8 deletions(-) diff --git a/authentik/lib/default.yml b/authentik/lib/default.yml index 22eda58ae872..4b68d7f1021a 100644 --- a/authentik/lib/default.yml +++ b/authentik/lib/default.yml @@ -122,6 +122,7 @@ web: # No default here as it's set dynamically # workers: 2 threads: 4 + path: / worker: concurrency: 2 diff --git a/authentik/lib/sentry.py b/authentik/lib/sentry.py index b42a299660f2..ceec11ffd378 100644 --- a/authentik/lib/sentry.py +++ b/authentik/lib/sentry.py @@ -36,6 +36,7 @@ from authentik.lib.utils.reflection import get_env LOGGER = get_logger() +_root_path = CONFIG.get("web.path", "/") class SentryIgnoredException(Exception): @@ -89,7 +90,7 @@ def traces_sampler(sampling_context: dict) -> float: path = sampling_context.get("asgi_scope", {}).get("path", "") _type = sampling_context.get("asgi_scope", {}).get("type", "") # Ignore all healthcheck routes - if path.startswith("/-/health") or path.startswith("/-/metrics"): + if path.startswith(f"{_root_path}-/health") or path.startswith(f"{_root_path}-/metrics"): return 0 if _type == "websocket": return 0 diff --git a/authentik/root/urls.py b/authentik/root/urls.py index 1b03051fddd6..e5aba664c2dc 100644 --- a/authentik/root/urls.py +++ b/authentik/root/urls.py @@ -4,6 +4,7 @@ from structlog.stdlib import get_logger from authentik.core.views import error +from authentik.lib.config import CONFIG from authentik.lib.utils.reflection import get_apps from authentik.root.monitoring import LiveView, MetricsView, ReadyView @@ -14,7 +15,7 @@ handler404 = error.NotFoundView.as_view() handler500 = error.ServerErrorView.as_view() -urlpatterns = [] +authentik_urlpatterns = [] for _authentik_app in get_apps(): mountpoints = None @@ -35,7 +36,7 @@ namespace=namespace, ), ) - urlpatterns.append(_path) + authentik_urlpatterns.append(_path) LOGGER.debug( "Mounted URLs", app_name=_authentik_app.name, @@ -43,8 +44,12 @@ namespace=namespace, ) -urlpatterns += [ +authentik_urlpatterns += [ path("-/metrics/", MetricsView.as_view(), name="metrics"), path("-/health/live/", LiveView.as_view(), name="health-live"), path("-/health/ready/", ReadyView.as_view(), name="health-ready"), ] + +urlpatterns = [ + path(CONFIG.get("web.path", "/")[1:], include(authentik_urlpatterns)) +] diff --git a/cmd/server/healthcheck.go b/cmd/server/healthcheck.go index d37cfb483eb4..0f0ccec02929 100644 --- a/cmd/server/healthcheck.go +++ b/cmd/server/healthcheck.go @@ -47,7 +47,7 @@ func checkServer() int { h := &http.Client{ Transport: web.NewUserAgentTransport("goauthentik.io/healthcheck", http.DefaultTransport), } - url := fmt.Sprintf("http://%s/-/health/live/", config.Get().Listen.HTTP) + url := fmt.Sprintf("http://%s%s-/health/live/", config.Get().Listen.HTTP, config.Get().Web.Path) res, err := h.Head(url) if err != nil { log.WithError(err).Warning("failed to send healthcheck request") diff --git a/internal/config/struct.go b/internal/config/struct.go index 0964d7583c2d..c0cd6d8e8e37 100644 --- a/internal/config/struct.go +++ b/internal/config/struct.go @@ -14,6 +14,7 @@ type Config struct { // Config for both core and outposts Debug bool `yaml:"debug" env:"AUTHENTIK_DEBUG, overwrite"` Listen ListenConfig `yaml:"listen" env:", prefix=AUTHENTIK_LISTEN__"` + Web WebConfig `yaml:"web" env:", prefix=AUTHENTIK__WEB__"` // Outpost specific config // These are only relevant for proxy/ldap outposts, and cannot be set via YAML @@ -71,3 +72,7 @@ type OutpostConfig struct { Discover bool `yaml:"discover" env:"DISCOVER, overwrite"` DisableEmbeddedOutpost bool `yaml:"disable_embedded_outpost" env:"DISABLE_EMBEDDED_OUTPOST, overwrite"` } + +type WebConfig struct { + Path string `yaml:"path" env:"PATH, overwrite"` +} diff --git a/internal/web/metrics.go b/internal/web/metrics.go index baf486e26d18..af5cf2de0d0f 100644 --- a/internal/web/metrics.go +++ b/internal/web/metrics.go @@ -31,7 +31,7 @@ func (ws *WebServer) runMetricsServer() { ).ServeHTTP(rw, r) // Get upstream metrics - re, err := http.NewRequest("GET", fmt.Sprintf("%s/-/metrics/", ws.ul.String()), nil) + re, err := http.NewRequest("GET", fmt.Sprintf("%s%s-/metrics/", ws.ul.String(), config.Get().Web.Path), nil) if err != nil { l.WithError(err).Warning("failed to get upstream metrics") return diff --git a/internal/web/static.go b/internal/web/static.go index 1d6d1888ec75..19a8e3569112 100644 --- a/internal/web/static.go +++ b/internal/web/static.go @@ -14,7 +14,7 @@ import ( ) func (ws *WebServer) configureStatic() { - statRouter := ws.lh.NewRoute().Subrouter() + statRouter := ws.lh.NewRoute().Path(config.Get().Web.Path).Subrouter() statRouter.Use(ws.staticHeaderMiddleware) indexLessRouter := statRouter.NewRoute().Subrouter() indexLessRouter.Use(web.DisableIndex) diff --git a/internal/web/web.go b/internal/web/web.go index cce90e6c5e0b..a6e2c1add911 100644 --- a/internal/web/web.go +++ b/internal/web/web.go @@ -81,8 +81,9 @@ func NewWebServer() *WebServer { } ws.configureStatic() ws.configureProxy() + hcUrl := fmt.Sprintf("%s%s-/health/live/", ws.ul.String(), config.Get().Web.Path) ws.g = gounicorn.New(func() bool { - req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/-/health/live/", ws.ul.String()), nil) + req, err := http.NewRequest(http.MethodGet, hcUrl, nil) if err != nil { ws.log.WithError(err).Warning("failed to create request for healthcheck") return false From 1e8faf8e1b181633f66bf285e93978f4dfd6d649 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 24 Feb 2024 18:43:56 +0100 Subject: [PATCH 02/20] make outpost compatible Signed-off-by: Jens Langhammer --- cmd/server/server.go | 2 +- internal/outpost/ak/api.go | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cmd/server/server.go b/cmd/server/server.go index 9324c984de46..a09451d1258f 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -61,7 +61,7 @@ var rootCmd = &cobra.Command{ ex := common.Init() defer common.Defer() - u, err := url.Parse(fmt.Sprintf("http://%s", config.Get().Listen.HTTP)) + u, err := url.Parse(fmt.Sprintf("http://%s%s", config.Get().Listen.HTTP, config.Get().Web.Path)) if err != nil { panic(err) } diff --git a/internal/outpost/ak/api.go b/internal/outpost/ak/api.go index 1f744010a771..cfdc0cd1a99d 100644 --- a/internal/outpost/ak/api.go +++ b/internal/outpost/ak/api.go @@ -54,10 +54,10 @@ type APIController struct { func NewAPIController(akURL url.URL, token string) *APIController { rsp := sentry.StartSpan(context.Background(), "authentik.outposts.init") - config := api.NewConfiguration() - config.Host = akURL.Host - config.Scheme = akURL.Scheme - config.HTTPClient = &http.Client{ + apiConfig := api.NewConfiguration() + apiConfig.Host = akURL.Host + apiConfig.Scheme = akURL.Scheme + apiConfig.HTTPClient = &http.Client{ Transport: web.NewUserAgentTransport( constants.OutpostUserAgent(), web.NewTracingTransport( @@ -66,10 +66,15 @@ func NewAPIController(akURL url.URL, token string) *APIController { ), ), } - config.AddDefaultHeader("Authorization", fmt.Sprintf("Bearer %s", token)) + apiConfig.Servers = api.ServerConfigurations{ + { + URL: fmt.Sprintf("%sapi/v3", akURL.Path), + }, + } + apiConfig.AddDefaultHeader("Authorization", fmt.Sprintf("Bearer %s", token)) // create the API client, with the transport - apiClient := api.NewAPIClient(config) + apiClient := api.NewAPIClient(apiConfig) log := log.WithField("logger", "authentik.outpost.ak-api-controller") From 7bcdff3c0070d311322476178ac8f500dedda2f9 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 24 Feb 2024 18:45:54 +0100 Subject: [PATCH 03/20] fix static files somewhat Signed-off-by: Jens Langhammer --- authentik/root/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/authentik/root/settings.py b/authentik/root/settings.py index 11d847b6ce9f..ef9032af7821 100644 --- a/authentik/root/settings.py +++ b/authentik/root/settings.py @@ -389,7 +389,7 @@ # https://docs.djangoproject.com/en/2.1/howto/static-files/ STATICFILES_DIRS = [BASE_DIR / Path("web")] -STATIC_URL = "/static/" +STATIC_URL = CONFIG.get("web.path", "/")+"static/" STORAGES = { "staticfiles": { From c784c99e1d2a6d14602a940641fb7e349c791a4e Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 24 Feb 2024 19:10:53 +0100 Subject: [PATCH 04/20] fix web interface Signed-off-by: Jens Langhammer --- authentik/core/templates/base/header_js.html | 3 +++ authentik/core/views/interface.py | 2 ++ web/src/common/api/config.ts | 2 +- web/src/common/global.ts | 6 ++++++ web/src/common/ws.ts | 3 ++- 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/authentik/core/templates/base/header_js.html b/authentik/core/templates/base/header_js.html index a67a0b3daea9..d8052ba4014f 100644 --- a/authentik/core/templates/base/header_js.html +++ b/authentik/core/templates/base/header_js.html @@ -9,6 +9,9 @@ versionFamily: "{{ version_family }}", versionSubdomain: "{{ version_subdomain }}", build: "{{ build }}", + api: { + base: "{{ base_url }}", + }, }; window.addEventListener("DOMContentLoaded", () => { {% for message in messages %} diff --git a/authentik/core/views/interface.py b/authentik/core/views/interface.py index 2a7dbda558cb..5eb01567d00d 100644 --- a/authentik/core/views/interface.py +++ b/authentik/core/views/interface.py @@ -12,6 +12,7 @@ from authentik.api.v3.config import ConfigView from authentik.brands.api import CurrentBrandSerializer from authentik.flows.models import Flow +from authentik.lib.config import CONFIG class InterfaceView(TemplateView): @@ -24,6 +25,7 @@ def get_context_data(self, **kwargs: Any) -> dict[str, Any]: kwargs["version_subdomain"] = f"version-{LOCAL_VERSION.major}-{LOCAL_VERSION.minor}" kwargs["build"] = get_build_hash() kwargs["url_kwargs"] = self.kwargs + kwargs["base_url"] = self.request.build_absolute_uri(CONFIG.get("web.path", "/")) return super().get_context_data(**kwargs) diff --git a/web/src/common/api/config.ts b/web/src/common/api/config.ts index dd1a2c1b75e9..8187a974b9da 100644 --- a/web/src/common/api/config.ts +++ b/web/src/common/api/config.ts @@ -68,7 +68,7 @@ export function getMetaContent(key: string): string { } export const DEFAULT_CONFIG = new Configuration({ - basePath: (process.env.AK_API_BASE_PATH || window.location.origin) + "/api/v3", + basePath: `${globalAK().api.base}api/v3`, headers: { "sentry-trace": getMetaContent("sentry-trace"), }, diff --git a/web/src/common/global.ts b/web/src/common/global.ts index 990303df0d43..390aadb976d1 100644 --- a/web/src/common/global.ts +++ b/web/src/common/global.ts @@ -11,6 +11,9 @@ export interface GlobalAuthentik { versionFamily: string; versionSubdomain: string; build: string; + api: { + base: string; + }; } export interface AuthentikWindow { @@ -35,6 +38,9 @@ export function globalAK(): GlobalAuthentik { versionFamily: "", versionSubdomain: "", build: "", + api: { + base: ( process.env.AK_API_BASE_PATH || window.location.origin), + } }; } return ak; diff --git a/web/src/common/ws.ts b/web/src/common/ws.ts index 29823d603bcb..740d3f61f5c8 100644 --- a/web/src/common/ws.ts +++ b/web/src/common/ws.ts @@ -1,3 +1,4 @@ +import { globalAK } from "@goauthentik/app/common/global"; import { EVENT_MESSAGE, EVENT_WS_MESSAGE } from "@goauthentik/common/constants"; import { MessageLevel } from "@goauthentik/common/messages"; @@ -22,7 +23,7 @@ export class WebsocketClient { connect(): void { if (navigator.webdriver) return; const wsUrl = `${window.location.protocol.replace("http", "ws")}//${ - window.location.host + globalAK().api.base }/ws/client/`; this.messageSocket = new WebSocket(wsUrl); this.messageSocket.addEventListener("open", () => { From b0caa7bce9f15ac0f482d31087127297ec9408b6 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 24 Feb 2024 19:37:01 +0100 Subject: [PATCH 05/20] fix most static stuff Signed-off-by: Jens Langhammer --- internal/web/metrics.go | 2 +- internal/web/proxy.go | 9 +++--- internal/web/static.go | 70 ++++++++++++++++++++++++++++++----------- internal/web/web.go | 34 ++++++++++---------- 4 files changed, 74 insertions(+), 41 deletions(-) diff --git a/internal/web/metrics.go b/internal/web/metrics.go index af5cf2de0d0f..e816a99e259d 100644 --- a/internal/web/metrics.go +++ b/internal/web/metrics.go @@ -31,7 +31,7 @@ func (ws *WebServer) runMetricsServer() { ).ServeHTTP(rw, r) // Get upstream metrics - re, err := http.NewRequest("GET", fmt.Sprintf("%s%s-/metrics/", ws.ul.String(), config.Get().Web.Path), nil) + re, err := http.NewRequest("GET", fmt.Sprintf("%s%s-/metrics/", ws.upstreamURL.String(), config.Get().Web.Path), nil) if err != nil { l.WithError(err).Warning("failed to get upstream metrics") return diff --git a/internal/web/proxy.go b/internal/web/proxy.go index 56f81a0726cc..8961fc7d096a 100644 --- a/internal/web/proxy.go +++ b/internal/web/proxy.go @@ -9,14 +9,15 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" + "goauthentik.io/internal/config" "goauthentik.io/internal/utils/sentry" ) func (ws *WebServer) configureProxy() { // Reverse proxy to the application server director := func(req *http.Request) { - req.URL.Scheme = ws.ul.Scheme - req.URL.Host = ws.ul.Host + req.URL.Scheme = ws.upstreamURL.Scheme + req.URL.Host = ws.upstreamURL.Host if _, ok := req.Header["User-Agent"]; !ok { // explicitly disable User-Agent so it's not set to default value req.Header.Set("User-Agent", "") @@ -32,10 +33,10 @@ func (ws *WebServer) configureProxy() { } rp.ErrorHandler = ws.proxyErrorHandler rp.ModifyResponse = ws.proxyModifyResponse - ws.m.Path("/-/health/live/").HandlerFunc(sentry.SentryNoSample(func(rw http.ResponseWriter, r *http.Request) { + ws.mainRouter.PathPrefix(config.Get().Web.Path).Path("/-/health/live/").HandlerFunc(sentry.SentryNoSample(func(rw http.ResponseWriter, r *http.Request) { rw.WriteHeader(204) })) - ws.m.PathPrefix("/").HandlerFunc(sentry.SentryNoSample(func(rw http.ResponseWriter, r *http.Request) { + ws.mainRouter.PathPrefix(config.Get().Web.Path).HandlerFunc(sentry.SentryNoSample(func(rw http.ResponseWriter, r *http.Request) { if !ws.g.IsRunning() { ws.proxyErrorHandler(rw, r, errors.New("authentik starting")) return diff --git a/internal/web/static.go b/internal/web/static.go index 19a8e3569112..1bc25d6ac230 100644 --- a/internal/web/static.go +++ b/internal/web/static.go @@ -14,41 +14,73 @@ import ( ) func (ws *WebServer) configureStatic() { - statRouter := ws.lh.NewRoute().Path(config.Get().Web.Path).Subrouter() - statRouter.Use(ws.staticHeaderMiddleware) - indexLessRouter := statRouter.NewRoute().Subrouter() + // Setup routers + staticRouter := ws.loggingRouter.NewRoute().Subrouter() + staticRouter.Use(ws.staticHeaderMiddleware) + indexLessRouter := staticRouter.NewRoute().Subrouter() + // Specifically disable index indexLessRouter.Use(web.DisableIndex) + distFs := http.FileServer(http.Dir("./web/dist")) - distHandler := http.StripPrefix("/static/dist/", distFs) - authentikHandler := http.StripPrefix("/static/authentik/", http.FileServer(http.Dir("./web/authentik"))) + + pathStripper := func(handler http.Handler, paths ...string) http.Handler { + h := handler + for _, path := range paths { + h = http.StripPrefix(path, h) + } + return h + } + helpHandler := http.FileServer(http.Dir("./website/help/")) - indexLessRouter.PathPrefix("/static/dist/").Handler(distHandler) - indexLessRouter.PathPrefix("/static/authentik/").Handler(authentikHandler) - // Prevent font-loading issues on safari, which loads fonts relatively to the URL the browser is on - indexLessRouter.PathPrefix("/if/flow/{flow_slug}/assets").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + indexLessRouter.PathPrefix(config.Get().Web.Path).PathPrefix("/static/dist/").Handler(pathStripper( + distFs, + "static/dist/", + config.Get().Web.Path, + )) + indexLessRouter.PathPrefix(config.Get().Web.Path).PathPrefix("/static/authentik/").Handler(pathStripper( + http.FileServer(http.Dir("./web/authentik")), + "static/authentik/", + config.Get().Web.Path, + )) + + indexLessRouter.PathPrefix(config.Get().Web.Path).PathPrefix("/if/flow/{flow_slug}/assets").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) - web.DisableIndex(http.StripPrefix(fmt.Sprintf("/if/flow/%s", vars["flow_slug"]), distFs)).ServeHTTP(rw, r) + pathStripper( + distFs, + config.Get().Web.Path, + "if/flow", + vars["flow_slug"], + ).ServeHTTP(rw, r) }) - indexLessRouter.PathPrefix("/if/admin/assets").Handler(http.StripPrefix("/if/admin", distFs)) - indexLessRouter.PathPrefix("/if/user/assets").Handler(http.StripPrefix("/if/user", distFs)) - indexLessRouter.PathPrefix("/if/rac/{app_slug}/assets").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + indexLessRouter.PathPrefix(config.Get().Web.Path).PathPrefix("/if/admin/assets").Handler(http.StripPrefix(fmt.Sprintf("%sif/admin", config.Get().Web.Path), distFs)) + indexLessRouter.PathPrefix(config.Get().Web.Path).PathPrefix("/if/user/assets").Handler(http.StripPrefix(fmt.Sprintf("%sif/user", config.Get().Web.Path), distFs)) + indexLessRouter.PathPrefix(config.Get().Web.Path).PathPrefix("/if/rac/{app_slug}/assets").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) - web.DisableIndex(http.StripPrefix(fmt.Sprintf("/if/rac/%s", vars["app_slug"]), distFs)).ServeHTTP(rw, r) + pathStripper( + distFs, + config.Get().Web.Path, + "if/rac", + vars["app_slug"], + ).ServeHTTP(rw, r) }) // Media files, if backend is file if config.Get().Storage.Media.Backend == "file" { fsMedia := http.FileServer(http.Dir(config.Get().Storage.Media.File.Path)) - indexLessRouter.PathPrefix("/media/").Handler(http.StripPrefix("/media", fsMedia)) + indexLessRouter.PathPrefix(config.Get().Web.Path).PathPrefix("/media/").Handler(http.StripPrefix("/media", fsMedia)) } - statRouter.PathPrefix("/if/help/").Handler(http.StripPrefix("/if/help/", helpHandler)) - statRouter.PathPrefix("/help").Handler(http.RedirectHandler("/if/help/", http.StatusMovedPermanently)) + staticRouter.PathPrefix(config.Get().Web.Path).PathPrefix("/if/help/").Handler(pathStripper( + helpHandler, + config.Get().Web.Path, + "/if/help/", + )) + staticRouter.PathPrefix(config.Get().Web.Path).PathPrefix("/help").Handler(http.RedirectHandler(fmt.Sprintf("%sif/help/", config.Get().Web.Path), http.StatusMovedPermanently)) - ws.lh.Path("/robots.txt").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + staticRouter.PathPrefix(config.Get().Web.Path).Path("/robots.txt").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { rw.Header()["Content-Type"] = []string{"text/plain"} rw.WriteHeader(200) _, err := rw.Write(staticWeb.RobotsTxt) @@ -56,7 +88,7 @@ func (ws *WebServer) configureStatic() { ws.log.WithError(err).Warning("failed to write response") } }) - ws.lh.Path("/.well-known/security.txt").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + staticRouter.PathPrefix(config.Get().Web.Path).Path("/.well-known/security.txt").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { rw.Header()["Content-Type"] = []string{"text/plain"} rw.WriteHeader(200) _, err := rw.Write(staticWeb.SecurityTxt) diff --git a/internal/web/web.go b/internal/web/web.go index a6e2c1add911..825c69786ffe 100644 --- a/internal/web/web.go +++ b/internal/web/web.go @@ -32,13 +32,13 @@ type WebServer struct { ProxyServer *proxyv2.ProxyServer BrandTLS *brand_tls.Watcher - g *gounicorn.GoUnicorn - gr bool - m *mux.Router - lh *mux.Router - log *log.Entry - uc *http.Client - ul *url.URL + g *gounicorn.GoUnicorn + gunicornReady bool + mainRouter *mux.Router + loggingRouter *mux.Router + log *log.Entry + upstreamClient *http.Client + upstreamURL *url.URL } const UnixSocketName = "authentik-core.sock" @@ -72,16 +72,16 @@ func NewWebServer() *WebServer { u, _ := url.Parse("http://localhost:8000") ws := &WebServer{ - m: mainHandler, - lh: loggingHandler, - log: l, - gr: true, - uc: upstreamClient, - ul: u, + mainRouter: mainHandler, + loggingRouter: loggingHandler, + log: l, + gunicornReady: true, + upstreamClient: upstreamClient, + upstreamURL: u, } ws.configureStatic() ws.configureProxy() - hcUrl := fmt.Sprintf("%s%s-/health/live/", ws.ul.String(), config.Get().Web.Path) + hcUrl := fmt.Sprintf("%s%s-/health/live/", ws.upstreamURL.String(), config.Get().Web.Path) ws.g = gounicorn.New(func() bool { req, err := http.NewRequest(http.MethodGet, hcUrl, nil) if err != nil { @@ -107,7 +107,7 @@ func (ws *WebServer) Start() { func (ws *WebServer) attemptStartBackend() { for { - if !ws.gr { + if !ws.gunicornReady { return } err := ws.g.Start() @@ -135,7 +135,7 @@ func (ws *WebServer) Core() *gounicorn.GoUnicorn { } func (ws *WebServer) upstreamHttpClient() *http.Client { - return ws.uc + return ws.upstreamClient } func (ws *WebServer) Shutdown() { @@ -160,7 +160,7 @@ func (ws *WebServer) listenPlain() { func (ws *WebServer) serve(listener net.Listener) { srv := &http.Server{ - Handler: ws.m, + Handler: ws.mainRouter, } // See https://golang.org/pkg/net/http/#Server.Shutdown From 69e9676704fd2ccae2aa06c877d3c47c3f8e55f1 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 24 Feb 2024 19:37:09 +0100 Subject: [PATCH 06/20] fix most web links Signed-off-by: Jens Langhammer --- authentik/core/templates/login/base_full.html | 4 ++-- internal/web/static.go | 6 ++---- web/src/common/ws.ts | 5 ++--- web/src/elements/enterprise/EnterpriseStatusBanner.ts | 3 ++- web/src/elements/notifications/APIDrawer.ts | 3 ++- web/src/elements/notifications/NotificationDrawer.ts | 3 ++- web/src/elements/sidebar/SidebarUser.ts | 5 +++-- web/src/user/LibraryApplication/index.ts | 3 ++- web/src/user/LibraryPage/ApplicationEmptyState.ts | 4 ++-- web/src/user/UserInterface.ts | 5 +++-- .../user/user-settings/details/UserSettingsFlowExecutor.ts | 3 ++- .../user/user-settings/details/stages/prompt/PromptStage.ts | 3 ++- 12 files changed, 26 insertions(+), 21 deletions(-) diff --git a/authentik/core/templates/login/base_full.html b/authentik/core/templates/login/base_full.html index c88692a63230..33131eb263d0 100644 --- a/authentik/core/templates/login/base_full.html +++ b/authentik/core/templates/login/base_full.html @@ -4,7 +4,7 @@ {% load i18n %} {% block head_before %} - + {% include "base/header_js.html" %} @@ -13,7 +13,7 @@ {% block head %}