Skip to content

Commit

Permalink
fixed response header overwriting
Browse files Browse the repository at this point in the history
  • Loading branch information
Theo Bouwman committed Sep 21, 2018
1 parent 63f4ccc commit f161622
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ func NewAuthorizer(e *casbin.Enforcer) gin.HandlerFunc {
a := &BasicAuthorizer{enforcer: e}

if !a.CheckPermission(c.Request) {
a.RequirePermission(c.Writer)
a.RequirePermission(c)
return
}
}
}
Expand All @@ -44,7 +45,7 @@ func (a *BasicAuthorizer) CheckPermission(r *http.Request) bool {
}

// RequirePermission returns the 403 Forbidden to the client
func (a *BasicAuthorizer) RequirePermission(w http.ResponseWriter) {
w.WriteHeader(403)
w.Write([]byte("403 Forbidden\n"))
func (a *BasicAuthorizer) RequirePermission(c *gin.Context) {
c.AbortWithStatus(403)
return
}

0 comments on commit f161622

Please sign in to comment.