changeset 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 94a1dd4ed50c
children 694f959ba3e7
files auth/middleware.go
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
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...)))
 	}
 }