Skip to content

Commit

Permalink
chore: upgraded dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ralvarezdev committed Jan 4, 2025
1 parent 656b804 commit 2ba03ca
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 18 deletions.
3 changes: 1 addition & 2 deletions client/interceptor/outgoing-ctx/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ func (l *Logger) LogKeyValue(key string, value string) {
l.logger.LogMessage(
gologger.NewLogMessage(
formattedKey,
gologgerstatus.StatusDebug,
nil,
gologgerstatus.Debug,
value,
),
)
Expand Down
10 changes: 5 additions & 5 deletions client/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package metadata

import (
"context"
gogrpcgcloud "github.com/ralvarezdev/go-grpc/cloud/gcloud"
gojwt "github.com/ralvarezdev/go-jwt"
gojwtgrpc "github.com/ralvarezdev/go-jwt/grpc"
goloadergcloud "github.com/ralvarezdev/go-loader/cloud/gcloud"
"google.golang.org/grpc/metadata"
"strings"
)
Expand Down Expand Up @@ -47,7 +47,7 @@ func NewCtxMetadata(metadataFields *map[string]string) (*CtxMetadata, error) {
func NewUnauthenticatedCtxMetadata(gcloudToken string) (*CtxMetadata, error) {
return NewCtxMetadata(
&map[string]string{
goloadergcloud.AuthorizationMetadataKey: gojwt.BearerPrefix + " " + gcloudToken,
gogrpcgcloud.AuthorizationMetadataKey: gojwt.BearerPrefix + " " + gcloudToken,
},
)
}
Expand All @@ -58,8 +58,8 @@ func NewAuthenticatedCtxMetadata(
) (*CtxMetadata, error) {
return NewCtxMetadata(
&map[string]string{
goloadergcloud.AuthorizationMetadataKey: gojwt.BearerPrefix + " " + gcloudToken,
gojwtgrpc.AuthorizationMetadataKey: gojwt.BearerPrefix + " " + jwtToken,
gogrpcgcloud.AuthorizationMetadataKey: gojwt.BearerPrefix + " " + gcloudToken,
gojwtgrpc.AuthorizationMetadataKey: gojwt.BearerPrefix + " " + jwtToken,
},
)
}
Expand Down Expand Up @@ -89,7 +89,7 @@ func AppendGCloudTokenToOutgoingContext(
) context.Context {
return metadata.AppendToOutgoingContext(
ctx,
goloadergcloud.AuthorizationMetadataKey,
gogrpcgcloud.AuthorizationMetadataKey,
gojwt.BearerPrefix+" "+gcloudToken,
)
}
9 changes: 9 additions & 0 deletions cloud/gcloud/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package gcloud

var (
// AuthorizationTokenIdx is the index of the authorization token
AuthorizationTokenIdx = 0

// AuthorizationMetadataKey is the key of the authorization metadata
AuthorizationMetadataKey = "x-serverless-authorization"
)
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/ralvarezdev/go-grpc
go 1.23.4

require (
github.com/ralvarezdev/go-flags v0.2.3
github.com/ralvarezdev/go-jwt v0.3.1
github.com/ralvarezdev/go-loader v0.2.3
github.com/ralvarezdev/go-logger v0.2.2
github.com/ralvarezdev/go-flags v0.2.5
github.com/ralvarezdev/go-jwt v0.3.7
github.com/ralvarezdev/go-loader v0.2.6
github.com/ralvarezdev/go-logger v0.3.0
go.mongodb.org/mongo-driver v1.17.1
google.golang.org/grpc v1.69.2
)
Expand Down Expand Up @@ -35,11 +35,11 @@ require (
go.opentelemetry.io/otel/trace v1.31.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/oauth2 v0.25.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/api v0.213.0 // indirect
google.golang.org/api v0.214.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 // indirect
google.golang.org/protobuf v1.36.0 // indirect
)
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,30 @@ github.com/ralvarezdev/go-flags v0.2.1 h1:zLhEZcb8jaaq5y+Gh7ot1NRaBLKvl0zyNA4st7
github.com/ralvarezdev/go-flags v0.2.1/go.mod h1:pYw9H7NJ07Y5asZDC/EI5bpBLR0kdL2ISsh6X5ws+3s=
github.com/ralvarezdev/go-flags v0.2.2/go.mod h1:xc0ii1VySdiV/s17KRo1GJ6bLxy5eOv93Oaz/mSlxtw=
github.com/ralvarezdev/go-flags v0.2.3/go.mod h1:xc0ii1VySdiV/s17KRo1GJ6bLxy5eOv93Oaz/mSlxtw=
github.com/ralvarezdev/go-flags v0.2.5 h1:SCD/H8qDL5mPHqIuBpHdURgATF3c9rm+OWUNwnV0uKs=
github.com/ralvarezdev/go-flags v0.2.5/go.mod h1:5uCMKlCrSOon33DPwVQqLVkokl984YDGDT7QbxY8jDU=
github.com/ralvarezdev/go-jwt v0.1.0 h1:GNgzK1F9bldIacS48lQ858rjp1fr714B18v87BBwppA=
github.com/ralvarezdev/go-jwt v0.1.0/go.mod h1:BPy5F1/CufL7bGRVUa5qgzva56g3PdiQXSbchqmoAOg=
github.com/ralvarezdev/go-jwt v0.2.0/go.mod h1:BPy5F1/CufL7bGRVUa5qgzva56g3PdiQXSbchqmoAOg=
github.com/ralvarezdev/go-jwt v0.2.1/go.mod h1:CKxcQ+o7CMqMd2/2UYEOSbk3yqDyu1NnVZWsxjwpayI=
github.com/ralvarezdev/go-jwt v0.3.0 h1:gI94Za26cTJ1dlAg2xEwei5e7zYv/p3rEHW7qRZqA6c=
github.com/ralvarezdev/go-jwt v0.3.0/go.mod h1:FhVExNxBptgxdchZ7kQH/7llF2hLKcLdlqgrIZea+3w=
github.com/ralvarezdev/go-jwt v0.3.1/go.mod h1:Yo+HExsp8k7Fd/WDn4SOF3lnLzBnfR6SqdHjcR09+D4=
github.com/ralvarezdev/go-jwt v0.3.4/go.mod h1:Tq6xz+T0+kxsL7YBKgu6UvjyjsJmm7YDtpj+1E3Gta4=
github.com/ralvarezdev/go-jwt v0.3.5/go.mod h1:kNPxRcDbdj3w5ILlgZGa/WyXgDAzFgLyu3JLK9Ie94c=
github.com/ralvarezdev/go-jwt v0.3.7/go.mod h1:kNPxRcDbdj3w5ILlgZGa/WyXgDAzFgLyu3JLK9Ie94c=
github.com/ralvarezdev/go-loader v0.1.0 h1:f/BVbO53bgWBnMMsHRHg9kJSEcaEc3ikH6N6tIjm5is=
github.com/ralvarezdev/go-loader v0.1.0/go.mod h1:XEgz5P7sMISBey2UqO8RlWtnfctNboKq7gU50BrvA2c=
github.com/ralvarezdev/go-loader v0.2.2 h1:sg8DwXblHv1/X00h3TgWNPtH+cSh1Vw2BaLsahGsLvs=
github.com/ralvarezdev/go-loader v0.2.2/go.mod h1:YNkLXmM3DUQAMpBzct02foddri1VODY7iK4vElIWibE=
github.com/ralvarezdev/go-loader v0.2.3/go.mod h1:YNkLXmM3DUQAMpBzct02foddri1VODY7iK4vElIWibE=
github.com/ralvarezdev/go-loader v0.2.6/go.mod h1:wswhqUg/qCfwFFLVH0BvCp3Z9v/ajPMDBMlQJ0/ljSY=
github.com/ralvarezdev/go-logger v0.1.0 h1:i2AI1nlxU6Hizvk75Vc8wtFydiVrqIeeRbJwiuO/69A=
github.com/ralvarezdev/go-logger v0.1.0/go.mod h1:v5OvFrkS+wsYNTCVegXWiRhBtcYrQJr4LDMDntvpAos=
github.com/ralvarezdev/go-logger v0.2.2 h1:j58spza2L6s+vAibifHSuUPrXm0+6nWZWR3SOg8ihBk=
github.com/ralvarezdev/go-logger v0.2.2/go.mod h1:v5OvFrkS+wsYNTCVegXWiRhBtcYrQJr4LDMDntvpAos=
github.com/ralvarezdev/go-logger v0.3.0 h1:KjIA2NEEPsHy8vOpdPYO21fCMEx8XmbIfhRlqd7WjVI=
github.com/ralvarezdev/go-logger v0.3.0/go.mod h1:v5OvFrkS+wsYNTCVegXWiRhBtcYrQJr4LDMDntvpAos=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
Expand Down Expand Up @@ -94,6 +102,7 @@ golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
Expand Down Expand Up @@ -121,6 +130,7 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.213.0 h1:KmF6KaDyFqB417T68tMPbVmmwtIXs2VB60OJKIHB0xQ=
google.golang.org/api v0.213.0/go.mod h1:V0T5ZhNUUNpYAlL306gFZPFt5F5D/IeyLoktduYYnvQ=
google.golang.org/api v0.214.0/go.mod h1:bYPpLG8AyeMWwDU6NXoB00xC0DFkikVvd5MfwoxjLqE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 h1:8ZmaLZE4XWrtU3MyClkYqqtl6Oegr3235h7jxsDyqCY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU=
google.golang.org/grpc v1.69.2 h1:U3S9QEtbXC0bYNvRtcoklF3xGtLViumSYxWykJS+7AU=
Expand Down
9 changes: 4 additions & 5 deletions server/metadata/metadata.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package metadata

import (
gogrpcgcloud "github.com/ralvarezdev/go-grpc/cloud/gcloud"
gojwt "github.com/ralvarezdev/go-jwt"
gojwtgrpc "github.com/ralvarezdev/go-jwt/grpc"
goloadergcloud "github.com/ralvarezdev/go-loader/cloud/gcloud"
"google.golang.org/grpc/metadata"
"strings"
)
Expand All @@ -12,13 +12,12 @@ import (
func GetTokenFromMetadata(md metadata.MD, tokenKey string) (string, error) {
// Get the authorization from the metadata
authorization := md.Get(tokenKey)
tokenIdx := gojwtgrpc.TokenIdx.Int()
if len(authorization) <= tokenIdx {
if len(authorization) <= gojwtgrpc.AuthorizationTokenIdx {
return "", gojwtgrpc.ErrAuthorizationMetadataNotProvided
}

// Get the authorization value from the metadata
authorizationValue := authorization[tokenIdx]
authorizationValue := authorization[gojwtgrpc.AuthorizationTokenIdx]

// Split the authorization value by space
authorizationFields := strings.Split(authorizationValue, " ")
Expand All @@ -38,5 +37,5 @@ func GetAuthorizationTokenFromMetadata(md metadata.MD) (string, error) {

// GetGCloudAuthorizationTokenFromMetadata gets the GCloud authorization token from the metadata
func GetGCloudAuthorizationTokenFromMetadata(md metadata.MD) (string, error) {
return GetTokenFromMetadata(md, goloadergcloud.AuthorizationMetadataKey)
return GetTokenFromMetadata(md, gogrpcgcloud.AuthorizationMetadataKey)
}

0 comments on commit 2ba03ca

Please sign in to comment.