Initial commit

This commit is contained in:
sas.fajri
2026-04-30 14:27:01 +07:00
commit e29e943c27
70 changed files with 8909 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
package auth
import "net/http"
func Require(secret string) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
username := getSession(r, secret)
if username == "" {
http.Redirect(w, r, basePath+"/mcu-login", http.StatusSeeOther)
return
}
next.ServeHTTP(w, setContext(r, username))
})
}
}