From e50fb968ebe186b864575144801d5f1ab0d7cde6 Mon Sep 17 00:00:00 2001 From: Marcos Huck Date: Wed, 21 Feb 2024 20:14:27 +0000 Subject: [PATCH 1/9] Bump gz-go version to v10 --- encoders/marshaler.go | 2 +- examples/authentication/http/main.go | 2 +- go.mod | 2 +- mailing/sendgrid_builder.go | 2 +- main.go | 2 +- monitoring/prometheus/prometheus.go | 2 +- monitoring_prometheus_test.go | 4 ++-- net/client.go | 2 +- net/client_test.go | 2 +- net/http.go | 4 ++-- repository/firestore/firestore.go | 6 +++--- repository/firestore/firestore_test.go | 4 ++-- repository/firestore/options.go | 4 ++-- repository/firestore/options_test.go | 2 +- repository/sql/options.go | 2 +- repository/sql/options_test.go | 4 ++-- repository/sql/repository.go | 4 ++-- repository/sql/repository_test.go | 4 ++-- router.go | 2 +- utility.go | 2 +- 20 files changed, 29 insertions(+), 29 deletions(-) diff --git a/encoders/marshaler.go b/encoders/marshaler.go index 8e4aff0..680d97a 100644 --- a/encoders/marshaler.go +++ b/encoders/marshaler.go @@ -4,7 +4,7 @@ import ( "context" "io" - "github.com/gazebo-web/gz-go/v9/telemetry" + "github.com/gazebo-web/gz-go/v10/telemetry" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "go.opentelemetry.io/otel/codes" ) diff --git a/examples/authentication/http/main.go b/examples/authentication/http/main.go index dcb6283..0785644 100644 --- a/examples/authentication/http/main.go +++ b/examples/authentication/http/main.go @@ -7,7 +7,7 @@ import ( "time" "github.com/gazebo-web/auth/pkg/authentication" - "github.com/gazebo-web/gz-go/v9/middleware" + "github.com/gazebo-web/gz-go/v10/middleware" "github.com/rs/cors" ) diff --git a/go.mod b/go.mod index 099234b..99d0e20 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/gazebo-web/gz-go/v9 +module github.com/gazebo-web/gz-go/v10 go 1.21 diff --git a/mailing/sendgrid_builder.go b/mailing/sendgrid_builder.go index cf264e4..0d43e31 100644 --- a/mailing/sendgrid_builder.go +++ b/mailing/sendgrid_builder.go @@ -1,7 +1,7 @@ package mailing import ( - "github.com/gazebo-web/gz-go/v9/structs" + "github.com/gazebo-web/gz-go/v10/structs" "github.com/sendgrid/sendgrid-go/helpers/mail" ) diff --git a/main.go b/main.go index 32f9cfd..2cb5011 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,7 @@ import ( "strings" "time" - "github.com/gazebo-web/gz-go/v9/monitoring" + "github.com/gazebo-web/gz-go/v10/monitoring" "github.com/gorilla/mux" "github.com/rollbar/rollbar-go" "gorm.io/driver/mysql" diff --git a/monitoring/prometheus/prometheus.go b/monitoring/prometheus/prometheus.go index 15981eb..add77c5 100644 --- a/monitoring/prometheus/prometheus.go +++ b/monitoring/prometheus/prometheus.go @@ -7,7 +7,7 @@ import ( "strings" "time" - "github.com/gazebo-web/gz-go/v9/monitoring" + "github.com/gazebo-web/gz-go/v10/monitoring" "github.com/gorilla/mux" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" diff --git a/monitoring_prometheus_test.go b/monitoring_prometheus_test.go index daf8224..0310335 100644 --- a/monitoring_prometheus_test.go +++ b/monitoring_prometheus_test.go @@ -5,8 +5,8 @@ import ( "net/http/httptest" "testing" - "github.com/gazebo-web/gz-go/v9/monitoring" - "github.com/gazebo-web/gz-go/v9/monitoring/prometheus" + "github.com/gazebo-web/gz-go/v10/monitoring" + "github.com/gazebo-web/gz-go/v10/monitoring/prometheus" "github.com/gorilla/mux" "github.com/stretchr/testify/suite" "gorm.io/gorm" diff --git a/net/client.go b/net/client.go index dd9b895..f2b8726 100644 --- a/net/client.go +++ b/net/client.go @@ -5,7 +5,7 @@ import ( "errors" "reflect" - "github.com/gazebo-web/gz-go/v9/encoders" + "github.com/gazebo-web/gz-go/v10/encoders" ) var ( diff --git a/net/client_test.go b/net/client_test.go index 8cc881a..2fa604a 100644 --- a/net/client_test.go +++ b/net/client_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/gazebo-web/gz-go/v9/encoders" + "github.com/gazebo-web/gz-go/v10/encoders" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/net/http.go b/net/http.go index 1511d06..742cc6e 100644 --- a/net/http.go +++ b/net/http.go @@ -10,8 +10,8 @@ import ( "strings" "time" - "github.com/gazebo-web/gz-go/v9/encoders" - "github.com/gazebo-web/gz-go/v9/telemetry" + "github.com/gazebo-web/gz-go/v10/encoders" + "github.com/gazebo-web/gz-go/v10/telemetry" "go.opentelemetry.io/otel/codes" ) diff --git a/repository/firestore/firestore.go b/repository/firestore/firestore.go index 7abff03..f23273b 100644 --- a/repository/firestore/firestore.go +++ b/repository/firestore/firestore.go @@ -4,9 +4,9 @@ import ( "context" "cloud.google.com/go/firestore" - "github.com/gazebo-web/gz-go/v9/errors" - "github.com/gazebo-web/gz-go/v9/reflect" - "github.com/gazebo-web/gz-go/v9/repository" + "github.com/gazebo-web/gz-go/v10/errors" + "github.com/gazebo-web/gz-go/v10/reflect" + "github.com/gazebo-web/gz-go/v10/repository" "google.golang.org/api/iterator" ) diff --git a/repository/firestore/firestore_test.go b/repository/firestore/firestore_test.go index 493a6af..925d26f 100644 --- a/repository/firestore/firestore_test.go +++ b/repository/firestore/firestore_test.go @@ -9,8 +9,8 @@ import ( "cloud.google.com/go/firestore" firebase "firebase.google.com/go/v4" - "github.com/gazebo-web/gz-go/v9/errors" - "github.com/gazebo-web/gz-go/v9/repository" + "github.com/gazebo-web/gz-go/v10/errors" + "github.com/gazebo-web/gz-go/v10/repository" "github.com/stretchr/testify/suite" ) diff --git a/repository/firestore/options.go b/repository/firestore/options.go index 3500929..a5bf9e9 100644 --- a/repository/firestore/options.go +++ b/repository/firestore/options.go @@ -4,8 +4,8 @@ import ( "errors" "cloud.google.com/go/firestore" - "github.com/gazebo-web/gz-go/v9/pagination" - "github.com/gazebo-web/gz-go/v9/repository" + "github.com/gazebo-web/gz-go/v10/pagination" + "github.com/gazebo-web/gz-go/v10/repository" ) // Option is a Firestore-specific repository.Option implementation. diff --git a/repository/firestore/options_test.go b/repository/firestore/options_test.go index b307e90..965223f 100644 --- a/repository/firestore/options_test.go +++ b/repository/firestore/options_test.go @@ -3,7 +3,7 @@ package firestore import ( "testing" - "github.com/gazebo-web/gz-go/v9/repository" + "github.com/gazebo-web/gz-go/v10/repository" "github.com/stretchr/testify/assert" ) diff --git a/repository/sql/options.go b/repository/sql/options.go index d2d6913..ad359f6 100644 --- a/repository/sql/options.go +++ b/repository/sql/options.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/gazebo-web/gz-go/v9/repository" + "github.com/gazebo-web/gz-go/v10/repository" "gorm.io/gorm" ) diff --git a/repository/sql/options_test.go b/repository/sql/options_test.go index 58975e5..ec3cfc0 100644 --- a/repository/sql/options_test.go +++ b/repository/sql/options_test.go @@ -5,8 +5,8 @@ import ( "fmt" "testing" - utilsgorm "github.com/gazebo-web/gz-go/v9/database/gorm" - "github.com/gazebo-web/gz-go/v9/repository" + utilsgorm "github.com/gazebo-web/gz-go/v10/database/gorm" + "github.com/gazebo-web/gz-go/v10/repository" "github.com/stretchr/testify/suite" "gorm.io/gorm" ) diff --git a/repository/sql/repository.go b/repository/sql/repository.go index 68c01fc..794b050 100644 --- a/repository/sql/repository.go +++ b/repository/sql/repository.go @@ -3,8 +3,8 @@ package sql import ( "context" - "github.com/gazebo-web/gz-go/v9/reflect" - "github.com/gazebo-web/gz-go/v9/repository" + "github.com/gazebo-web/gz-go/v10/reflect" + "github.com/gazebo-web/gz-go/v10/repository" "gorm.io/gorm" ) diff --git a/repository/sql/repository_test.go b/repository/sql/repository_test.go index ca492bf..e29e6ce 100644 --- a/repository/sql/repository_test.go +++ b/repository/sql/repository_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" - utilsgorm "github.com/gazebo-web/gz-go/v9/database/gorm" - "github.com/gazebo-web/gz-go/v9/repository" + utilsgorm "github.com/gazebo-web/gz-go/v10/database/gorm" + "github.com/gazebo-web/gz-go/v10/repository" "github.com/stretchr/testify/suite" "gorm.io/gorm" ) diff --git a/router.go b/router.go index f25ff79..fdbc298 100644 --- a/router.go +++ b/router.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/codegangsta/negroni" - "github.com/gazebo-web/gz-go/v9/monitoring" + "github.com/gazebo-web/gz-go/v10/monitoring" "github.com/gorilla/mux" ) diff --git a/utility.go b/utility.go index 07edead..2e64701 100644 --- a/utility.go +++ b/utility.go @@ -20,7 +20,7 @@ import ( "text/template" "github.com/form3tech-oss/jwt-go" - gzerrors "github.com/gazebo-web/gz-go/v9/errors" + gzerrors "github.com/gazebo-web/gz-go/v10/errors" ) // GetUserIdentity returns the user identity found in the http request's JWT From ae1359c70d85ebcc39e172a2a05783eca441a083 Mon Sep 17 00:00:00 2001 From: Marcos Huck Date: Wed, 21 Feb 2024 20:25:05 +0000 Subject: [PATCH 2/9] Fix missing imports --- README.md | 2 +- database/gorm/gorm.go | 1 - mailing/sendgrid_injector.go | 2 -- mailing/sendgrid_test.go | 1 - mailing/ses.go | 1 - mailing/templates_test.go | 1 - scheduler/scheduler.go | 1 - storage/filesystem_storage.go | 1 - storage/gcs.go | 1 - storage/storage.go | 1 - 10 files changed, 1 insertion(+), 11 deletions(-) diff --git a/README.md b/README.md index a4ede6d..941d631 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ func example() { ## Installing ### Using Go CLI ``` -go get github.com/gazebo-web/gz-go/v9 +go get github.com/gazebo-web/gz-go/v10 ``` ## Contribute diff --git a/database/gorm/gorm.go b/database/gorm/gorm.go index 366cba4..db21f7c 100644 --- a/database/gorm/gorm.go +++ b/database/gorm/gorm.go @@ -4,7 +4,6 @@ import ( "errors" "log" - "github.com/gazebo-web/gz-go/v9" "gorm.io/gorm" ) diff --git a/mailing/sendgrid_injector.go b/mailing/sendgrid_injector.go index ad4211c..a3aadba 100644 --- a/mailing/sendgrid_injector.go +++ b/mailing/sendgrid_injector.go @@ -1,7 +1,5 @@ package mailing -import "github.com/gazebo-web/gz-go/v9" - // contentInjector is a function that prepares and configures email content to be sent by sendgridEmailService. type contentInjector func(b sendgridEmailBuilder, key string, data any) (sendgridEmailBuilder, error) diff --git a/mailing/sendgrid_test.go b/mailing/sendgrid_test.go index c2e636a..2d35a11 100644 --- a/mailing/sendgrid_test.go +++ b/mailing/sendgrid_test.go @@ -6,7 +6,6 @@ import ( "net/http" "testing" - "github.com/gazebo-web/gz-go/v9" "github.com/sendgrid/rest" "github.com/sendgrid/sendgrid-go/helpers/mail" "github.com/stretchr/testify/mock" diff --git a/mailing/ses.go b/mailing/ses.go index 5f4f333..57f6e4c 100644 --- a/mailing/ses.go +++ b/mailing/ses.go @@ -9,7 +9,6 @@ import ( "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/ses" "github.com/aws/aws-sdk-go/service/ses/sesiface" - "github.com/gazebo-web/gz-go/v9" ) // awsSimpleEmailService implements the Sender interface using AWS Simple Email Service API. diff --git a/mailing/templates_test.go b/mailing/templates_test.go index 361bc28..793d919 100644 --- a/mailing/templates_test.go +++ b/mailing/templates_test.go @@ -6,7 +6,6 @@ import ( "net/http" "testing" - "github.com/gazebo-web/gz-go/v9" "github.com/sendgrid/rest" "github.com/stretchr/testify/suite" ) diff --git a/scheduler/scheduler.go b/scheduler/scheduler.go index d6f09ba..5e79775 100644 --- a/scheduler/scheduler.go +++ b/scheduler/scheduler.go @@ -4,7 +4,6 @@ import ( "sync" "time" - "github.com/gazebo-web/gz-go/v9" sch "gitlab.com/ignitionrobotics/web/scheduler" ) diff --git a/storage/filesystem_storage.go b/storage/filesystem_storage.go index 5850550..aff10ca 100644 --- a/storage/filesystem_storage.go +++ b/storage/filesystem_storage.go @@ -5,7 +5,6 @@ import ( "io" "os" - "github.com/gazebo-web/gz-go/v9" "github.com/pkg/errors" ) diff --git a/storage/gcs.go b/storage/gcs.go index 95f640e..9a7b97d 100644 --- a/storage/gcs.go +++ b/storage/gcs.go @@ -8,7 +8,6 @@ import ( "time" "cloud.google.com/go/storage" - "github.com/gazebo-web/gz-go/v9" ) // gcs implements Storage using the Google Cloud Storage (GCS) service. diff --git a/storage/storage.go b/storage/storage.go index 8a099ca..da5ce63 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -9,7 +9,6 @@ import ( "path/filepath" "strconv" - "github.com/gazebo-web/gz-go/v9" "github.com/pkg/errors" ) From 4fa5ee67a6f1c95ec4731380b2825e981b04ba55 Mon Sep 17 00:00:00 2001 From: Marcos Huck Date: Wed, 21 Feb 2024 20:27:45 +0000 Subject: [PATCH 3/9] Fix missing imports --- database/gorm/gorm.go | 1 + scheduler/scheduler.go | 1 + 2 files changed, 2 insertions(+) diff --git a/database/gorm/gorm.go b/database/gorm/gorm.go index db21f7c..0ead8a2 100644 --- a/database/gorm/gorm.go +++ b/database/gorm/gorm.go @@ -4,6 +4,7 @@ import ( "errors" "log" + "github.com/gazebo-web/gz-go/v10" "gorm.io/gorm" ) diff --git a/scheduler/scheduler.go b/scheduler/scheduler.go index 5e79775..2b18acd 100644 --- a/scheduler/scheduler.go +++ b/scheduler/scheduler.go @@ -4,6 +4,7 @@ import ( "sync" "time" + "github.com/gazebo-web/gz-go/v10" sch "gitlab.com/ignitionrobotics/web/scheduler" ) From 6f6337972eeb9d1efdc6f44fdb916d4237fb4a03 Mon Sep 17 00:00:00 2001 From: Marcos Huck Date: Wed, 21 Feb 2024 20:29:56 +0000 Subject: [PATCH 4/9] Fix missing imports --- mailing/sendgrid_injector.go | 2 ++ mailing/sendgrid_test.go | 1 + mailing/ses.go | 1 + mailing/templates_test.go | 1 + storage/filesystem_storage.go | 1 + storage/gcs.go | 1 + storage/storage.go | 1 + 7 files changed, 8 insertions(+) diff --git a/mailing/sendgrid_injector.go b/mailing/sendgrid_injector.go index a3aadba..7b0f470 100644 --- a/mailing/sendgrid_injector.go +++ b/mailing/sendgrid_injector.go @@ -1,5 +1,7 @@ package mailing +import "github.com/gazebo-web/gz-go/v10" + // contentInjector is a function that prepares and configures email content to be sent by sendgridEmailService. type contentInjector func(b sendgridEmailBuilder, key string, data any) (sendgridEmailBuilder, error) diff --git a/mailing/sendgrid_test.go b/mailing/sendgrid_test.go index 2d35a11..2448972 100644 --- a/mailing/sendgrid_test.go +++ b/mailing/sendgrid_test.go @@ -6,6 +6,7 @@ import ( "net/http" "testing" + "github.com/gazebo-web/gz-go/v10" "github.com/sendgrid/rest" "github.com/sendgrid/sendgrid-go/helpers/mail" "github.com/stretchr/testify/mock" diff --git a/mailing/ses.go b/mailing/ses.go index 57f6e4c..0cb87ea 100644 --- a/mailing/ses.go +++ b/mailing/ses.go @@ -9,6 +9,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/ses" "github.com/aws/aws-sdk-go/service/ses/sesiface" + "github.com/gazebo-web/gz-go/v10" ) // awsSimpleEmailService implements the Sender interface using AWS Simple Email Service API. diff --git a/mailing/templates_test.go b/mailing/templates_test.go index 793d919..cb79b58 100644 --- a/mailing/templates_test.go +++ b/mailing/templates_test.go @@ -6,6 +6,7 @@ import ( "net/http" "testing" + "github.com/gazebo-web/gz-go/v10" "github.com/sendgrid/rest" "github.com/stretchr/testify/suite" ) diff --git a/storage/filesystem_storage.go b/storage/filesystem_storage.go index aff10ca..99f6732 100644 --- a/storage/filesystem_storage.go +++ b/storage/filesystem_storage.go @@ -5,6 +5,7 @@ import ( "io" "os" + "github.com/gazebo-web/gz-go/v10" "github.com/pkg/errors" ) diff --git a/storage/gcs.go b/storage/gcs.go index 9a7b97d..e63cd48 100644 --- a/storage/gcs.go +++ b/storage/gcs.go @@ -8,6 +8,7 @@ import ( "time" "cloud.google.com/go/storage" + "github.com/gazebo-web/gz-go/v10" ) // gcs implements Storage using the Google Cloud Storage (GCS) service. diff --git a/storage/storage.go b/storage/storage.go index da5ce63..5df4162 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -9,6 +9,7 @@ import ( "path/filepath" "strconv" + "github.com/gazebo-web/gz-go/v10" "github.com/pkg/errors" ) From ed4c5a2a9e959422d3fc7e57bd77866c6e1b6b18 Mon Sep 17 00:00:00 2001 From: Marcos Huck Date: Mon, 4 Mar 2024 19:40:52 +0000 Subject: [PATCH 5/9] Add BearerAccessTokenAuthFuncGRPC --- examples/authentication/http/main.go | 2 +- go.mod | 2 +- go.sum | 2 + middleware/auth_access_token.go | 27 +++++ middleware/auth_access_token_test.go | 103 ++++++++++++++++++ middleware/{auth_bearer.go => auth_jwt.go} | 12 +- .../{auth_bearer_test.go => auth_jwt_test.go} | 94 ++++++++-------- middleware/middleware.go | 6 +- 8 files changed, 190 insertions(+), 58 deletions(-) create mode 100644 middleware/auth_access_token.go create mode 100644 middleware/auth_access_token_test.go rename middleware/{auth_bearer.go => auth_jwt.go} (92%) rename middleware/{auth_bearer_test.go => auth_jwt_test.go} (89%) diff --git a/examples/authentication/http/main.go b/examples/authentication/http/main.go index 0785644..ba5c6ee 100644 --- a/examples/authentication/http/main.go +++ b/examples/authentication/http/main.go @@ -25,7 +25,7 @@ func main() { auth := authentication.NewAuth0(f) // Set up bearer token middleware - bearer := middleware.BearerToken(auth) + bearer := middleware.BearerJWT(auth) // Define HTTP handler h := http.Handler(http.HandlerFunc(handler)) diff --git a/go.mod b/go.mod index 99d0e20..4dcaa3b 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/fatih/structtag v1.2.0 github.com/form3tech-oss/jwt-go v3.2.5+incompatible github.com/fsouza/fake-gcs-server v1.47.7 - github.com/gazebo-web/auth v0.8.0 + github.com/gazebo-web/auth v0.8.1-0.20240304193427-135e58a101d6 github.com/go-chi/chi/v5 v5.0.11 github.com/go-chi/render v1.0.3 github.com/golang-jwt/jwt/v5 v5.2.0 diff --git a/go.sum b/go.sum index 3c096b7..ecc099d 100644 --- a/go.sum +++ b/go.sum @@ -106,6 +106,8 @@ github.com/fsouza/fake-gcs-server v1.47.7 h1:56/U4rKY081TaNbq0gHWi7/71UxC2KROqcn github.com/fsouza/fake-gcs-server v1.47.7/go.mod h1:4vPUynN8/zZlxk5Jpy6LvvTTxItdTAObK4DYnp89Jys= github.com/gazebo-web/auth v0.8.0 h1:TwpFAX9RyZ0uthZ2ubj/svAl7/RzwbxAZIbqim2+OYQ= github.com/gazebo-web/auth v0.8.0/go.mod h1:uvecK4glAnlhq+HIKafL/nJdRbrVtw9TKUVQcXhYYJY= +github.com/gazebo-web/auth v0.8.1-0.20240304193427-135e58a101d6 h1:WPw3pren4cv+Hh1Ivfkqisr1kToT8aFnpUoeKWtii6c= +github.com/gazebo-web/auth v0.8.1-0.20240304193427-135e58a101d6/go.mod h1:uvecK4glAnlhq+HIKafL/nJdRbrVtw9TKUVQcXhYYJY= github.com/go-chi/chi/v5 v5.0.11 h1:BnpYbFZ3T3S1WMpD79r7R5ThWX40TaFB7L31Y8xqSwA= github.com/go-chi/chi/v5 v5.0.11/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4= diff --git a/middleware/auth_access_token.go b/middleware/auth_access_token.go new file mode 100644 index 0000000..3779aed --- /dev/null +++ b/middleware/auth_access_token.go @@ -0,0 +1,27 @@ +package middleware + +import ( + "context" + + "github.com/gazebo-web/auth/pkg/authentication" + grpc_auth "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/auth" +) + +// BearerAccessTokenAuthFuncGRPC returns a grpc_auth.AuthFunc that allows to validate +// incoming access tokens found in the Authorization header. These tokens are +// bearer tokens signed by different authentication providers. +// The validator function received as an argument performs the validation for +// every incoming bearer token. +func BearerAccessTokenAuthFuncGRPC(validator authentication.AccessTokenAuthentication) grpc_auth.AuthFunc { + return func(ctx context.Context) (context.Context, error) { + token, err := grpc_auth.AuthFromMD(ctx, "bearer") + if err != nil { + return nil, err + } + err = validator(ctx, token) + if err != nil { + return nil, err + } + return ctx, nil + } +} diff --git a/middleware/auth_access_token_test.go b/middleware/auth_access_token_test.go new file mode 100644 index 0000000..b26a7f0 --- /dev/null +++ b/middleware/auth_access_token_test.go @@ -0,0 +1,103 @@ +package middleware + +import ( + "context" + "testing" + + grpc_auth "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/auth" + "github.com/grpc-ecosystem/go-grpc-middleware/v2/metadata" + grpc_test "github.com/grpc-ecosystem/go-grpc-middleware/v2/testing/testpb" + "github.com/stretchr/testify/suite" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + grpc_metadata "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +func TestAuthFuncGRPC_AccessToken(t *testing.T) { + ss := &TestAuthAccessTokenSuite{ + InterceptorTestSuite: &grpc_test.InterceptorTestSuite{ + TestService: newTestAuthenticationAccessToken(), + ServerOpts: []grpc.ServerOption{ + grpc.StreamInterceptor(grpc_auth.StreamServerInterceptor(BearerAccessTokenAuthFuncGRPC(validateAccessToken))), + grpc.UnaryInterceptor(grpc_auth.UnaryServerInterceptor(BearerAccessTokenAuthFuncGRPC(validateAccessToken))), + }, + }, + } + suite.Run(t, ss) +} + +func validateAccessToken(ctx context.Context, token string) error { + if token != "ey.LfexACqSU5qgYgp9EXSdR4rtnD7BJ0oOCNi8BKIkZ4vt25jRxyu6AXAKVNrtItb1" { + return status.Error(codes.Unauthenticated, "Invalid access token") + } + return nil +} + +type TestAuthAccessTokenSuite struct { + *grpc_test.InterceptorTestSuite +} + +func (suite *TestAuthAccessTokenSuite) TestNoBearer() { + ctx := context.Background() + client := suite.NewClient() + res, err := client.Ping(ctx, &grpc_test.PingRequest{}) + suite.Assert().Error(err) + suite.Assert().ErrorIs(err, status.Error(codes.Unauthenticated, "Request unauthenticated with bearer")) + suite.Assert().Nil(res) +} + +func (suite *TestAuthAccessTokenSuite) TestNoToken() { + ctx := context.Background() + md := grpc_metadata.Pairs("authorization", "bearer") + ctx = metadata.MD(md).ToOutgoing(ctx) + + client := suite.NewClient() + res, err := client.Ping(ctx, &grpc_test.PingRequest{}) + suite.Assert().Error(err) + suite.Assert().ErrorIs(err, status.Error(codes.Unauthenticated, "Bad authorization string")) + suite.Assert().Nil(res) +} + +func (suite *TestAuthAccessTokenSuite) TestInvalidScheme() { + ctx := context.Background() + ctx = ctxWithToken(ctx, "basic_auth", "test:test") + + client := suite.NewClient() + res, err := client.Ping(ctx, &grpc_test.PingRequest{}) + suite.Assert().Error(err) + suite.Assert().ErrorIs(err, status.Error(codes.Unauthenticated, "Request unauthenticated with bearer")) + suite.Assert().Nil(res) +} + +func (suite *TestAuthAccessTokenSuite) TestInvalidToken() { + ctx := context.Background() + ctx = ctxWithToken(ctx, "bearer", "ey.FfexACqSU5qgYgp9EXSdR4rtnD7BJ0oOCNi8BKIkZ4vt25jRxyu6AXAKVNrtItb1") + + client := suite.NewClient() + res, err := client.Ping(ctx, &grpc_test.PingRequest{}) + suite.Assert().Error(err) + suite.Assert().ErrorIs(err, status.Error(codes.Unauthenticated, "Invalid access token")) + suite.Assert().Nil(res) +} + +func (suite *TestAuthAccessTokenSuite) TestValidToken() { + ctx := context.Background() + ctx = ctxWithToken(ctx, "bearer", "ey.LfexACqSU5qgYgp9EXSdR4rtnD7BJ0oOCNi8BKIkZ4vt25jRxyu6AXAKVNrtItb1") + + client := suite.NewClient() + res, err := client.Ping(ctx, &grpc_test.PingRequest{}) + suite.Assert().NoError(err) + suite.Assert().NotNil(res) +} + +type testAuthAccessToken struct { + grpc_test.UnimplementedTestServiceServer +} + +func (t *testAuthAccessToken) Ping(ctx context.Context, request *grpc_test.PingRequest) (*grpc_test.PingResponse, error) { + return &grpc_test.PingResponse{}, nil +} +func newTestAuthenticationAccessToken() grpc_test.TestServiceServer { + return &testAuthAccessToken{} +} diff --git a/middleware/auth_bearer.go b/middleware/auth_jwt.go similarity index 92% rename from middleware/auth_bearer.go rename to middleware/auth_jwt.go index f4a9197..8a93cea 100644 --- a/middleware/auth_bearer.go +++ b/middleware/auth_jwt.go @@ -11,12 +11,12 @@ import ( "google.golang.org/grpc/status" ) -// BearerToken returns a Middleware for authenticating users using Bearer Tokens in JWT format. -func BearerToken(authentication authentication.Authentication) Middleware { +// BearerJWT returns a Middleware for authenticating users using Bearer Tokens in JWT format. +func BearerJWT(authentication authentication.Authentication) Middleware { return newTokenMiddleware(authentication.VerifyJWT, request.BearerExtractor{}) } -// BearerAuthFuncGRPC returns a new grpc_auth.AuthFunc to use with the gazebo-web authentication library. +// BearerJWTAuthFuncGRPC returns a new grpc_auth.AuthFunc to use with the gazebo-web authentication library. // // The passed in context.Context will contain the gRPC metadata.MD object (for header-based authentication) and // the peer.Peer information that can contain transport-based credentials (e.g. `credentials.AuthInfo`). @@ -24,10 +24,10 @@ func BearerToken(authentication authentication.Authentication) Middleware { // auth := authentication.New[...]() // // srv := grpc.NewServer( -// grpc.StreamInterceptor(grpc_auth.StreamServerInterceptor(BearerAuthFuncGRPC(auth))), -// grpc.UnaryInterceptor(grpc_auth.UnaryServerInterceptor(BearerAuthFuncGRPC(auth))), +// grpc.StreamInterceptor(grpc_auth.StreamServerInterceptor(BearerJWTAuthFuncGRPC(auth))), +// grpc.UnaryInterceptor(grpc_auth.UnaryServerInterceptor(BearerJWTAuthFuncGRPC(auth))), // ) -func BearerAuthFuncGRPC(auth authentication.Authentication, claimInjector ClaimInjectorJWT) grpc_auth.AuthFunc { +func BearerJWTAuthFuncGRPC(auth authentication.Authentication, claimInjector ClaimInjectorJWT) grpc_auth.AuthFunc { return func(ctx context.Context) (context.Context, error) { raw, err := grpc_auth.AuthFromMD(ctx, "bearer") if err != nil { diff --git a/middleware/auth_bearer_test.go b/middleware/auth_jwt_test.go similarity index 89% rename from middleware/auth_bearer_test.go rename to middleware/auth_jwt_test.go index 6e50c3e..3e9c2be 100644 --- a/middleware/auth_bearer_test.go +++ b/middleware/auth_jwt_test.go @@ -27,7 +27,7 @@ import ( ) func TestBearerToken_NoAuthorizationHeader(t *testing.T) { - handler := setupBearerTokenTest(t) + handler := setupJWTTokenTest(t) wr := httptest.NewRecorder() r := httptest.NewRequest("GET", "https://gazebosim.org", nil) @@ -37,7 +37,7 @@ func TestBearerToken_NoAuthorizationHeader(t *testing.T) { } func TestBearerToken_EmptyAuthorizationHeader(t *testing.T) { - handler := setupBearerTokenTest(t) + handler := setupJWTTokenTest(t) wr := httptest.NewRecorder() r := httptest.NewRequest("GET", "https://gazebosim.org", nil) @@ -48,7 +48,7 @@ func TestBearerToken_EmptyAuthorizationHeader(t *testing.T) { } func TestBearerToken_InvalidAuthorizationHeader(t *testing.T) { - handler := setupBearerTokenTest(t) + handler := setupJWTTokenTest(t) wr := httptest.NewRecorder() r := httptest.NewRequest("GET", "https://gazebosim.org", nil) @@ -59,7 +59,7 @@ func TestBearerToken_InvalidAuthorizationHeader(t *testing.T) { } func TestBearerToken_EmptyBearerToken(t *testing.T) { - handler := setupBearerTokenTest(t) + handler := setupJWTTokenTest(t) wr := httptest.NewRecorder() r := httptest.NewRequest("GET", "https://gazebosim.org", nil) @@ -70,7 +70,7 @@ func TestBearerToken_EmptyBearerToken(t *testing.T) { } func TestBearerToken_InvalidBearerTokenRandomString(t *testing.T) { - handler := setupBearerTokenTest(t) + handler := setupJWTTokenTest(t) wr := httptest.NewRecorder() r := httptest.NewRequest("GET", "https://gazebosim.org", nil) @@ -81,7 +81,7 @@ func TestBearerToken_InvalidBearerTokenRandomString(t *testing.T) { } func TestBearerToken_InvalidBearerTokenSignedByAnother(t *testing.T) { - handler := setupBearerTokenTest(t) + handler := setupJWTTokenTest(t) wr := httptest.NewRecorder() r := httptest.NewRequest("GET", "https://gazebosim.org", nil) @@ -92,7 +92,7 @@ func TestBearerToken_InvalidBearerTokenSignedByAnother(t *testing.T) { } func TestBearerToken(t *testing.T) { - handler := setupBearerTokenTest(t) + handler := setupJWTTokenTest(t) token := jwt.NewWithClaims(jwt.SigningMethodRS256, jwt.MapClaims(map[string]interface{}{ "sub": "gazebo-web", @@ -128,13 +128,13 @@ func TestBearerToken(t *testing.T) { assert.Equal(t, http.StatusOK, wr.Code) } -func setupBearerTokenTest(t *testing.T) http.Handler { +func setupJWTTokenTest(t *testing.T) http.Handler { // Set up public key for Authentication service publicKey, err := os.ReadFile("./testdata/key.pem") require.NoError(t, err) // Set up a Bearer token middleware - mw := BearerToken(authentication.NewAuth0(publicKey)) + mw := BearerJWT(authentication.NewAuth0(publicKey)) // Define handler that will be wrapped by the middleware handler := mw(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -147,18 +147,18 @@ func setupBearerTokenTest(t *testing.T) http.Handler { return handler } -func TestAuthFuncGRPC(t *testing.T) { - auth := newTestAuthentication() - ss := &TestAuthSuite{ +func TestAuthFuncGRPC_JWT(t *testing.T) { + auth := newTestAuthenticationJWT() + ss := &TestAuthJWTSuite{ auth: auth, InterceptorTestSuite: &grpc_test.InterceptorTestSuite{ TestService: auth, ServerOpts: []grpc.ServerOption{ - grpc.StreamInterceptor(grpc_auth.StreamServerInterceptor(BearerAuthFuncGRPC(auth, groupClaimInjectors(mandatoryInjection, + grpc.StreamInterceptor(grpc_auth.StreamServerInterceptor(BearerJWTAuthFuncGRPC(auth, groupClaimInjectors(mandatoryInjection, groupClaimInjectors(mandatoryInjection, SubjectClaimer), groupClaimInjectors(optionalInjection, EmailClaimer), )))), - grpc.UnaryInterceptor(grpc_auth.UnaryServerInterceptor(BearerAuthFuncGRPC(auth, groupClaimInjectors(mandatoryInjection, + grpc.UnaryInterceptor(grpc_auth.UnaryServerInterceptor(BearerJWTAuthFuncGRPC(auth, groupClaimInjectors(mandatoryInjection, groupClaimInjectors(mandatoryInjection, SubjectClaimer), groupClaimInjectors(optionalInjection, EmailClaimer), )))), @@ -168,12 +168,12 @@ func TestAuthFuncGRPC(t *testing.T) { suite.Run(t, ss) } -type TestAuthSuite struct { +type TestAuthJWTSuite struct { *grpc_test.InterceptorTestSuite - auth *testAuthService + auth *testAuthJWTService } -func (suite *TestAuthSuite) TestVerifyJWT_FailsNoBearer() { +func (suite *TestAuthJWTSuite) TestVerifyJWT_FailsNoBearer() { ctx := context.Background() client := suite.NewClient() @@ -183,7 +183,7 @@ func (suite *TestAuthSuite) TestVerifyJWT_FailsNoBearer() { suite.Assert().Nil(res) } -func (suite *TestAuthSuite) TestVerifyJWT_FailsVerifyJWTError() { +func (suite *TestAuthJWTSuite) TestVerifyJWT_FailsVerifyJWTError() { ctx := ctxWithToken(context.Background(), "bearer", "1234") expectedError := errors.New("failed to verify token") @@ -197,7 +197,7 @@ func (suite *TestAuthSuite) TestVerifyJWT_FailsVerifyJWTError() { suite.Assert().Nil(res) } -func (suite *TestAuthSuite) TestVerifyJWT_Success() { +func (suite *TestAuthJWTSuite) TestVerifyJWT_Success() { ctx := ctxWithToken(context.Background(), "bearer", "1234") expectedCtx := mock.AnythingOfType("*context.valueCtx") @@ -217,34 +217,6 @@ func ctxWithToken(ctx context.Context, scheme string, token string) context.Cont return metadata.MD(md).ToOutgoing(ctx) } -type testAuthService struct { - grpc_test.UnimplementedTestServiceServer - mock.Mock -} - -func (s *testAuthService) Ping(ctx context.Context, _ *grpc_test.PingRequest) (*grpc_test.PingResponse, error) { - sub, err := ExtractGRPCAuthSubject(ctx) - if err != nil { - return nil, err - } - email, err := ExtractGRPCAuthEmail(ctx) - if err != nil { - return nil, err - } - return &grpc_test.PingResponse{ - Value: strings.Join([]string{sub, email}, ";"), - }, nil -} - -func (s *testAuthService) VerifyJWT(ctx context.Context, token string) (jwt.Claims, error) { - args := s.Called(ctx, token) - return args.Get(0).(jwt.Claims), args.Error(1) -} - -func newTestAuthentication() *testAuthService { - return &testAuthService{} -} - func TestGroupClaimInjectors_Mandatory(t *testing.T) { ctx := grpc_metadata.NewIncomingContext(context.Background(), nil) c := groupClaimInjectors(mandatoryInjection, SubjectClaimer) @@ -329,3 +301,31 @@ func TestGroupClaimInjectors_Combined_NoEmail(t *testing.T) { emails := grpc_metadata.ValueFromIncomingContext(ctx, metadataEmailKey) assert.Empty(t, emails) } + +type testAuthJWTService struct { + grpc_test.UnimplementedTestServiceServer + mock.Mock +} + +func (s *testAuthJWTService) Ping(ctx context.Context, _ *grpc_test.PingRequest) (*grpc_test.PingResponse, error) { + sub, err := ExtractGRPCAuthSubject(ctx) + if err != nil { + return nil, err + } + email, err := ExtractGRPCAuthEmail(ctx) + if err != nil { + return nil, err + } + return &grpc_test.PingResponse{ + Value: strings.Join([]string{sub, email}, ";"), + }, nil +} + +func (s *testAuthJWTService) VerifyJWT(ctx context.Context, token string) (jwt.Claims, error) { + args := s.Called(ctx, token) + return args.Get(0).(jwt.Claims), args.Error(1) +} + +func newTestAuthenticationJWT() *testAuthJWTService { + return &testAuthJWTService{} +} diff --git a/middleware/middleware.go b/middleware/middleware.go index ab9816f..90a64e3 100644 --- a/middleware/middleware.go +++ b/middleware/middleware.go @@ -24,7 +24,7 @@ type Middleware func(http.Handler) http.Handler // newTokenMiddleware initializes a generic middleware that uses token authentication. It attempts to extract the tokens from // the HTTP request, and verifies the access token is valid to continue to the next element in the middleware chain. -func newTokenMiddleware(verify authentication.TokenAuthentication, extractors ...Extractor) Middleware { +func newTokenMiddleware(verify authentication.JsonWebTokenAuthentication, extractors ...Extractor) Middleware { e := request.MultiExtractor(extractors) return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -53,7 +53,7 @@ const ( ) // ExtractGRPCAuthSubject extracts the authentication subject (sub) claim from the context metadata. This claim is -// usually injected in a middleware such as BearerToken or BearerAuthFuncGRPC, if present. +// usually injected in a middleware such as BearerJWT or BearerJWTAuthFuncGRPC, if present. // // From the RFC7519, section 4.1.2: https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.2 // @@ -75,7 +75,7 @@ func InjectGRPCAuthSubject(ctx context.Context, sub string) context.Context { } // ExtractGRPCAuthEmail extracts the custom email (email) claim from the context metadata. This claim is -// usually injected in a middleware such as BearerToken or BearerAuthFuncGRPC, if present. +// usually injected in a middleware such as BearerJWT or BearerJWTAuthFuncGRPC, if present. // // This claim is expected in those provider that inject an email address in their JWT. Not all providers // do such thing. From 8c4bbccab3c4a62a395d8f28964b8dd71009438b Mon Sep 17 00:00:00 2001 From: Marcos Huck Date: Fri, 8 Mar 2024 13:45:27 +0000 Subject: [PATCH 6/9] Make validateAccessToken an inner func to the suite --- middleware/auth_access_token_test.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/middleware/auth_access_token_test.go b/middleware/auth_access_token_test.go index b26a7f0..fe1ba8d 100644 --- a/middleware/auth_access_token_test.go +++ b/middleware/auth_access_token_test.go @@ -15,23 +15,17 @@ import ( ) func TestAuthFuncGRPC_AccessToken(t *testing.T) { - ss := &TestAuthAccessTokenSuite{ + var ss TestAuthAccessTokenSuite + ss = TestAuthAccessTokenSuite{ InterceptorTestSuite: &grpc_test.InterceptorTestSuite{ TestService: newTestAuthenticationAccessToken(), ServerOpts: []grpc.ServerOption{ - grpc.StreamInterceptor(grpc_auth.StreamServerInterceptor(BearerAccessTokenAuthFuncGRPC(validateAccessToken))), - grpc.UnaryInterceptor(grpc_auth.UnaryServerInterceptor(BearerAccessTokenAuthFuncGRPC(validateAccessToken))), + grpc.StreamInterceptor(grpc_auth.StreamServerInterceptor(BearerAccessTokenAuthFuncGRPC(ss.validateAccessToken))), + grpc.UnaryInterceptor(grpc_auth.UnaryServerInterceptor(BearerAccessTokenAuthFuncGRPC(ss.validateAccessToken))), }, }, } - suite.Run(t, ss) -} - -func validateAccessToken(ctx context.Context, token string) error { - if token != "ey.LfexACqSU5qgYgp9EXSdR4rtnD7BJ0oOCNi8BKIkZ4vt25jRxyu6AXAKVNrtItb1" { - return status.Error(codes.Unauthenticated, "Invalid access token") - } - return nil + suite.Run(t, &ss) } type TestAuthAccessTokenSuite struct { @@ -91,6 +85,13 @@ func (suite *TestAuthAccessTokenSuite) TestValidToken() { suite.Assert().NotNil(res) } +func (suite *TestAuthAccessTokenSuite) validateAccessToken(ctx context.Context, token string) error { + if token != "ey.LfexACqSU5qgYgp9EXSdR4rtnD7BJ0oOCNi8BKIkZ4vt25jRxyu6AXAKVNrtItb1" { + return status.Error(codes.Unauthenticated, "Invalid access token") + } + return nil +} + type testAuthAccessToken struct { grpc_test.UnimplementedTestServiceServer } From c7640f9f985c4d9ccf7561323d357ca0dd72cb9c Mon Sep 17 00:00:00 2001 From: Marcos Huck Date: Fri, 8 Mar 2024 13:46:29 +0000 Subject: [PATCH 7/9] Make token a field in TestAuthAccessTokenSuite --- middleware/auth_access_token_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/middleware/auth_access_token_test.go b/middleware/auth_access_token_test.go index fe1ba8d..3f2506e 100644 --- a/middleware/auth_access_token_test.go +++ b/middleware/auth_access_token_test.go @@ -17,6 +17,7 @@ import ( func TestAuthFuncGRPC_AccessToken(t *testing.T) { var ss TestAuthAccessTokenSuite ss = TestAuthAccessTokenSuite{ + token: "ey.LfexACqSU5qgYgp9EXSdR4rtnD7BJ0oOCNi8BKIkZ4vt25jRxyu6AXAKVNrtItb1", InterceptorTestSuite: &grpc_test.InterceptorTestSuite{ TestService: newTestAuthenticationAccessToken(), ServerOpts: []grpc.ServerOption{ @@ -30,6 +31,7 @@ func TestAuthFuncGRPC_AccessToken(t *testing.T) { type TestAuthAccessTokenSuite struct { *grpc_test.InterceptorTestSuite + token string } func (suite *TestAuthAccessTokenSuite) TestNoBearer() { @@ -86,7 +88,7 @@ func (suite *TestAuthAccessTokenSuite) TestValidToken() { } func (suite *TestAuthAccessTokenSuite) validateAccessToken(ctx context.Context, token string) error { - if token != "ey.LfexACqSU5qgYgp9EXSdR4rtnD7BJ0oOCNi8BKIkZ4vt25jRxyu6AXAKVNrtItb1" { + if token != suite.token { return status.Error(codes.Unauthenticated, "Invalid access token") } return nil From 7052c3a11e735b79a00603cecb836edbe521df03 Mon Sep 17 00:00:00 2001 From: Marcos Huck Date: Fri, 8 Mar 2024 13:52:13 +0000 Subject: [PATCH 8/9] Bump auth dependency to v0.9.0 --- go.mod | 8 ++++---- go.sum | 17 ++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 4dcaa3b..089b31b 100644 --- a/go.mod +++ b/go.mod @@ -19,10 +19,10 @@ require ( github.com/fatih/structtag v1.2.0 github.com/form3tech-oss/jwt-go v3.2.5+incompatible github.com/fsouza/fake-gcs-server v1.47.7 - github.com/gazebo-web/auth v0.8.1-0.20240304193427-135e58a101d6 + github.com/gazebo-web/auth v0.9.0 github.com/go-chi/chi/v5 v5.0.11 github.com/go-chi/render v1.0.3 - github.com/golang-jwt/jwt/v5 v5.2.0 + github.com/golang-jwt/jwt/v5 v5.2.1 github.com/gorilla/mux v1.8.1 github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.1 github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 @@ -37,7 +37,7 @@ require ( github.com/satori/go.uuid v1.2.0 github.com/sendgrid/rest v2.6.9+incompatible github.com/sendgrid/sendgrid-go v3.14.0+incompatible - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/urfave/negroni v1.0.0 gitlab.com/ignitionrobotics/web/scheduler v0.5.0 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0 @@ -119,7 +119,7 @@ require ( github.com/prometheus/procfs v0.12.0 // indirect github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46 // indirect github.com/shabbyrobe/gocovmerge v0.0.0-20190829150210-3e036491d500 // indirect - github.com/stretchr/objx v0.5.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/otel/metric v1.23.1 // indirect go.opentelemetry.io/proto/otlp v1.1.0 // indirect diff --git a/go.sum b/go.sum index ecc099d..2e795f4 100644 --- a/go.sum +++ b/go.sum @@ -104,10 +104,8 @@ github.com/form3tech-oss/jwt-go v3.2.5+incompatible h1:/l4kBbb4/vGSsdtB5nUe8L7B9 github.com/form3tech-oss/jwt-go v3.2.5+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/fsouza/fake-gcs-server v1.47.7 h1:56/U4rKY081TaNbq0gHWi7/71UxC2KROqcnrD9BRJhs= github.com/fsouza/fake-gcs-server v1.47.7/go.mod h1:4vPUynN8/zZlxk5Jpy6LvvTTxItdTAObK4DYnp89Jys= -github.com/gazebo-web/auth v0.8.0 h1:TwpFAX9RyZ0uthZ2ubj/svAl7/RzwbxAZIbqim2+OYQ= -github.com/gazebo-web/auth v0.8.0/go.mod h1:uvecK4glAnlhq+HIKafL/nJdRbrVtw9TKUVQcXhYYJY= -github.com/gazebo-web/auth v0.8.1-0.20240304193427-135e58a101d6 h1:WPw3pren4cv+Hh1Ivfkqisr1kToT8aFnpUoeKWtii6c= -github.com/gazebo-web/auth v0.8.1-0.20240304193427-135e58a101d6/go.mod h1:uvecK4glAnlhq+HIKafL/nJdRbrVtw9TKUVQcXhYYJY= +github.com/gazebo-web/auth v0.9.0 h1:nD28XNVmuDNkEDcdKa+0O5Uu41PbkmSyxQjaT+KiCtE= +github.com/gazebo-web/auth v0.9.0/go.mod h1:hZHBuA/l7U/6u7nxoZvbqQAaTbGU44jYi6jm+9E2pok= github.com/go-chi/chi/v5 v5.0.11 h1:BnpYbFZ3T3S1WMpD79r7R5ThWX40TaFB7L31Y8xqSwA= github.com/go-chi/chi/v5 v5.0.11/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4= @@ -129,8 +127,8 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69 github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw= -github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= +github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= @@ -278,8 +276,9 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -287,8 +286,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +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/urfave/negroni v1.0.0 h1:kIimOitoypq34K7TG7DUaJ9kq/N4Ofuwi1sjz0KipXc= github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= From 0cb660066944d636bdb7fc6bd68a039744abd175 Mon Sep 17 00:00:00 2001 From: Marcos Huck Date: Fri, 8 Mar 2024 10:55:36 -0300 Subject: [PATCH 9/9] Update middleware/auth_access_token.go Co-authored-by: Alejo Carballude Signed-off-by: Marcos Huck --- middleware/auth_access_token.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleware/auth_access_token.go b/middleware/auth_access_token.go index 3779aed..df459ad 100644 --- a/middleware/auth_access_token.go +++ b/middleware/auth_access_token.go @@ -7,7 +7,7 @@ import ( grpc_auth "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/auth" ) -// BearerAccessTokenAuthFuncGRPC returns a grpc_auth.AuthFunc that allows to validate +// BearerAccessTokenAuthFuncGRPC returns a grpc_auth.AuthFunc that validates // incoming access tokens found in the Authorization header. These tokens are // bearer tokens signed by different authentication providers. // The validator function received as an argument performs the validation for