Mojo-JWT icon indicating copy to clipboard operation
Mojo-JWT copied to clipboard

Consider returning new JWT on decode

Open rpcme opened this issue 10 years ago • 6 comments

I am having a difficult time managing JWTs when the decode method is stomping on values. It also makes it difficult to test.

delete $self->{$_} for qw/claims expires not_before/;

Perhaps it may work to have the encode and decode methods be static.

rpcme avatar Apr 26 '15 13:04 rpcme

that does sound intriguing, I'll give it a look soonish

jberger avatar Apr 26 '15 23:04 jberger

I guess the value of extending your module is when I can modify what ->claims produces. Right now, I basically override the claims attribute so ->encode can take values based on some set of behaviours the programmer needs as per google's (or other) rules.

unfortunately, it seems as though ->decode does enough damage where I can't even decode and look at exp (which makes it so I can't validate the value).

another option is $jwt->plan (surely there's some name far more correct than this), which produces the claim that would be encoded.

Most of this is talking out loud.

rpcme avatar Apr 27 '15 20:04 rpcme

Yeah, I get your point. I was imagining that a user would create a new instance per message, in which case encode and decode make sense as they are, but that said, doing as you say would enforce that. I really do think it is worth consideration, I just haven't had a moment to look at it.

jberger avatar Apr 27 '15 21:04 jberger

Yep, no problem. Maybe we can hash it out next month.

On Apr 27, 2015, at 5:37 PM, Joel Berger [email protected] wrote:

Yeah, I get your point. I was imagining that a user would create a new instance per message, in which case encode and decode make sense as they are, but that said, doing as you say would enforce that. I really do think it is worth consideration, I just haven't had a moment to look at it.

— Reply to this email directly or view it on GitHub https://github.com/jberger/Mojo-JWT/issues/3#issuecomment-96828711.

rpcme avatar Apr 27 '15 22:04 rpcme

Is this still in the works?

strangelittlemonkey avatar Mar 07 '17 06:03 strangelittlemonkey

The thought is still on my mind yes, I just haven't seen much need to actually do it. If you are interested in presenting a patch, I'd consider it.

jberger avatar Mar 07 '17 15:03 jberger