mirror of
https://github.com/wso2/open-mcp-auth-proxy.git
synced 2025-08-18 04:09:57 +00:00
Refactor proxy builder
This commit is contained in:
parent
d71ee4052c
commit
c65f73a6ce
5 changed files with 197 additions and 32 deletions
20
internal/authz/default_policy_engine.go
Normal file
20
internal/authz/default_policy_engine.go
Normal 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 + "'"}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue