SMTP/IMAP auth fails with 535 on ThunderID 1.0.0 when Direct-Auth-Secret is not sent

Aperta
#313 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Aravinda-HWK ci sta già lavorando.

Dal 28/10/2026.

  • #314 di @Aravinda-HWK — aperta

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug

Summary

With ThunderID 1.0.0 as the IdP, SMTP AUTH (and IMAP LOGIN) against raven fails with 535 Invalid credentials even though the username and password are correct. ThunderID's Direct API (POST /auth/credentials/authenticate) needs a Direct-Auth-Secret header. If the header is missing, ThunderID rejects the request with 401 AUTH-4010 "Authentication is required" before it checks the password. raven can't tell this apart from a wrong password, so the user sees 535 Invalid credentials.

What we saw

A service account (<user>@<domain>) tried SMTP AUTH PLAIN with a password we know is correct. We tried twice and got the same result both times. raven's SASL log:

PLAIN authentication attempt for user: <user>@<domain>
Authentication API returned status 401 for user: <user>

From outside the cluster, a call to /auth/credentials/authenticate without the header also gives 401 AUTH-4010 for both <user> and <user>@<domain>. That means the IdP rejects the request before it looks at the credentials, so changing or resetting the password won't help.

Root cause

Since #289, raven sends the header, but only when an environment variable is set:

  • internal/idp/token.go: DirectAuthSecret() reads IDP_DIRECT_AUTH_SECRET
  • internal/sasl/server.go (SASL PLAIN/LOGIN for Postfix) and internal/server/auth/auth.go (IMAP LOGIN) add Direct-Auth-Secret only when that value isn't empty

If the variable is unset (or the deployed image is older than #289), raven:

  1. leaves the header out without logging anything,
  2. gets 401 AUTH-4010 from ThunderID,
  3. logs Authentication API returned status 401, which reads the same as a wrong password, and
  4. tells the client Invalid credentials (535 over SMTP).

Neither config/raven.yaml nor docs/ mentions IDP_DIRECT_AUTH_SECRET (or IDP_CLIENT_ID / IDP_CLIENT_SECRET / IDP_RESOURCE), so it's easy to deploy without it.

How to confirm

Run this inside the ThunderID pod. It reads the direct-auth secret and sends it with the request without ever printing it:

oc -n <namespace> exec deploy/<thunderid-deployment> -- sh -c \
 'S=$(cat config/secrets/direct_auth_secret); curl -s -w " HTTP %{http_code}\n" -X POST \
  -H "Content-Type: application/json" -H "Direct-Auth-Secret: $S" \
  http://localhost:8090/auth/credentials/authenticate \
  -d "{\"username\":\"<user>\",\"password\":\"<password>\"}"'

If it returns HTTP 200, the account and password are fine, and the only thing missing is raven sending the header.

Proposed fix

Immediate (deployment): set IDP_DIRECT_AUTH_SECRET on the raven containers (SASL and IMAP) to the same value as ThunderID's config/secrets/direct_auth_secret, and make sure the image includes #289.

In raven:

  • Log a warning at startup (SASL service and IMAP server) when IDP_DIRECT_AUTH_SECRET is unset, or fail fast if ThunderID is the configured IdP.
  • Treat a 401 response with an AUTH-4010 body as a configuration/upstream error: log the IdP error code and answer with a temporary failure ([UNAVAILABLE] / 454) instead of Invalid credentials, so a missing secret doesn't look like a bad password.
  • Document the IDP_* environment variables (IDP_CLIENT_ID, IDP_CLIENT_SECRET, IDP_DIRECT_AUTH_SECRET, IDP_RESOURCE) in the README / deployment docs.
  • Optionally, also support reading the secret from raven.yaml or a mounted file path, to match how ThunderID stores it.

Alternative workaround (if raven can't be updated soon): skip SMTP AUTH for clients inside the cluster (e.g. ThunderID's pods) by trusting them through Postfix mynetworks. This weakens auth and should only be temporary.

Lingua principale
Go
Stelle
12
Fork
13
Merge medio
2g 3h
PR unite (30g)
8

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 OpenGovMail/raven

Tutte le issue di OpenGovMail/raven

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.