From 97b12126d74ae3529a0513fdc2a9549931ae3958 Mon Sep 17 00:00:00 2001 From: Alberto Ricart Date: Fri, 13 Sep 2024 10:18:19 -0500 Subject: [PATCH] removed parsing of account for cluster traffic as that option will be delayed. --- v2/account_claims.go | 22 +++------------------- v2/account_claims_test.go | 6 ------ 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/v2/account_claims.go b/v2/account_claims.go index 00bbc8c..05850fc 100644 --- a/v2/account_claims.go +++ b/v2/account_claims.go @@ -19,7 +19,6 @@ import ( "errors" "fmt" "sort" - "strings" "time" "github.com/nats-io/nkeys" @@ -232,9 +231,8 @@ func (ac *ExternalAuthorization) Validate(vr *ValidationResults) { } const ( - ClusterTrafficSystem = "system" - ClusterTrafficOwner = "owner" - ClusterTrafficOtherAccount = "account:" + ClusterTrafficSystem = "system" + ClusterTrafficOwner = "owner" ) type ClusterTraffic string @@ -243,21 +241,7 @@ func (ct ClusterTraffic) Valid() error { if ct == "" || ct == ClusterTrafficSystem || ct == ClusterTrafficOwner { return nil } - - if strings.HasPrefix(string(ct), ClusterTrafficOtherAccount) { - // so in JWT we would expect this to be an account ID - id := ct[len(ClusterTrafficOtherAccount):] - if !strings.HasPrefix(string(id), "A") { - return errors.New("cluster traffic should be an account public key") - } - _, err := nkeys.FromPublicKey(string(id)) - if err != nil { - return errors.New("cluster traffic is not a public account key") - } - } else { - return fmt.Errorf("unknown cluster traffic option: %q", ct) - } - return nil + return fmt.Errorf("unknown cluster traffic option: %q", ct) } // Account holds account specific claims data diff --git a/v2/account_claims_test.go b/v2/account_claims_test.go index cb4dc67..5930313 100644 --- a/v2/account_claims_test.go +++ b/v2/account_claims_test.go @@ -1005,12 +1005,6 @@ func TestClusterTraffic_Valid(t *testing.T) { {input: "OWNER", ok: false}, {input: "unknown", ok: false}, {input: "account", ok: false}, - {input: "account:", ok: false}, - {input: "account:A", ok: false}, - {input: "account:B", ok: false}, - // seed - reject - {input: "account:SAAEVKMPCBXPP5JG5J4DWQQJTL6TJJE35UCTYON4E2AMPMHOVJPTUSWIZY", ok: false}, - {input: "account:ABDFLVEVLA2IOTEEP44IGMZE2SFRBNVCXH5DUGRQ36AUVB2I44TJTNIA", ok: true}, } for _, test := range tests {