package sec import ( "git.clearsky.net.au/cody/gex.git/srv" ) func Middleware(req *srv.Req, res srv.Res) bool { //Session var sess Sess sess.Construct(req, res) sess.Save() req.Ctx["Sess"] = sess pattern := req.Pattern // Route Access Check // Cancel the security check as there are no permissions for this route if len(permissions[pattern]) == 0 { return true } handlerRoles := permissions[pattern] sess = req.Ctx["Sess"].(Sess) for _, role := range handlerRoles { if sess.HasRole(role) { return true } } res.Send("No Access") return false }