Add auth, rest api, svelte frontend, build structure

This commit is contained in:
2025-06-02 08:44:10 +02:00
parent 97be451306
commit 17ab7c4929
222 changed files with 3057 additions and 136 deletions

View File

@@ -5,7 +5,7 @@ import (
"net/http"
)
func RecoverMiddleware(next http.Handler) http.Handler {
func Recover(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
defer func() {
if err := recover(); err != nil {

View File

@@ -0,0 +1,27 @@
package middleware
import (
"net/http"
"git.clustercockpit.org/moebiusband/go-http-skeleton/internal/auth"
"git.clustercockpit.org/moebiusband/go-http-skeleton/web"
)
func SecuredCheck(next http.Handler) http.Handler {
authHandle := auth.GetAuthInstance()
return authHandle.Auth(
// On success;
next,
// On failure:
func(rw http.ResponseWriter, r *http.Request, err error) {
rw.WriteHeader(http.StatusUnauthorized)
web.RenderTemplate(rw, "login", web.PageData{
Title: "Authentication failed - ClusterCockpit",
MsgType: "alert-danger",
Message: err.Error(),
Redirect: r.RequestURI,
})
})
}