1234567891011121314151617181920212223242526272829303132333435 |
- 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
- }
|