Refactor proxy builder

This commit is contained in:
NipuniBhagya 2025-05-14 15:39:02 +05:30
parent 85e5fe1c1d
commit 331cc281c6
5 changed files with 200 additions and 35 deletions

View file

@ -0,0 +1,20 @@
package authz
import (
"net/http"
)
type TokenClaims struct {
Scopes []string
}
type DefaulPolicyEngine struct{}
func (d *DefaulPolicyEngine) Evaluate(r *http.Request, claims *TokenClaims, requiredScope string) PolicyResult {
for _, scope := range claims.Scopes {
if scope == requiredScope {
return PolicyResult{DecisionAllow, ""}
}
}
return PolicyResult{DecisionDeny, "missing scope '" + requiredScope + "'"}
}