authn: the insecure JWKS transport ignores proxy env vars and DefaultTransport's defaults

Aperta Adatta ai principianti
#153 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
74/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
go

Direzione di ricerca

Inizia leggendo authn/manager.go, in particolare la configurazione del trasporto di NewManager mostrata nell’issue. Esamina i test del package authn e aggiungi o aggiorna la copertura del percorso TLS non sicuro. Il lavoro è completato quando quel percorso mantiene il comportamento predefinito del trasporto, incluso il supporto delle variabili d’ambiente del proxy, applicando al contempo l’impostazione TLS richiesta.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Found while migrating nsw-agency from a forked copy of this package to core/authn v0.3.0 (OpenNSW/nsw-agency#213).

What

NewManager builds a bare http.Transport when InsecureSkipTLSVerify is set — authn/manager.go:

httpClient := &http.Client{Timeout: 10 * time.Second}
if authConfig.InsecureSkipTLSVerify {
    httpClient.Transport = &http.Transport{
        TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
    }
}

A zero-valued http.Transport has Proxy == nil, so it ignores HTTP_PROXY/HTTPS_PROXY/NO_PROXY, and it also drops http.DefaultTransport's connection-pool and dial defaults (MaxIdleConns, IdleConnTimeout, TLSHandshakeTimeout, HTTP/2 via ForceAttemptHTTP2).

In a dev environment where the IdP is only reachable through a proxy, the JWKS fetch fails and every token is rejected, with nothing in the error to suggest the proxy was bypassed.

Suggested fix

Clone the default transport instead of replacing it, which is what the code this package replaced in nsw-agency did:

if authConfig.InsecureSkipTLSVerify {
    if tr, ok := http.DefaultTransport.(*http.Transport); ok {
        customTransport := tr.Clone()
        customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} //nolint:gosec
        httpClient.Transport = customTransport
    }
}

Scope

InsecureSkipTLSVerify is gated to development in nsw-agency (it refuses to start unless APP_ENV=development), so the secure path is unaffected — the default nil transport already resolves to http.DefaultTransport. This only bites the dev/self-signed path.

Lingua principale
Go
Stelle
6
Fork
8
Merge medio
21h 36m
PR unite (30g)
42

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OpenNSW/core

Tutte le issue di OpenNSW/core

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.