Mercurial > gemma
comparison 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 |
comparison
equal
deleted
inserted
replaced
229:94a1dd4ed50c | 230:8a226dc1c6ff |
---|---|
72 } | 72 } |
73 return false | 73 return false |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 func EnsureRole(name string) func(func(http.ResponseWriter, *http.Request)) http.Handler { | 77 func EnsureRole(roles ...string) func(func(http.ResponseWriter, *http.Request)) http.Handler { |
78 return func(fn func(http.ResponseWriter, *http.Request)) http.Handler { | 78 return func(fn func(http.ResponseWriter, *http.Request)) http.Handler { |
79 return SessionMiddleware(SessionChecker(http.HandlerFunc(fn), HasRole(name))) | 79 return SessionMiddleware(SessionChecker(http.HandlerFunc(fn), HasRole(roles...))) |
80 } | 80 } |
81 } | 81 } |