aboutsummaryrefslogtreecommitdiff
path: root/internal/authz/middleware.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--internal/authz/middleware.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/internal/authz/middleware.go b/internal/authz/middleware.go
index 6763323..abebcdb 100644
--- a/internal/authz/middleware.go
+++ b/internal/authz/middleware.go
@@ -54,6 +54,7 @@ func Authorization(adminSvc *admin.Servicer, next http.Handler) http.Handler {
urn, ok := ctx.Value(AuthzUrnKey).(string)
if !ok || urn == "" {
http.Error(rw, "Bad Request", http.StatusBadRequest)
+ return
}
repo := req.URL.Path
action := req.Method
@@ -61,10 +62,12 @@ func Authorization(adminSvc *admin.Servicer, next http.Handler) http.Handler {
if err != nil {
log.Printf("error running enforce %s", err)
http.Error(rw, "Bad Request", http.StatusBadRequest)
+ return
}
if !ok {
- log.Printf("Access denied")
+ log.Printf("Not Authorized - attempted access %s", urn)
http.Error(rw, "Access denied", http.StatusForbidden)
+ return
}
log.Printf("Method %s Url %s", action, repo)
next.ServeHTTP(rw, req.WithContext(ctx))