fixed multiple roles in 1 policy
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"authorization/db"
|
||||
"authorization/helper"
|
||||
"authorization/middleware"
|
||||
"authorization/models"
|
||||
"authorization/services"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -14,7 +14,7 @@ var authService *models.CachedAuthorizationService
|
||||
|
||||
// InitAuthService initializes the authorization service with caching
|
||||
func InitAuthService() {
|
||||
authService = services.NewCachedAuthorizationService(db.DB)
|
||||
authService = services.NewCachedAuthorizationService()
|
||||
}
|
||||
|
||||
// AuthorizeHandler godoc
|
||||
@@ -52,6 +52,8 @@ func AuthorizeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
log.Print("Authorization request for user=", ctx.UserID, ", resource=", ctx.Resource, ", action=", ctx.Action)
|
||||
log.Print("JWT claims user=", claims.UserID, ", username=", claims.Username, ", role=", claims.Role)
|
||||
// Verify JWT user matches request user (security check)
|
||||
if ctx.UserID != claims.UserID {
|
||||
helper.RespondWithError(w, http.StatusForbidden, "User ID mismatch")
|
||||
|
||||
Reference in New Issue
Block a user