joken-elixir / joken

Elixir JWT library
Apache License 2.0
773 stars 103 forks source link

Intermittent ** (Joken.Error) Couldn't recognize the signer algorithm. #369

Closed aphillipo closed 2 years ago

aphillipo commented 2 years ago

Hey I'm doing the following,

signer = Joken.Signer.create("HS256", @config[:api_secret])

But from time to time I get:


     ** (Joken.Error) Couldn't recognize the signer algorithm.

     Possible values are:

     ["HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "ES256", "ES384", "ES512", "PS256", "PS384", "PS512", "Ed25519", "Ed25519ph", "Ed448", "Ed448ph"]

I literally just added some IO.inspect calls to print off the value of @config[:api_secret] and now it magically works again even after removing the inspect calls, not that it should have mattered.

I have come to the conclusion that is must be a config thing with my Mac or something but I just cannot for the life of me figure it out. Sometimes deleting _build helps other times not. Maybe there is some time/clock thing involved but everything seems okay and it doesn't look like time is exp etc. is part of this signer creation process.

Any ideas welcome but it's extremely confusing. I'm on an M1 Max if that makes any difference.

aphillipo commented 2 years ago

@config[:api_secret] was empty under some weird conditions... probably should be a better/correct error for nil/empty secrets.

victorolinasc commented 2 years ago

Sorry for the long delay... I was on vacations :)

Glad it turned out fine. Will look into it in more detail this week

aphillipo commented 2 years ago

No worries at all Victor! Joken is so good and simple, thanks for all your work on it!