diff options
Diffstat (limited to 'internal/authz/middleware.go')
| -rw-r--r-- | internal/authz/middleware.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/internal/authz/middleware.go b/internal/authz/middleware.go index 1dd06e3..41672f2 100644 --- a/internal/authz/middleware.go +++ b/internal/authz/middleware.go @@ -7,11 +7,11 @@ import ( "log" "net/http" - "github.com/casbin/casbin/v2" + "git.ofmax.li/go-git-server/internal/admin" "golang.org/x/crypto/bcrypt" ) -func Authentication(authMap TokenMap, next http.HandlerFunc) http.Handler { +func Authentication(authMap TokenMap, next http.Handler) http.Handler { return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { u, p, ok := req.BasicAuth() if !ok { @@ -40,13 +40,13 @@ func Authentication(authMap TokenMap, next http.HandlerFunc) http.Handler { } // Authorization middleware to enforce authoirzation of all requests. -func Authorization(enf *casbin.Enforcer, next http.HandlerFunc) http.Handler { +func Authorization(adminSvc *admin.Service, next http.Handler) http.Handler { return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { ctx := req.Context() urn := ctx.Value("urn") repo := req.URL.Path action := req.Method - ok, err := enf.Enforce(urn, repo, action) + ok, err := adminSvc.Enforce(urn, repo, action) if err != nil { log.Printf("error running enforce %s", err) http.Error(rw, "Bad Request", http.StatusBadRequest) |