Add login fallback (#3302)

Part of https://github.com/matrix-org/dendrite/issues/3216

The files are basically copied from Synapse, with minor changes to the
called endpoints. We never seem to have had the
`/_matrix/static/client/login/` endpoint, this adds it.
This commit is contained in:
Till 2024-01-17 17:08:57 +01:00 committed by GitHub
parent dae1ef2e46
commit bebf701dce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 430 additions and 0 deletions

View file

@ -50,6 +50,9 @@ import (
//go:embed static/*.gotmpl
var staticContent embed.FS
//go:embed static/client/login
var loginFallback embed.FS
const HTTPServerTimeout = time.Minute * 5
// CreateClient creates a new client (normally used for media fetch requests).
@ -158,6 +161,14 @@ func SetupAndServeHTTP(
_, _ = w.Write(landingPage.Bytes())
})
// We only need the files beneath the static/client/login folder.
sub, err := fs.Sub(loginFallback, "static/client/login")
if err != nil {
logrus.Panicf("unable to read embedded files, this should never happen: %s", err)
}
// Serve a static page for login fallback
routers.Static.PathPrefix("/client/login/").Handler(http.StripPrefix("/_matrix/static/client/login/", http.FileServer(http.FS(sub))))
var clientHandler http.Handler
clientHandler = routers.Client
if cfg.Global.Sentry.Enabled {