Reusability and thread-safety of JwtConsumer

Issue #25 resolved
Former user created an issue

First, thanks for this nice library.

At first glance it seems that both JwtConsumerBuilder and JwtConsumer are thread-safe and can be reused, but on deeper inspection we've found that's not the case because of NumericDateValidator.evaluationTime which is set in the constructor.

It would be nice if we could build a JwtConsumer only once and just reuse it for every token validation.

Comments (7)

  1. Brian Campbell repo owner

    Yeah, okay, that's definitely a fair request. I really need to be able to set an evaluation time for a bunch of tests but I could make it so things are thread-safe and can be reused when an explicit evaluation time isn't given. And maybe also think about better/different ways of exposing something to help with testing.

  2. Brian Campbell repo owner

    fix #25 so now if an explicit evaluation time isn’t given to the JwtConsumer[Builder], get the current time during NumericDateValidator.validate(...) so that a JwtConsumer can be created once and used many times and in multiple threads

    → <<cset bf34a2f50ce4>>

  3. Brian Campbell repo owner

    addressed with bf34a2f "fix #25 so now if an explicit evaluation time isn’t given to the JwtConsumer[Builder], get the current time during NumericDateValidator.validate(...) so that a JwtConsumer can be created once and used many times and in multiple threads"

  4. Log in to comment