From 70ced4850c7c8e0b1ce8d764dc5aae6b8c3b77aa Mon Sep 17 00:00:00 2001 From: Carmendelope Date: Mon, 27 Nov 2023 18:34:01 +0100 Subject: [PATCH 01/12] Add new fields in AuthxClaim --- go.mod | 2 +- pkg/helper/metadata_helper.go | 4 +- pkg/interceptors/jwt_interceptor.go | 9 ++++ pkg/interceptors/mocks_helper.go | 19 ++++++-- pkg/interceptors/secrets_test.go | 2 +- pkg/njwt/claims.go | 76 ++++++++++++++++++++++------- pkg/njwt/token_test.go | 29 +++++++++-- pkg/utils/test_helper.go | 8 +-- 8 files changed, 118 insertions(+), 31 deletions(-) diff --git a/go.mod b/go.mod index 4ec14c6..b91b5e6 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/napptive/njwt -go 1.19 +go 1.21 require ( github.com/golang-jwt/jwt v3.2.2+incompatible diff --git a/pkg/helper/metadata_helper.go b/pkg/helper/metadata_helper.go index 082777e..1c973ff 100644 --- a/pkg/helper/metadata_helper.go +++ b/pkg/helper/metadata_helper.go @@ -42,5 +42,7 @@ const ( // OriginalUsernameKey with the key that will be injected in the context metadata for signup claims corresponding with the orignal username in the target provider OriginalUsernameKey = "original_username" // IdentityProviderKey with the key that will be injected in the context metadata for signup claims corresponding with the the target provider - IdentityProviderKey = "identity_provider" + IdentityProviderKey = "identity_provider" + EnvironmentAccountKey = "environment_account" + AccountsKey = "accounts" ) diff --git a/pkg/interceptors/jwt_interceptor.go b/pkg/interceptors/jwt_interceptor.go index 73d8c61..c6fc8df 100644 --- a/pkg/interceptors/jwt_interceptor.go +++ b/pkg/interceptors/jwt_interceptor.go @@ -173,6 +173,14 @@ func GetClaimFromContext(ctx context.Context) (*njwt.ExtendedAuthxClaim, error) zoneURLVal = zoneURL[0] } + var userAccounts []njwt.UserAccountClaim + accounts, exists := md[helper.AccountsKey] + if exists { + // TODO: review error + userAccounts, _ = njwt.StringToAccounts(accounts[0]) + + } + return &njwt.ExtendedAuthxClaim{ StandardClaims: jwt.StandardClaims{ Id: tokenID[0], @@ -187,6 +195,7 @@ func GetClaimFromContext(ctx context.Context) (*njwt.ExtendedAuthxClaim, error) AccountAdmin: accountAdminVal, ZoneID: zoneIDVal, ZoneURL: zoneURLVal, + Accounts: userAccounts, }, }, nil } diff --git a/pkg/interceptors/mocks_helper.go b/pkg/interceptors/mocks_helper.go index 9625764..e28c539 100644 --- a/pkg/interceptors/mocks_helper.go +++ b/pkg/interceptors/mocks_helper.go @@ -19,9 +19,22 @@ func GetTestJWTConfig() config.JWTConfig { // GetTestAuthxClaim returns a random AuthxClaim to use in the tests func GetTestAuthxClaim() *njwt.AuthxClaim { - return njwt.NewAuthxClaim(utils.GetTestUserId(), utils.GetTestUserName(), - utils.GetTestAccountId(), utils.GetTestUserName(), - utils.GetTestEnvironmentId(), false, "zone_id", "zone_url") + accounts := make([]njwt.UserAccountClaim, 0) + accounts = append(accounts, njwt.UserAccountClaim{ + Id: utils.GetTestAccountId(), + Name: utils.GetTestAccountName(), + Role: "Admin", + }) + return njwt.NewAuthxClaim( + utils.GetTestUserId(), + utils.GetTestUserName(), + accounts[0].Id, + accounts[0].Name, + utils.GetTestEnvironmentId(), + accounts[0].Role == "Admin", + "zone_id", + "zone_url", + accounts) } func CreateTestIncomingContext(header string, token string) (context.Context, context.CancelFunc) { diff --git a/pkg/interceptors/secrets_test.go b/pkg/interceptors/secrets_test.go index 97e14c0..a69b2d7 100644 --- a/pkg/interceptors/secrets_test.go +++ b/pkg/interceptors/secrets_test.go @@ -46,7 +46,7 @@ var _ = ginkgo.Describe("Zone aware secrets manager", func() { ginkgo.It("should be able to retrieve a zone secret", func() { response := &grpc_jwt_go.SecretResponse{ - JwtSecret: "zoneSecet", + JwtSecret: "zoneSecret", } secretsClientMock.EXPECT().Get(gomock.Any(), gomock.Any()).Return(response, nil) secret, err := secretsManager.GetZoneSecret("uncached") diff --git a/pkg/njwt/claims.go b/pkg/njwt/claims.go index c2cb367..ffc897c 100644 --- a/pkg/njwt/claims.go +++ b/pkg/njwt/claims.go @@ -17,6 +17,7 @@ package njwt import ( + "encoding/json" "strconv" "time" @@ -63,19 +64,58 @@ type AuthxClaim struct { ZoneID string // ZoneURL with the base URL of the current zone. ZoneURL string + // EnvironmentAccount with the actual account identifier + EnvironmentAccount string + // Accounts with the information of the accounts to which a user belongs + Accounts []UserAccountClaim +} + +type UserAccountClaim struct { + // Id with the account identifier + Id string + // Name with the account name + Name string + // Role with the user role in the account + Role string +} + +func (ac *AuthxClaim) AccountsToString() (string, error) { + account, err := json.Marshal(ac.Accounts) + if err != nil { + return "", err + } + accountStr := string(account) + return accountStr, nil +} + +func StringToAccounts(str string) ([]UserAccountClaim, error) { + var accounts []UserAccountClaim + err := json.Unmarshal([]byte(str), &accounts) + if err != nil { + // TODO: return an error + log.Error().Err(err).Msg("error converting string to authx claim") + } + return accounts, err } // ToMap transforms the claim into a key-value map. func (ac *AuthxClaim) ToMap() map[string]string { + accounts, err := ac.AccountsToString() + if err != nil { + // TODO: return an error + log.Error().Err(err).Msg("error converting authx claim to a map") + } return map[string]string{ - helper.UserIDKey: ac.UserID, - helper.UsernameKey: ac.Username, - helper.AccountNameKey: ac.AccountName, - helper.AccountIDKey: ac.AccountID, - helper.EnvironmentIDKey: ac.EnvironmentID, - helper.AccountAdminKey: strconv.FormatBool(ac.AccountAdmin), - helper.ZoneIDKey: ac.ZoneID, - helper.ZoneURLKey: ac.ZoneURL, + helper.UserIDKey: ac.UserID, + helper.UsernameKey: ac.Username, + helper.AccountNameKey: ac.AccountName, + helper.AccountIDKey: ac.AccountID, + helper.EnvironmentIDKey: ac.EnvironmentID, + helper.AccountAdminKey: strconv.FormatBool(ac.AccountAdmin), + helper.ZoneIDKey: ac.ZoneID, + helper.ZoneURLKey: ac.ZoneURL, + helper.EnvironmentAccountKey: ac.EnvironmentAccount, + helper.AccountsKey: accounts, } } @@ -83,16 +123,18 @@ func (ac *AuthxClaim) ToMap() map[string]string { func NewAuthxClaim(userID string, username string, accountID string, accountName string, environmentID string, accountAdmin bool, - zoneID string, zoneURL string) *AuthxClaim { + zoneID string, zoneURL string, accounts []UserAccountClaim) *AuthxClaim { return &AuthxClaim{ - UserID: userID, - Username: username, - AccountID: accountID, - AccountName: accountName, - EnvironmentID: environmentID, - AccountAdmin: accountAdmin, - ZoneID: zoneID, - ZoneURL: zoneURL, + UserID: userID, + Username: username, + AccountID: accountID, + AccountName: accountName, + EnvironmentID: environmentID, + AccountAdmin: accountAdmin, + ZoneID: zoneID, + ZoneURL: zoneURL, + EnvironmentAccount: accountID, + Accounts: accounts, } } diff --git a/pkg/njwt/token_test.go b/pkg/njwt/token_test.go index 8740668..2ffb886 100644 --- a/pkg/njwt/token_test.go +++ b/pkg/njwt/token_test.go @@ -24,7 +24,27 @@ import ( "github.com/onsi/gomega" ) -var _ = ginkgo.Describe("NJWT Token Manager tests", func() { +// GenerateTestAuthxClaim returns a random AuthxClaim to use in the tests +func GenerateTestAuthxClaim() *AuthxClaim { + accounts := make([]UserAccountClaim, 0) + accounts = append(accounts, UserAccountClaim{ + Id: utils.GetTestAccountId(), + Name: utils.GetTestAccountName(), + Role: "Admin", + }) + return NewAuthxClaim( + utils.GetTestUserId(), + utils.GetTestUserName(), + accounts[0].Id, + accounts[0].Name, + utils.GetTestEnvironmentId(), + accounts[0].Role == "Admin", + "zone_id", + "zone_url", + accounts) +} + +var _ = ginkgo.Describe("njwt Token Manager tests", func() { ginkgo.Context("Check token manager generator", func() { tokenMgr := New() @@ -54,8 +74,8 @@ var _ = ginkgo.Describe("NJWT Token Manager tests", func() { }) ginkgo.It("The recover claim with personal claim", func() { - pc := NewAuthxClaim("userID", "username", utils.GetTestAccountId(), utils.GetTestUserName(), - utils.GetTestEnvironmentId(), true, "zoneID", "zoneURL") + + pc := GenerateTestAuthxClaim() claim := NewClaim("tt", time.Hour, pc) secret := "secret" @@ -94,8 +114,7 @@ var _ = ginkgo.Describe("NJWT Token Manager tests", func() { ginkgo.Context("working with unverified tokens", func() { tokenMgr := New() ginkgo.It("should be able to retrieve raw information from a token", func() { - pc := NewAuthxClaim("userID", "username", utils.GetTestAccountId(), utils.GetTestUserName(), - utils.GetTestEnvironmentId(), true, "zoneID", "zoneURL") + pc := GenerateTestAuthxClaim() claim := NewClaim("tt", time.Hour, pc) secret := "secret" diff --git a/pkg/utils/test_helper.go b/pkg/utils/test_helper.go index 5f1fde2..4f41261 100644 --- a/pkg/utils/test_helper.go +++ b/pkg/utils/test_helper.go @@ -21,8 +21,6 @@ import ( "syreclabs.com/go/faker" ) - - // GetTestUserId returns a random UserId func GetTestUserId() string { return xid.New().String() @@ -41,4 +39,8 @@ func GetTestEnvironmentId() string { // GetTestUserName returns a random Username func GetTestUserName() string { return faker.Internet().UserName() -} \ No newline at end of file +} + +func GetTestAccountName() string { + return faker.Internet().UserName() +} From 60bac7f742490791a09469fea5711a85b12d1970 Mon Sep 17 00:00:00 2001 From: Carmendelope Date: Mon, 27 Nov 2023 18:40:40 +0100 Subject: [PATCH 02/12] fix vulnerabilities --- go.mod | 20 ++++++++++---------- go.sum | 42 ++++++++++++++++++++++-------------------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/go.mod b/go.mod index b91b5e6..6e5a643 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.21 require ( github.com/golang-jwt/jwt v3.2.2+incompatible github.com/golang/mock v1.6.0 - github.com/napptive/go-utils v0.0.0-20230302113223-949e47c65976 github.com/napptive/grpc-jwt-go v0.1.0 github.com/napptive/grpc-ping-go v0.1.0 github.com/napptive/nerrors v1.1.0 @@ -13,28 +12,29 @@ require ( github.com/onsi/gomega v1.27.2 github.com/rs/xid v1.4.0 github.com/rs/zerolog v1.29.0 - google.golang.org/grpc v1.53.0 + google.golang.org/grpc v1.56.3 syreclabs.com/go/faker v1.2.3 ) require ( - github.com/envoyproxy/protoc-gen-validate v0.9.1 // indirect + github.com/envoyproxy/protoc-gen-validate v0.10.1 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect - github.com/golang/protobuf v1.5.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/kr/pretty v0.3.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.17 // indirect github.com/napptive/grpc-common-go v0.8.0 // indirect github.com/nxadm/tail v1.4.8 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect - golang.org/x/tools v0.6.0 // indirect - google.golang.org/genproto v0.0.0-20230301171018-9ab4bdc49ad5 // indirect - google.golang.org/protobuf v1.28.1 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect + golang.org/x/tools v0.7.0 // indirect + google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect + google.golang.org/protobuf v1.30.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 0a6b67b..7fc1497 100644 --- a/go.sum +++ b/go.sum @@ -12,13 +12,14 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v0.9.1 h1:PS7VIOgmSVhWUEeZwTe7z7zouA22Cr590PzXKbZHOVY= -github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0++PMirau2/yoOwVac3AbF2w= +github.com/envoyproxy/protoc-gen-validate v0.10.1 h1:c0g45+xCJhdgFGw7a5QAfdS4byAbud7miNWJ1WwEVf8= +github.com/envoyproxy/protoc-gen-validate v0.10.1/go.mod h1:DRjgyB0I43LtJapqN6NiRwroiAU2PaFuvk/vjgh61ss= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= +github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -38,8 +39,8 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -49,6 +50,7 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -66,8 +68,6 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/napptive/go-utils v0.0.0-20230302113223-949e47c65976 h1:OvdP5X5ww6++plEMTo6D7+ZEP/bf9tBntb/cWKFOdMY= -github.com/napptive/go-utils v0.0.0-20230302113223-949e47c65976/go.mod h1:SbWdBoy9YhBEehzMNfSUAKhCF+f6rHqUcPZFH6hv/qU= github.com/napptive/grpc-common-go v0.2.0/go.mod h1:Q896cZY+yIkted9zYw3jtguVDdfL1bqTHjjiirBTjnw= github.com/napptive/grpc-common-go v0.8.0 h1:iRGbhQyHiLYm7EVKprEMiFixAvcLroajAtA+I7n2K1M= github.com/napptive/grpc-common-go v0.8.0/go.mod h1:Q896cZY+yIkted9zYw3jtguVDdfL1bqTHjjiirBTjnw= @@ -86,6 +86,7 @@ github.com/onsi/ginkgo v1.15.0/go.mod h1:hF8qUzuuC8DJGygJH3726JnCZX4MYbRB8yFfISq github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.8.4 h1:gf5mIQ8cLFieruNLAdgijHF1PYfLphKm2dxxcUtcqK0= +github.com/onsi/ginkgo/v2 v2.8.4/go.mod h1:427dEDQZkDKsBvCjc2A/ZPefhKxsTTrsQegMlayL730= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48= @@ -126,8 +127,8 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -151,13 +152,13 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -166,8 +167,8 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= +golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -177,15 +178,15 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20230301171018-9ab4bdc49ad5 h1:/cadn7taPtPlCgiWNetEPsle7jgnlad2R7gR5MXB6dM= -google.golang.org/genproto v0.0.0-20230301171018-9ab4bdc49ad5/go.mod h1:TvhZT5f700eVlTNwND1xoEZQeWTB2RY/65kplwl/bFA= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= -google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= +google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= +google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -197,8 +198,8 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= @@ -211,6 +212,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= From 60b26aa7230e72921d7fa40b1a297b3b17879529 Mon Sep 17 00:00:00 2001 From: Carmendelope Date: Mon, 27 Nov 2023 18:41:24 +0100 Subject: [PATCH 03/12] upgrade --- go.mod | 9 ++++----- go.sum | 31 +++++++++++++++++-------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/go.mod b/go.mod index 6e5a643..df08634 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/napptive/grpc-ping-go v0.1.0 github.com/napptive/nerrors v1.1.0 github.com/onsi/ginkgo v1.16.5 - github.com/onsi/gomega v1.27.2 + github.com/onsi/gomega v1.30.0 github.com/rs/xid v1.4.0 github.com/rs/zerolog v1.29.0 google.golang.org/grpc v1.56.3 @@ -19,9 +19,9 @@ require ( require ( github.com/envoyproxy/protoc-gen-validate v0.10.1 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect - github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect + github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/kr/pretty v0.3.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.17 // indirect @@ -30,11 +30,10 @@ require ( golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect - golang.org/x/tools v0.7.0 // indirect + golang.org/x/tools v0.12.0 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 7fc1497..d76350c 100644 --- a/go.sum +++ b/go.sum @@ -18,10 +18,11 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= @@ -47,8 +48,8 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -85,13 +86,13 @@ github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108 github.com/onsi/ginkgo v1.15.0/go.mod h1:hF8qUzuuC8DJGygJH3726JnCZX4MYbRB8yFfISqnKUg= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.8.4 h1:gf5mIQ8cLFieruNLAdgijHF1PYfLphKm2dxxcUtcqK0= -github.com/onsi/ginkgo/v2 v2.8.4/go.mod h1:427dEDQZkDKsBvCjc2A/ZPefhKxsTTrsQegMlayL730= +github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= +github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48= -github.com/onsi/gomega v1.27.2 h1:SKU0CXeKE/WVgIV1T61kSa3+IRE8Ekrv9rdXDwwTqnY= -github.com/onsi/gomega v1.27.2/go.mod h1:5mR3phAHpkAVIDkHEUBY6HGVsU+cpcEscrGPB4oPlZI= +github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= +github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -103,8 +104,9 @@ github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -116,6 +118,8 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -167,8 +171,8 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= -golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= +golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= +golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -211,8 +215,7 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= From 2bc9a1541c65d8b3e8332f766caeec06fef8fca6 Mon Sep 17 00:00:00 2001 From: Carmendelope Date: Mon, 27 Nov 2023 18:43:04 +0100 Subject: [PATCH 04/12] upgrade --- go.mod | 14 +++++++------- go.sum | 36 +++++++++++++++++------------------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/go.mod b/go.mod index df08634..8ffbe11 100644 --- a/go.mod +++ b/go.mod @@ -10,29 +10,29 @@ require ( github.com/napptive/nerrors v1.1.0 github.com/onsi/ginkgo v1.16.5 github.com/onsi/gomega v1.30.0 - github.com/rs/xid v1.4.0 - github.com/rs/zerolog v1.29.0 - google.golang.org/grpc v1.56.3 + github.com/rs/xid v1.5.0 + github.com/rs/zerolog v1.31.0 + google.golang.org/grpc v1.59.0 syreclabs.com/go/faker v1.2.3 ) require ( - github.com/envoyproxy/protoc-gen-validate v0.10.1 // indirect + github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/kr/pretty v0.3.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.17 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect github.com/napptive/grpc-common-go v0.8.0 // indirect github.com/nxadm/tail v1.4.8 // indirect golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect golang.org/x/tools v0.12.0 // indirect - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect - google.golang.org/protobuf v1.30.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index d76350c..e4cf4f2 100644 --- a/go.sum +++ b/go.sum @@ -3,7 +3,7 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -12,8 +12,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v0.10.1 h1:c0g45+xCJhdgFGw7a5QAfdS4byAbud7miNWJ1WwEVf8= -github.com/envoyproxy/protoc-gen-validate v0.10.1/go.mod h1:DRjgyB0I43LtJapqN6NiRwroiAU2PaFuvk/vjgh61ss= +github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA= +github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= @@ -62,13 +62,11 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= -github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/napptive/grpc-common-go v0.2.0/go.mod h1:Q896cZY+yIkted9zYw3jtguVDdfL1bqTHjjiirBTjnw= github.com/napptive/grpc-common-go v0.8.0 h1:iRGbhQyHiLYm7EVKprEMiFixAvcLroajAtA+I7n2K1M= github.com/napptive/grpc-common-go v0.8.0/go.mod h1:Q896cZY+yIkted9zYw3jtguVDdfL1bqTHjjiirBTjnw= @@ -99,10 +97,10 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rs/xid v1.4.0 h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY= -github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= -github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= +github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= +github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= @@ -152,10 +150,10 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -182,15 +180,15 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= -google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= +google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -202,8 +200,8 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= From 0b2cea639d749db1988b8562ccfae25131155bab Mon Sep 17 00:00:00 2001 From: Carmendelope Date: Thu, 30 Nov 2023 11:53:05 +0100 Subject: [PATCH 05/12] Add new fields in the claim --- pkg/interceptors/jwt_interceptor.go | 4 +--- pkg/njwt/claims.go | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/pkg/interceptors/jwt_interceptor.go b/pkg/interceptors/jwt_interceptor.go index c6fc8df..7d66aa8 100644 --- a/pkg/interceptors/jwt_interceptor.go +++ b/pkg/interceptors/jwt_interceptor.go @@ -176,9 +176,7 @@ func GetClaimFromContext(ctx context.Context) (*njwt.ExtendedAuthxClaim, error) var userAccounts []njwt.UserAccountClaim accounts, exists := md[helper.AccountsKey] if exists { - // TODO: review error - userAccounts, _ = njwt.StringToAccounts(accounts[0]) - + userAccounts = njwt.StringToAccounts(accounts[0]) } return &njwt.ExtendedAuthxClaim{ diff --git a/pkg/njwt/claims.go b/pkg/njwt/claims.go index ffc897c..4a93641 100644 --- a/pkg/njwt/claims.go +++ b/pkg/njwt/claims.go @@ -88,21 +88,19 @@ func (ac *AuthxClaim) AccountsToString() (string, error) { return accountStr, nil } -func StringToAccounts(str string) ([]UserAccountClaim, error) { +func StringToAccounts(str string) []UserAccountClaim { var accounts []UserAccountClaim err := json.Unmarshal([]byte(str), &accounts) if err != nil { - // TODO: return an error log.Error().Err(err).Msg("error converting string to authx claim") } - return accounts, err + return accounts } // ToMap transforms the claim into a key-value map. func (ac *AuthxClaim) ToMap() map[string]string { accounts, err := ac.AccountsToString() if err != nil { - // TODO: return an error log.Error().Err(err).Msg("error converting authx claim to a map") } return map[string]string{ From c91486b20a9edc1db635b35bde277184e43c15b5 Mon Sep 17 00:00:00 2001 From: Carmendelope Date: Fri, 1 Dec 2023 12:23:31 +0100 Subject: [PATCH 06/12] Add a new method to check if a user can access to an account --- pkg/njwt/claims.go | 56 +++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/pkg/njwt/claims.go b/pkg/njwt/claims.go index 4a93641..88ced07 100644 --- a/pkg/njwt/claims.go +++ b/pkg/njwt/claims.go @@ -50,7 +50,7 @@ func NewClaim(issuer string, expiration time.Duration, pc interface{}) *Claim { type AuthxClaim struct { // UserID internal napptive user identifier. UserID string - // Username is the unique name of the user, currently the github account name. + // Username is the unique name of the user, currently the GitHub account name. Username string // AccountID with the actual account identifier AccountID string @@ -79,6 +79,25 @@ type UserAccountClaim struct { Role string } +// NewAuthxClaim creates a new instance of AuthxClaim. +func NewAuthxClaim(userID string, username string, + accountID string, accountName string, + environmentID string, accountAdmin bool, + zoneID string, zoneURL string, accounts []UserAccountClaim) *AuthxClaim { + return &AuthxClaim{ + UserID: userID, + Username: username, + AccountID: accountID, + AccountName: accountName, + EnvironmentID: environmentID, + AccountAdmin: accountAdmin, + ZoneID: zoneID, + ZoneURL: zoneURL, + EnvironmentAccount: accountID, + Accounts: accounts, + } +} + func (ac *AuthxClaim) AccountsToString() (string, error) { account, err := json.Marshal(ac.Accounts) if err != nil { @@ -117,25 +136,6 @@ func (ac *AuthxClaim) ToMap() map[string]string { } } -// NewAuthxClaim creates a new instance of AuthxClaim. -func NewAuthxClaim(userID string, username string, - accountID string, accountName string, - environmentID string, accountAdmin bool, - zoneID string, zoneURL string, accounts []UserAccountClaim) *AuthxClaim { - return &AuthxClaim{ - UserID: userID, - Username: username, - AccountID: accountID, - AccountName: accountName, - EnvironmentID: environmentID, - AccountAdmin: accountAdmin, - ZoneID: zoneID, - ZoneURL: zoneURL, - EnvironmentAccount: accountID, - Accounts: accounts, - } -} - // Print the contents of the claim through the logger. func (ac *AuthxClaim) Print() { log.Info().Str("user_id", ac.UserID).Str("username", ac.Username). @@ -143,6 +143,22 @@ func (ac *AuthxClaim) Print() { Str("environment_id", ac.EnvironmentID).Bool("account_admin", ac.AccountAdmin).Str("zone_id", ac.ZoneID).Str("zone_url", ac.ZoneURL).Msg("AuthxClaim") } +// IsAuthorized checks if the user (claim) has permissions to operate in an account +func (ac *AuthxClaim) IsAuthorized(accountName string, adminRoleRequired bool) bool { + + authorized := false + + for _, account := range ac.Accounts { + if account.Name == accountName { + if adminRoleRequired { + authorized = account.Role == "Admin" + } + return authorized + } + } + return authorized +} + // GetAuthxClaim returns the AuthxClaim section of the claim. func (c *Claim) GetAuthxClaim() *AuthxClaim { return c.PersonalClaim.(*AuthxClaim) From 20f85757d6664147249fadf6d72b6276360c2daf Mon Sep 17 00:00:00 2001 From: Carmendelope Date: Fri, 1 Dec 2023 12:46:34 +0100 Subject: [PATCH 07/12] Fix an authorize claim return --- pkg/njwt/claims.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/njwt/claims.go b/pkg/njwt/claims.go index 88ced07..3eec1c1 100644 --- a/pkg/njwt/claims.go +++ b/pkg/njwt/claims.go @@ -152,6 +152,8 @@ func (ac *AuthxClaim) IsAuthorized(accountName string, adminRoleRequired bool) b if account.Name == accountName { if adminRoleRequired { authorized = account.Role == "Admin" + } else { + authorized = true } return authorized } From 920b61ebbc05218c5931b98dd7891b7216db7bc8 Mon Sep 17 00:00:00 2001 From: Carmendelope Date: Fri, 1 Dec 2023 12:58:12 +0100 Subject: [PATCH 08/12] GetCurrentAccountName method added --- pkg/njwt/claims.go | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/pkg/njwt/claims.go b/pkg/njwt/claims.go index 3eec1c1..a0ec2e2 100644 --- a/pkg/njwt/claims.go +++ b/pkg/njwt/claims.go @@ -18,6 +18,7 @@ package njwt import ( "encoding/json" + "github.com/napptive/nerrors/pkg/nerrors" "strconv" "time" @@ -53,19 +54,22 @@ type AuthxClaim struct { // Username is the unique name of the user, currently the GitHub account name. Username string // AccountID with the actual account identifier + // Deprecated: uses EnvironmentAccountID AccountID string // AccountName with the name of the account + // Deprecated: uses Accounts info AccountName string // EnvironmentID with the actual environment identifier EnvironmentID string + // EnvironmentAccountID with the actual account identifier + EnvironmentAccountID string // AccountAdmin with the admin account + // Deprecated: uses Accounts info AccountAdmin bool // ZoneID with the zone identifier ZoneID string // ZoneURL with the base URL of the current zone. ZoneURL string - // EnvironmentAccount with the actual account identifier - EnvironmentAccount string // Accounts with the information of the accounts to which a user belongs Accounts []UserAccountClaim } @@ -85,16 +89,16 @@ func NewAuthxClaim(userID string, username string, environmentID string, accountAdmin bool, zoneID string, zoneURL string, accounts []UserAccountClaim) *AuthxClaim { return &AuthxClaim{ - UserID: userID, - Username: username, - AccountID: accountID, - AccountName: accountName, - EnvironmentID: environmentID, - AccountAdmin: accountAdmin, - ZoneID: zoneID, - ZoneURL: zoneURL, - EnvironmentAccount: accountID, - Accounts: accounts, + UserID: userID, + Username: username, + AccountID: accountID, + AccountName: accountName, + EnvironmentID: environmentID, + AccountAdmin: accountAdmin, + ZoneID: zoneID, + ZoneURL: zoneURL, + EnvironmentAccountID: accountID, + Accounts: accounts, } } @@ -131,7 +135,7 @@ func (ac *AuthxClaim) ToMap() map[string]string { helper.AccountAdminKey: strconv.FormatBool(ac.AccountAdmin), helper.ZoneIDKey: ac.ZoneID, helper.ZoneURLKey: ac.ZoneURL, - helper.EnvironmentAccountKey: ac.EnvironmentAccount, + helper.EnvironmentAccountKey: ac.EnvironmentAccountID, helper.AccountsKey: accounts, } } @@ -161,6 +165,19 @@ func (ac *AuthxClaim) IsAuthorized(accountName string, adminRoleRequired bool) b return authorized } +// GetCurrentAccountName returns the EnvironmentAccountID name +// The AccountName is a deprecated field, the name can be retrieved from the accounts list +func (ac *AuthxClaim) GetCurrentAccountName() (*string, error) { + accountName := "" + for _, account := range ac.Accounts { + if account.Id == ac.EnvironmentAccountID { + accountName = account.Name + return &accountName, nil + } + } + return nil, nerrors.NewInternalError("error getting account name from claim. Account %s not found in the user accounts", ac.EnvironmentAccountID) +} + // GetAuthxClaim returns the AuthxClaim section of the claim. func (c *Claim) GetAuthxClaim() *AuthxClaim { return c.PersonalClaim.(*AuthxClaim) From e1bed6051d6dbb23c92c32026f6708c86545a562 Mon Sep 17 00:00:00 2001 From: Carmendelope Date: Fri, 1 Dec 2023 13:17:35 +0100 Subject: [PATCH 09/12] GetCurrentAccountName method added --- pkg/njwt/claims.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/pkg/njwt/claims.go b/pkg/njwt/claims.go index a0ec2e2..d62887f 100644 --- a/pkg/njwt/claims.go +++ b/pkg/njwt/claims.go @@ -54,15 +54,15 @@ type AuthxClaim struct { // Username is the unique name of the user, currently the GitHub account name. Username string // AccountID with the actual account identifier - // Deprecated: uses EnvironmentAccountID + // Deprecated: uses EnvironmentAccount AccountID string // AccountName with the name of the account // Deprecated: uses Accounts info AccountName string // EnvironmentID with the actual environment identifier EnvironmentID string - // EnvironmentAccountID with the actual account identifier - EnvironmentAccountID string + // EnvironmentAccount with the actual account identifier + EnvironmentAccount string // AccountAdmin with the admin account // Deprecated: uses Accounts info AccountAdmin bool @@ -89,16 +89,16 @@ func NewAuthxClaim(userID string, username string, environmentID string, accountAdmin bool, zoneID string, zoneURL string, accounts []UserAccountClaim) *AuthxClaim { return &AuthxClaim{ - UserID: userID, - Username: username, - AccountID: accountID, - AccountName: accountName, - EnvironmentID: environmentID, - AccountAdmin: accountAdmin, - ZoneID: zoneID, - ZoneURL: zoneURL, - EnvironmentAccountID: accountID, - Accounts: accounts, + UserID: userID, + Username: username, + AccountID: accountID, + AccountName: accountName, + EnvironmentID: environmentID, + AccountAdmin: accountAdmin, + ZoneID: zoneID, + ZoneURL: zoneURL, + EnvironmentAccount: accountID, + Accounts: accounts, } } @@ -135,7 +135,7 @@ func (ac *AuthxClaim) ToMap() map[string]string { helper.AccountAdminKey: strconv.FormatBool(ac.AccountAdmin), helper.ZoneIDKey: ac.ZoneID, helper.ZoneURLKey: ac.ZoneURL, - helper.EnvironmentAccountKey: ac.EnvironmentAccountID, + helper.EnvironmentAccountKey: ac.EnvironmentAccount, helper.AccountsKey: accounts, } } @@ -165,17 +165,17 @@ func (ac *AuthxClaim) IsAuthorized(accountName string, adminRoleRequired bool) b return authorized } -// GetCurrentAccountName returns the EnvironmentAccountID name +// GetCurrentAccountName returns the EnvironmentAccount name // The AccountName is a deprecated field, the name can be retrieved from the accounts list func (ac *AuthxClaim) GetCurrentAccountName() (*string, error) { accountName := "" for _, account := range ac.Accounts { - if account.Id == ac.EnvironmentAccountID { + if account.Id == ac.EnvironmentAccount { accountName = account.Name return &accountName, nil } } - return nil, nerrors.NewInternalError("error getting account name from claim. Account %s not found in the user accounts", ac.EnvironmentAccountID) + return nil, nerrors.NewInternalError("error getting account name from claim. Account %s not found in the user accounts", ac.EnvironmentAccount) } // GetAuthxClaim returns the AuthxClaim section of the claim. From 81622e0766bd8e3b97dbeaa9cf14c2350f8daae2 Mon Sep 17 00:00:00 2001 From: Carmendelope Date: Fri, 1 Dec 2023 13:29:06 +0100 Subject: [PATCH 10/12] fix environment_id key --- pkg/helper/metadata_helper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/helper/metadata_helper.go b/pkg/helper/metadata_helper.go index 1c973ff..0f2fc01 100644 --- a/pkg/helper/metadata_helper.go +++ b/pkg/helper/metadata_helper.go @@ -43,6 +43,6 @@ const ( OriginalUsernameKey = "original_username" // IdentityProviderKey with the key that will be injected in the context metadata for signup claims corresponding with the the target provider IdentityProviderKey = "identity_provider" - EnvironmentAccountKey = "environment_account" + EnvironmentAccountKey = "environment_account_id" AccountsKey = "accounts" ) From f693863c322db276ef72fe308c969f2320422c01 Mon Sep 17 00:00:00 2001 From: Carmendelope Date: Fri, 1 Dec 2023 13:31:32 +0100 Subject: [PATCH 11/12] fix environment_id key --- pkg/njwt/claims.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/pkg/njwt/claims.go b/pkg/njwt/claims.go index d62887f..a0ec2e2 100644 --- a/pkg/njwt/claims.go +++ b/pkg/njwt/claims.go @@ -54,15 +54,15 @@ type AuthxClaim struct { // Username is the unique name of the user, currently the GitHub account name. Username string // AccountID with the actual account identifier - // Deprecated: uses EnvironmentAccount + // Deprecated: uses EnvironmentAccountID AccountID string // AccountName with the name of the account // Deprecated: uses Accounts info AccountName string // EnvironmentID with the actual environment identifier EnvironmentID string - // EnvironmentAccount with the actual account identifier - EnvironmentAccount string + // EnvironmentAccountID with the actual account identifier + EnvironmentAccountID string // AccountAdmin with the admin account // Deprecated: uses Accounts info AccountAdmin bool @@ -89,16 +89,16 @@ func NewAuthxClaim(userID string, username string, environmentID string, accountAdmin bool, zoneID string, zoneURL string, accounts []UserAccountClaim) *AuthxClaim { return &AuthxClaim{ - UserID: userID, - Username: username, - AccountID: accountID, - AccountName: accountName, - EnvironmentID: environmentID, - AccountAdmin: accountAdmin, - ZoneID: zoneID, - ZoneURL: zoneURL, - EnvironmentAccount: accountID, - Accounts: accounts, + UserID: userID, + Username: username, + AccountID: accountID, + AccountName: accountName, + EnvironmentID: environmentID, + AccountAdmin: accountAdmin, + ZoneID: zoneID, + ZoneURL: zoneURL, + EnvironmentAccountID: accountID, + Accounts: accounts, } } @@ -135,7 +135,7 @@ func (ac *AuthxClaim) ToMap() map[string]string { helper.AccountAdminKey: strconv.FormatBool(ac.AccountAdmin), helper.ZoneIDKey: ac.ZoneID, helper.ZoneURLKey: ac.ZoneURL, - helper.EnvironmentAccountKey: ac.EnvironmentAccount, + helper.EnvironmentAccountKey: ac.EnvironmentAccountID, helper.AccountsKey: accounts, } } @@ -165,17 +165,17 @@ func (ac *AuthxClaim) IsAuthorized(accountName string, adminRoleRequired bool) b return authorized } -// GetCurrentAccountName returns the EnvironmentAccount name +// GetCurrentAccountName returns the EnvironmentAccountID name // The AccountName is a deprecated field, the name can be retrieved from the accounts list func (ac *AuthxClaim) GetCurrentAccountName() (*string, error) { accountName := "" for _, account := range ac.Accounts { - if account.Id == ac.EnvironmentAccount { + if account.Id == ac.EnvironmentAccountID { accountName = account.Name return &accountName, nil } } - return nil, nerrors.NewInternalError("error getting account name from claim. Account %s not found in the user accounts", ac.EnvironmentAccount) + return nil, nerrors.NewInternalError("error getting account name from claim. Account %s not found in the user accounts", ac.EnvironmentAccountID) } // GetAuthxClaim returns the AuthxClaim section of the claim. From d70953bfcae6b697f7c925884627788de73b4c8f Mon Sep 17 00:00:00 2001 From: Carmendelope Date: Fri, 1 Dec 2023 15:04:07 +0100 Subject: [PATCH 12/12] Add EnvironmentAccountID --- pkg/interceptors/jwt_interceptor.go | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/pkg/interceptors/jwt_interceptor.go b/pkg/interceptors/jwt_interceptor.go index 7d66aa8..f6f17d2 100644 --- a/pkg/interceptors/jwt_interceptor.go +++ b/pkg/interceptors/jwt_interceptor.go @@ -155,6 +155,11 @@ func GetClaimFromContext(ctx context.Context) (*njwt.ExtendedAuthxClaim, error) if exists { envIDVal = envID[0] } + envAccountIDVal := "" + envAccountID, exists := md[helper.EnvironmentAccountKey] + if exists { + envAccountIDVal = envAccountID[0] + } accountAdminVal := false accountAdmin, exists := md[helper.AccountAdminKey] if exists && accountAdmin[0] == "true" { @@ -185,15 +190,16 @@ func GetClaimFromContext(ctx context.Context) (*njwt.ExtendedAuthxClaim, error) IssuedAt: issuedAt, }, AuthxClaim: njwt.AuthxClaim{ - UserID: userID[0], - Username: username[0], - AccountID: accountIDVal, - AccountName: accountNameVal, - EnvironmentID: envIDVal, - AccountAdmin: accountAdminVal, - ZoneID: zoneIDVal, - ZoneURL: zoneURLVal, - Accounts: userAccounts, + UserID: userID[0], + Username: username[0], + AccountID: accountIDVal, + AccountName: accountNameVal, + EnvironmentID: envIDVal, + EnvironmentAccountID: envAccountIDVal, + AccountAdmin: accountAdminVal, + ZoneID: zoneIDVal, + ZoneURL: zoneURLVal, + Accounts: userAccounts, }, }, nil }