Skip to content

fix(auth): use PEM format for Keycloak RSA public key verification#99

Merged
JanZachmann merged 2 commits intoomnect:mainfrom
JanZachmann:update-centrifugo-v6.6.0
Feb 18, 2026
Merged

fix(auth): use PEM format for Keycloak RSA public key verification#99
JanZachmann merged 2 commits intoomnect:mainfrom
JanZachmann:update-centrifugo-v6.6.0

Conversation

@JanZachmann
Copy link
Contributor

Summary

  • Fix InvalidSignature error in Keycloak portal token validation caused by the jwt-simplejsonwebtoken migration
  • DecodingKey::from_rsa_der() does not handle the SPKI format Keycloak returns; replaced with from_rsa_pem() and PEM header wrapping
  • Extract key conversion into decoding_key_from_keycloak() pure function and add unit tests with a real RSA keypair

Reason

The jwt-simplejsonwebtoken migration (#97) broke Keycloak token verification. All existing tests mocked SingleSignOnProvider::verify_token() at the trait level, so the actual RSA key parsing and signature verification had zero test coverage.

Verification

  • cargo test --features mock — 3 new tests exercise real RSA key format conversion and JWT signature verification
  • Deployed to device and confirmed portal auth flow succeeds

## Summary
- Updated Centrifugo from v6.1.0 to v6.6.0
- Bumped project version to 1.1.2
- Includes Go 1.25.5 security patches and performance improvements

## Reason
Update to the latest Centrifugo release to benefit from performance optimizations,
improved observability, and security updates in the Go runtime (1.25.5).

Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
The jwt-simple to jsonwebtoken migration used DecodingKey::from_rsa_der()
which doesn't handle the SPKI format returned by Keycloak's realm endpoint.
Switch to from_rsa_pem() with proper PEM header wrapping.

Extract the key conversion into a testable function and add unit tests
that exercise the real RSA signature verification path with a test keypair.

Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
@JanZachmann JanZachmann merged commit 3916530 into omnect:main Feb 18, 2026
2 checks passed
JanZachmann added a commit that referenced this pull request Feb 18, 2026
## Summary

- `jsonwebtoken` v9 `Validation::new()` enforces `aud` (audience) claim
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
- Disables `aud` validation to match prior behavior (same approach
already used for `iss`)

Follow-up to #99 — signature verification now passes but audience
validation was rejecting valid tokens with `InvalidAudience`.

Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
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