Thalhammer / jwt-cpp

A header only library for creating and validating json web tokens in c++
https://thalhammer.github.io/jwt-cpp/
MIT License
828 stars 229 forks source link

Default constructor for jwks object #346

Closed justend29 closed 2 months ago

justend29 commented 2 months ago

I appreciate the design to always uphold the invariants of every type. For jwt::jwks, which is an object holding a collection of jwks, constructing an empty collection of jwks is valid and maintains the invariants of the type. The motivation for this is encapsulating jwt::jwks in a caching class, where JWKs are often cached with periodic refreshing. There aren't any keys until fetched from issuer. I found myself doing jwt::jwks{"{\"keys\":[]}"} since there wasn't a default constructor, which feels silly.

justend29 commented 2 months ago

whoever created the CI job to not only indicate exactly where the lining error is, but also generate a patch file and sample commands to apply it deserves a gold star.

prince-chrismc commented 2 months ago

also generate a patch file and sample commands to apply it deserves a gold star.

⭐ appreciate it 🙏

prince-chrismc commented 2 months ago

It would be amazing to have a test to help ensure this behavior is maintained :)

Similar to

https://github.com/prince-chrismc/jwt-cpp/blob/e9cd684d027eb40396f2db6b07f41275415806a4/tests/JwksTest.cpp#L55

But just check the list empty (you might need to usenthe itors to count)

justend29 commented 2 months ago

@prince-chrismc I shouldn't have made the PR w/o a test. It's in.