Skip to content

fix(auth): restore request payload after Bearer/Basic auth in middleware#102

Merged
JanZachmann merged 3 commits intoomnect:mainfrom
JanZachmann:fix/jwt-audience-validation
Feb 18, 2026
Merged

fix(auth): restore request payload after Bearer/Basic auth in middleware#102
JanZachmann merged 3 commits intoomnect:mainfrom
JanZachmann:fix/jwt-audience-validation

Conversation

@JanZachmann
Copy link
Contributor

@JanZachmann JanZachmann commented Feb 18, 2026

Summary

  • Auth middleware stripped the request body when falling through from session-cookie auth to Bearer/Basic auth, causing all authenticated POST requests with a body to fail after session.purge() (e.g. password change)
  • Restored payload via req.set_payload() after successful Bearer/Basic auth
  • Refactored duplicated auth branches into a single match to prevent future omissions
  • Added regression tests that verify the request body reaches the handler through Bearer and Basic auth paths

Reason

After changing the password, the backend calls session.purge(), invalidating the session cookie. On subsequent requests the middleware falls through to Bearer/Basic auth, calling req.take_payload() to extract the Authorization header — but never restoring the payload. The handler's web::Json<T> extractor then receives an empty body, producing: Json deserialize error: EOF while parsing a value at line 1 column 0.

jsonwebtoken v9 Validation::new() enforces audience (aud) validation
by default. Keycloak tokens set aud to the OIDC client ID, which the
backend does not know. The previous jwt-simple library did not enforce
audience. Disable aud validation to match the prior behavior.

Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
When the session cookie is invalid (e.g. after password change via
session.purge()), the auth middleware takes the request payload to
extract the Authorization header but never restores it. This causes
all authenticated POST requests with a body to fail with
"Json deserialize error: EOF while parsing a value at line 1 column 0".

Restore the payload via req.set_payload() after successful Bearer or
Basic auth. Also refactors the auth branches into a single match to
prevent future omissions.

Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
@JanZachmann JanZachmann merged commit 78c9c74 into omnect:main Feb 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments