diff --git a/internal/outpost/proxy/proxy.go b/internal/outpost/proxy/proxy.go index 5ead7895f..e8343d903 100644 --- a/internal/outpost/proxy/proxy.go +++ b/internal/outpost/proxy/proxy.go @@ -22,6 +22,7 @@ import ( "github.com/oauth2-proxy/oauth2-proxy/providers" "goauthentik.io/api" "goauthentik.io/internal/utils/web" + staticWeb "goauthentik.io/web" log "github.com/sirupsen/logrus" ) @@ -255,11 +256,18 @@ func (p *OAuthProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) { p.AuthenticateOnly(rw, req) case path == p.UserInfoPath: p.UserInfo(rw, req) + case strings.HasPrefix(path, fmt.Sprintf("%s/static", p.ProxyPrefix)): + p.ServeStatic(rw, req) default: p.Proxy(rw, req) } } +func (p *OAuthProxy) ServeStatic(rw http.ResponseWriter, req *http.Request) { + staticFs := http.FileServer(http.FS(staticWeb.StaticDist)) + http.StripPrefix(fmt.Sprintf("%s/static", p.ProxyPrefix), staticFs).ServeHTTP(rw, req) +} + //UserInfo endpoint outputs session email and preferred username in JSON format func (p *OAuthProxy) UserInfo(rw http.ResponseWriter, req *http.Request) { diff --git a/internal/outpost/proxy/templates.go b/internal/outpost/proxy/templates.go index ca61f9ca3..607bfb577 100644 --- a/internal/outpost/proxy/templates.go +++ b/internal/outpost/proxy/templates.go @@ -4,25 +4,11 @@ import ( "html/template" log "github.com/sirupsen/logrus" + "goauthentik.io/internal/outpost/proxy/templates" ) func getTemplates() *template.Template { - t, err := template.New("foo").Parse(`{{define "error.html"}} - - - - {{.Title}} - - - - -

{{.Title}}

-

{{.Message}}

-
-

Sign In

-

Powered by authentik

- -{{end}}`) + t, err := template.New("foo").Parse(templates.ErrorTemplate) if err != nil { log.Fatalf("failed parsing template %s", err) } diff --git a/internal/outpost/proxy/templates/error.html b/internal/outpost/proxy/templates/error.html new file mode 100644 index 000000000..ed4e8744d --- /dev/null +++ b/internal/outpost/proxy/templates/error.html @@ -0,0 +1,65 @@ +{{define "error.html"}} + + + + + + {{.Title}} + + + + + + +
+ + + + + + + + + + + +
+
+
+ +
+ + + +
+ +
+
+ + +{{end}} diff --git a/internal/outpost/proxy/templates/templates.go b/internal/outpost/proxy/templates/templates.go new file mode 100644 index 000000000..bb37f3ff9 --- /dev/null +++ b/internal/outpost/proxy/templates/templates.go @@ -0,0 +1,6 @@ +package templates + +import _ "embed" + +//go:embed error.html +var ErrorTemplate string diff --git a/proxy.Dockerfile b/proxy.Dockerfile index df48d274f..b23aa26b3 100644 --- a/proxy.Dockerfile +++ b/proxy.Dockerfile @@ -13,12 +13,24 @@ RUN docker-entrypoint.sh generate \ --additional-properties=packageName=api,enumClassPrefix=true,useOneOfDiscriminatorLookup=true && \ rm -f /local/api/go.mod /local/api/go.sum +# Stage 2: Build website +FROM node as web-builder + +COPY ./web /static/ + +ENV NODE_ENV=production +RUN cd /static && npm i && npm run build + # Stage 2: Build FROM golang:1.17.0 AS builder WORKDIR /go/src/goauthentik.io COPY . . +COPY --from=web-builder /static/robots.txt /work/web/robots.txt +COPY --from=web-builder /static/security.txt /work/web/security.txt +COPY --from=web-builder /static/dist/ /work/web/dist/ +COPY --from=web-builder /static/authentik/ /work/web/authentik/ COPY --from=api-builder /local/api api RUN go build -o /go/proxy ./cmd/proxy