mirror of
https://github.com/wso2/open-mcp-auth-proxy.git
synced 2025-06-28 01:23:30 +00:00
20 lines
428 B
Go
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 + "'"}
|
|
}
|