open-mcp-auth-proxy-upstream/internal/authz/default_policy_engine.go
2025-05-14 15:39:02 +05:30

20 lines
428 B
Go

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 + "'"}
}