Skip to content

fix: omit null nonce in id token and add config documentation - #9

Merged
hashemix merged 6 commits into
mainfrom
fix/skip-null-idtoken-claims
Jun 24, 2026
Merged

fix: omit null nonce in id token and add config documentation#9
hashemix merged 6 commits into
mainfrom
fix/skip-null-idtoken-claims

Conversation

@hashemix

Copy link
Copy Markdown
Member

Description

Three changes:

1. Fix ID Token Serialization

Add #[serde(skip_serializing_if = "Option::is_none")] on all optional
IdTokenClaims fields (nonce, at_hash, c_hash, azp, typ, sid,
jti, auth_time).

Previously, None values were serialized as null in the JWT payload
(e.g. "nonce": null). oauth4webapi performs a strict-equality check
on the nonce claim and rejects the ID token when it sees "nonce": null
instead of the key being absent. Now the key is omitted entirely when absent,
matching the OIDC Core spec.

2. Sample Config File

Add config.sample.yaml with every IssuerConfig field documented and
set to its default value, so users have a ready-to-copy reference.

3. Documentation

Add a "Configuration" section to the README covering default_user_id,
all config fields with their env vars (OAUTH_*) and defaults, loading
order, and a reference to the sample config file.

Update src/lib.rs doc comments with a pointer to the README config docs.

Changes

  • src/models.rs - Add #[serde(skip_serializing_if = "Option::is_none")]
    to all Option fields in IdTokenClaims
  • config.sample.yaml - New sample config file
  • README.md - New "Configuration" section with full field table
  • src/lib.rs - Brief config docs referencing README

Tests

  • tests/crypto.rs
    • test_id_token_omits_nonce_key_when_not_provided - raw JSON assert
      that "nonce" key is absent when none was sent
    • test_id_token_includes_nonce_key_when_provided - raw JSON assert
      that key is present when nonce is sent
  • src/main.rs
    • test_id_token_omits_nonce_when_not_sent - full HTTP end-to-end flow
      without nonce, checks ID token payload
  • tests/config.rs
    • test_config_sample_file - parses config.sample.yaml and asserts
      every field matches documented defaults

@hashemix
hashemix merged commit 529ca98 into main Jun 24, 2026
9 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