Skip to content

Commit 07d424f

Browse files
committed
Remove actions
Signed-off-by: Huabing Zhao <[email protected]>
1 parent bd06b21 commit 07d424f

File tree

10 files changed

+47
-276
lines changed

10 files changed

+47
-276
lines changed

api/v1alpha1/mcp_route.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -237,16 +237,13 @@ type MCPRouteOAuth struct {
237237
// MCPRouteAuthorization defines the authorization configuration for a MCPRoute.
238238
type MCPRouteAuthorization struct {
239239
// Rules defines a list of authorization rules.
240-
// These rules are evaluated in order, the first matching rule will be applied,
241-
// and the rest will be skipped.
240+
//
241+
// Requests that match any rule and satisfy the rule's conditions will be allowed.
242+
// Requests that do not match any rule or fail to satisfy the matched rule's conditions will be denied.
243+
// If no rules are defined, all requests will be denied.
242244
//
243245
// +optional
244246
Rules []MCPRouteAuthorizationRule `json:"rules,omitempty"`
245-
246-
// DefaultAction defines the default action to be taken if no rules match.
247-
// If not specified, the default action is Deny.
248-
// +optional
249-
DefaultAction *egv1a1.AuthorizationAction `json:"defaultAction"`
250247
}
251248

252249
// MCPRouteAuthorizationRule defines an authorization rule for MCPRoute based on the MCP authorization spec.
@@ -261,11 +258,6 @@ type MCPRouteAuthorizationRule struct {
261258
//
262259
// +kubebuilder:validation:Required
263260
Target MCPAuthorizationTarget `json:"target"`
264-
265-
// Action defines whether to allow or deny requests that match this rule.
266-
//
267-
// +kubebuilder:validation:Required
268-
Action egv1a1.AuthorizationAction `json:"action"`
269261
}
270262

271263
// MCPAuthorizationTarget defines the target of an authorization rule.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/controller/gateway.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"strings"
1414
"time"
1515

16-
egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
1716
"github.com/go-logr/logr"
1817
"github.com/google/uuid"
1918
appsv1 "k8s.io/api/apps/v1"
@@ -477,19 +476,7 @@ func mcpConfig(mcpRoutes []aigv1a1.MCPRoute) *filterapi.MCPConfig {
477476
authorization := route.Spec.SecurityPolicy.Authorization
478477
mcpRoute.Authorization = &filterapi.MCPRouteAuthorization{}
479478

480-
defaultAction := ptr.Deref(authorization.DefaultAction, egv1a1.AuthorizationActionDeny)
481-
if defaultAction == egv1a1.AuthorizationActionAllow {
482-
mcpRoute.Authorization.DefaultAction = filterapi.AuthorizationActionAllow
483-
} else {
484-
mcpRoute.Authorization.DefaultAction = filterapi.AuthorizationActionDeny
485-
}
486-
487479
for _, rule := range authorization.Rules {
488-
action := filterapi.AuthorizationActionDeny
489-
if rule.Action == egv1a1.AuthorizationActionAllow {
490-
action = filterapi.AuthorizationActionAllow
491-
}
492-
493480
scopes := make([]string, len(rule.Source.JWTSource.Scopes))
494481
for i, scope := range rule.Source.JWTSource.Scopes {
495482
scopes[i] = string(scope)
@@ -505,7 +492,6 @@ func mcpConfig(mcpRoutes []aigv1a1.MCPRoute) *filterapi.MCPConfig {
505492
}
506493

507494
mcpRule := filterapi.MCPRouteAuthorizationRule{
508-
Action: action,
509495
Source: filterapi.MCPAuthorizationSource{
510496
JWTSource: filterapi.JWTSource{
511497
Scopes: scopes,

internal/filterapi/mcpconfig.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ type MCPRouteAuthorization struct {
6868
// These rules are evaluated in order, the first matching rule will be applied,
6969
// and the rest will be skipped.
7070
Rules []MCPRouteAuthorizationRule `json:"rules,omitempty"`
71-
72-
// DefaultAction defines the action to take when no rules match.
73-
DefaultAction AuthorizationAction `json:"defaultAction,omitempty"`
7471
}
7572

7673
// MCPRouteAuthorizationRule defines an authorization rule for MCPRoute based on the MCP authorization spec.
@@ -81,21 +78,8 @@ type MCPRouteAuthorizationRule struct {
8178

8279
// Target defines the authorization target for this rule.
8380
Target MCPAuthorizationTarget `json:"target"`
84-
85-
// Action defines whether to allow or deny requests that match this rule.
86-
Action AuthorizationAction `json:"action"`
8781
}
8882

89-
// AuthorizationAction represents an authorization decision.
90-
type AuthorizationAction string
91-
92-
const (
93-
// AuthorizationActionAllow allows the request.
94-
AuthorizationActionAllow AuthorizationAction = "Allow"
95-
// AuthorizationActionDeny denies the request.
96-
AuthorizationActionDeny AuthorizationAction = "Deny"
97-
)
98-
9983
type MCPAuthorizationTarget struct {
10084
// Tools defines the list of tools this rule applies to.
10185
Tools []ToolCall `json:"tools"`

internal/mcpproxy/authorization.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ func (m *MCPProxy) authorizeRequest(authorization *filterapi.MCPRouteAuthorizati
2525
return true
2626
}
2727

28-
defaultAction := authorization.DefaultAction == filterapi.AuthorizationActionAllow
29-
30-
// If there are no rules, return the default action.
28+
// If no rules are defined, deny all requests.
3129
if len(authorization.Rules) == 0 {
32-
return defaultAction
30+
return false
3331
}
3432

3533
// If the rules are defined, a valid bearer token is required.
@@ -61,11 +59,11 @@ func (m *MCPProxy) authorizeRequest(authorization *filterapi.MCPRouteAuthorizati
6159
continue
6260
}
6361
if scopesSatisfied(scopeSet, rule.Source.JWTSource.Scopes) {
64-
return rule.Action == filterapi.AuthorizationActionAllow
62+
return true
6563
}
6664
}
6765

68-
return defaultAction
66+
return false
6967
}
7068

7169
func bearerToken(header string) (string, error) {

0 commit comments

Comments
 (0)