From fef0a3cb17e4060c6a7a6ed594f9e9b02ccf2419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 17 Feb 2022 13:57:21 +0100 Subject: [PATCH] Worker: Remove 3rd party code for adding Basic HTTP auth header --- internal/worker/registration.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/internal/worker/registration.go b/internal/worker/registration.go index 191bbe84..f795cc1a 100644 --- a/internal/worker/registration.go +++ b/internal/worker/registration.go @@ -30,7 +30,6 @@ import ( "runtime" "time" - "github.com/deepmap/oapi-codegen/pkg/securityprovider" "github.com/rs/zerolog/log" "gitlab.com/blender/flamenco-ng-poc/internal/appinfo" "gitlab.com/blender/flamenco-ng-poc/pkg/api" @@ -208,14 +207,16 @@ func mustHostname() string { // authenticatedClient constructs a Flamenco client with the given credentials. func authenticatedClient(cfg WorkerConfig, creds WorkerCredentials) api.ClientWithResponsesInterface { - basicAuthProvider, err := securityprovider.NewSecurityProviderBasicAuth(creds.WorkerID, creds.Secret) - if err != nil { - log.Panic().Err(err).Msg("unable to create basic auth provider") - } - flamenco, err := api.NewClientWithResponses( cfg.Manager, - api.WithRequestEditorFn(basicAuthProvider.Intercept), + + // Add a Basic HTTP authentication header to every request to Flamenco Manager. + api.WithRequestEditorFn(func(ctx context.Context, req *http.Request) error { + req.SetBasicAuth(creds.WorkerID, creds.Secret) + return nil + }), + + // Add a User-Agent header to identify this software + its version. api.WithRequestEditorFn(func(ctx context.Context, req *http.Request) error { req.Header.Set("User-Agent", appinfo.UserAgent()) return nil