Keats / jsonwebtoken

JWT lib in rust
MIT License
1.69k stars 269 forks source link

Lifetime introduction for 0 copy keys proposal #230

Closed BRA1L0R closed 2 years ago

BRA1L0R commented 2 years ago

EndodingKey and DecodingKey do unecessary copies of secret keys or ders when borrowing could be an option.

This is a proposal because I can still see scenarios where a user would want a completely owned key, but if this is the case it should be documented and specified that secrets are always cloned.

Keats commented 2 years ago

So there were actually issues with using lifetimes with them before: https://github.com/Keats/jsonwebtoken/issues/120 I've moved to owning the key entirely since it's usually not something you call often - most of the time you instantiate your keys once.

BRA1L0R commented 2 years ago

So there were actually issues with using lifetimes with them before: #120 I've moved to owning the key entirely since it's usually not something you call often - most of the time you instantiate your keys once.

Ok it makes sense it would indeed incentivize reusing keys instead of creating them multiple times.