loco-rs / loco

🚂 🦀 The one-person framework for Rust for side-projects and startups
https://loco.rs
Apache License 2.0
5.52k stars 235 forks source link

Can add claims but can't access UserClaims claims in project #988

Closed SorenTriacc closed 3 days ago

SorenTriacc commented 1 week ago

Description Not able to access UserClaims claims after they are set.

Upon trying to add a custom claim to the user JWT I was able to add items to claims as a serde_json::Value but when trying to read the claim in a middleware layer I wasn't able to access them because claims is private. `

[derive(Debug, Serialize, Deserialize)]

pub struct UserClaims { pub pid: String, exp: usize, claims: Option, } `

Expected Behavior

The expectation is that custom claims could be accessed after being set. Such that they can be accessed via UserClaims.claims or deconstructed in the scope of the project. I would suggest making claims public like pid.

Environment:

Additional Context

I am somewhat new, and this might be an oversight on my end. However, I don't believe that the claims:Option<serde_json> in UserClaims would serve any purpose internally besides allowing the developer to set custom claims in the JWT token.

jondot commented 3 days ago

thanks, we've not gotten a PR that fixes this