diff options
| author | Max Resnick <max@ofmax.li> | 2022-11-25 21:28:54 -0800 |
|---|---|---|
| committer | Max Resnick <max@ofmax.li> | 2022-12-11 21:13:05 -0800 |
| commit | ab38860d69c194969bea9ae5ef385c35eb94b988 (patch) | |
| tree | c319053354cb2a772609b706368b1fd5741a44fc /internal/authz | |
| parent | 9e79e588131b0d59abefd84405cb7908bc2baa77 (diff) | |
| download | go-git-server-ab38860d69c194969bea9ae5ef385c35eb94b988.tar.gz | |
add tests, new policies, init repo manager
Diffstat (limited to '')
| -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) |