Mercurial > gemma
diff auth/middleware.go @ 230:8a226dc1c6ff
Made auth.Role variadic to allow to express that a endpoint may be used by more than one role.
auth.HasRole already had this ability but I forgot to pull it through.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 26 Jul 2018 13:39:59 +0200 |
parents | 63dd5216eee4 |
children | 3771788d3dae |
line wrap: on
line diff
--- a/auth/middleware.go Thu Jul 26 13:32:49 2018 +0200 +++ b/auth/middleware.go Thu Jul 26 13:39:59 2018 +0200 @@ -74,8 +74,8 @@ } } -func EnsureRole(name string) func(func(http.ResponseWriter, *http.Request)) http.Handler { +func EnsureRole(roles ...string) func(func(http.ResponseWriter, *http.Request)) http.Handler { return func(fn func(http.ResponseWriter, *http.Request)) http.Handler { - return SessionMiddleware(SessionChecker(http.HandlerFunc(fn), HasRole(name))) + return SessionMiddleware(SessionChecker(http.HandlerFunc(fn), HasRole(roles...))) } }