fix(security): block refresh tokens as bearer and sandbox MCP uploads
Reject refresh JWTs in ValidateToken, revoke all user sessions on logout, and restrict create_knowledge_from_file to allowed directories on network MCP transports.
This commit is contained in:
@@ -6,6 +6,25 @@ import (
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
)
|
||||
|
||||
func TestIsRefreshTokenClaims(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
claims jwt.MapClaims
|
||||
want bool
|
||||
}{
|
||||
{name: "refresh", claims: jwt.MapClaims{"type": "refresh"}, want: true},
|
||||
{name: "access", claims: jwt.MapClaims{"type": "access"}, want: false},
|
||||
{name: "missing type", claims: jwt.MapClaims{"user_id": "u1"}, want: false},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
if got := isRefreshTokenClaims(tc.claims); got != tc.want {
|
||||
t.Fatalf("isRefreshTokenClaims(%v) = %v, want %v", tc.claims, got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// tenantIDFromClaims is the JWT->tenant-id projection used by
|
||||
// userService.ValidateToken. It must:
|
||||
// - prefer the claim when present (so /auth/switch-tenant takes effect)
|
||||
|
||||
Reference in New Issue
Block a user