Skip to content

Add iss element to jwt claim#8

Merged
seun-ja merged 1 commit into
mainfrom
feat/add_iss_to_claim
Apr 12, 2026
Merged

Add iss element to jwt claim#8
seun-ja merged 1 commit into
mainfrom
feat/add_iss_to_claim

Conversation

@seun-ja

@seun-ja seun-ja commented Apr 10, 2026

Copy link
Copy Markdown
Owner

Adds optional issuer to claims

Signed-off-by: Aminu Oluwaseun Joshua <seun.aminujoshua@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an optional JWT issuer (iss) claim to the crate’s JWT Claims model and updates JWT-related tests accordingly.

Changes:

  • Extend Claims with an optional iss: Option<String> field (omitted during serialization when None).
  • Update JWT tests to construct Claims with an iss value.
  • Add a new public accessor ApiError::status_code().

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/jwt.rs Adds optional iss field to JWT claims with conditional serialization.
src/tests/jwt.rs Updates claim construction in tests to include iss.
src/error.rs Adds a public status_code() accessor on ApiError.
Comments suppressed due to low confidence (1)

src/tests/jwt.rs:68

  • Tests now include iss when constructing Claims, but they never assert that iss round-trips through encode/decode. Consider asserting decoded.iss == Some("test".to_string()) in the valid-token test, and adding a small test case where iss is omitted (None) to ensure backwards compatibility for tokens without an issuer.
fn decode_jwt_valid_token() {
    let secret = "mysecret";
    let claims = Claims {
        prompt: "test prompt".to_string(),
        exp: 9999999999,
        iss: Some("test".to_string()),
    };
    let token = jsonwebtoken::encode(
        &jsonwebtoken::Header::default(),
        &claims,
        &jsonwebtoken::EncodingKey::from_secret(secret.as_bytes()),
    )
    .unwrap();
    let decoded = decode_jwt(&token, secret).unwrap();
    assert_eq!(decoded.prompt, "test prompt");
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/error.rs
Comment on lines +56 to +60
impl ApiError {
pub fn status_code(&self) -> u16 {
self.status
}
}

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description focuses on adding an optional iss claim, but this change also adds a new public API (ApiError::status_code). If this method is required for the JWT issuer work, please update the PR description to mention it; otherwise consider splitting it into a separate PR to keep changes scoped and easier to review/revert.

Copilot uses AI. Check for mistakes.
@seun-ja
seun-ja merged commit 9806523 into main Apr 12, 2026
5 checks passed
@seun-ja
seun-ja deleted the feat/add_iss_to_claim branch April 12, 2026 22:41
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.

2 participants