feat: handle missing trailing slashes for console and login (#3490)

* handle calls without trailing slash

* build redirect uris correctly

* handle missing trailing slash for login

* sentry as http middleware

* import

* fix build origin
This commit is contained in:
Livio Amstutz
2022-04-26 12:13:16 +02:00
committed by GitHub
parent 388ef6b93b
commit 32986aa60a
5 changed files with 14 additions and 12 deletions

View File

@@ -12,6 +12,7 @@ import (
"github.com/caos/logging"
"github.com/caos/oidc/v2/pkg/op"
"github.com/gorilla/mux"
"github.com/caos/zitadel/internal/api/authz"
http_util "github.com/caos/zitadel/internal/api/http"
@@ -71,9 +72,9 @@ func Start(config Config, externalSecure bool, issuer op.IssuerFromRequest, inst
)
security := middleware.SecurityHeaders(csp(), nil)
handler := &http.ServeMux{}
handler.Handle("/", cache(security(http.FileServer(&spaHandler{http.FS(fSys)}))))
handler.Handle(envRequestPath, instanceHandler(cache(security(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
handler := mux.NewRouter()
handler.Use(cache, security)
handler.Handle(envRequestPath, instanceHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
instance := authz.GetInstance(r.Context())
if instance.InstanceID() == "" {
http.Error(w, "empty instanceID", http.StatusInternalServerError)
@@ -87,7 +88,8 @@ func Start(config Config, externalSecure bool, issuer op.IssuerFromRequest, inst
}
_, err = w.Write(environmentJSON)
logging.OnError(err).Error("error serving environment.json")
})))))
})))
handler.SkipClean(true).PathPrefix("").Handler(http.FileServer(&spaHandler{http.FS(fSys)}))
return handler, nil
}