From 6052e3053f29b0767b4bcde9a130fb7166d18154 Mon Sep 17 00:00:00 2001 From: Michael Sverdlik <113865820+michael-strigo@users.noreply.github.com> Date: Tue, 12 Sep 2023 11:18:11 +1000 Subject: [PATCH] Skip if Nomad header already set --- plugin.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugin.go b/plugin.go index 43908e8..a46970d 100644 --- a/plugin.go +++ b/plugin.go @@ -63,10 +63,16 @@ func (p *Plugin) ServeHTTP(rw http.ResponseWriter, req *http.Request) { return } + if req.Header.Get(NOMAD_HEADER) != "" { + p.logger.Printf("Existing %v header already set - skipping\n", NOMAD_HEADER) + p.next.ServeHTTP(rw, req) + return + } + // Check if token already cached and valid. If not, reach out to Nomad to // get a new one and cache it. token, ok := tokenCache.Get(cfjwt) - if !ok || time.Now().UTC().After(token.ExpirationTime) { + if !ok || time.Now().After(token.ExpirationTime) { var err error p.logger.Println("Assertion not cached - connecting to Nomad")