46 Replies
@jart can you please help me out here?
Hi there.
You turned on tokens? Can I see your config?
yes let me share it
Here it is:
Removed some comments from it so i can share it here
sorry, I meant the authentication DSL section from your user resource
@jart here it is:
What version of Joken did hex bring in?
nvm.
it hasn't had a release in a year
joken is 2.5.0
Can you tell me what the result of calling
AshAuthentication.Info.authentication_tokens_signing_algorithm!(Dummy.Accounts.User)
is please?
or is the above a compile-time error?Let me check
@jart I am new to ash framework. how can i get the result of the above?
😅
just call it from iex
okay
okay well that's fine.
where are you encountering the error?
After pressing the register button i get this

that's so weird.
are you using a custom register action or just the one that ash auth defined?
ash auth defined
Can you run
AshAuthentication.Info.strategy_for_action!(Dummy.Accounts.User, :register_with_password)
please?
if it returns the strategy then I can't see why it would be failing
I ran
mix phx.gen.secret 32
and added that here.
@jart what should i be replacing <dummy_secret>
with?it's fine how it is
you're getting an error about the signing algorithm not the secret
I am expecting that calling this will cause an exception:
AshAuthentication.Jwt.Config.token_signer(Dummy.Accounts.User)
if it works it will contain your secret so don't paste it hereit doesn't work
just out of interest can you try this:
AshAuthentication.Jwt.Config.token_signer(Dummy.Accounts.User, signing_algorithm: "HS256")
same error
that makes literally no sense.
can you run
mix clean --deps
and recompile and try it again?sure
looks like you're not the only one who has seen this: https://github.com/joken-elixir/joken/issues/369
GitHub
Intermittent ** (Joken.Error) Couldn't recognize the signer algorit...
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 signe...
what should i do to fix it? 😅
recompiling didn't work?
compilin to check
It worked
strange
that is so frustrating
Thank you for your help @jart
I really appreciate it
yes indeed
It happened again today. Can you please look into it because compiling the deps again and again is frustrating.
and this time this issue is persisting.
Unfortunately that is not our library, there is not so much that we can do. And keep in mind, this is free and open source software, we encourage the community to help with issues like this.
I would suggest commenting on that issue, also
Actually...I'm not entirely sure that issue reflects what is happening here
that person said it was their own fault
Are you setting
signing_algorithm
in your DSL anywhere?
nvm, the fact that this line:
Doesn't work tells me that the issue can't be on our end TBH
Its strange that you're the only one having this issue though.
Is there anything special about your development set up that you can think of?
You said that the issue is persisting does that mean compiling dependencies isn't helping?@talha-azeem sorry to hear it’s still going wrong. Can you call
Joken.Signer.create("HS256", "s3cret")
from iex? If not I think you should raise an issue on the joken repo and I’ll jump in and backfill as much info as I can.Will mark this as solved & close it for now, but keen to keep the conversation going if this ends up being an issue in AshAuthentication. For now we don't really have a good way of knowing where the issue is/why its coming up for you and not others.
is
ash_authentication_phoenix
yours?
running this gives me %Joken.Signer
struct
@jart https://discord.com/channels/711271361523351632/1067733106662047764
I enabled tokens in his app as well just to check if i am missing something but his app gives the same error as well.Are you on windows? Tokens are working for me just fine in my app, I’m just trying to understand what might be different about your setup.
I am using MacOS
Can you push the changes you made to that example app up as a fork?
I will clone it and see if I get the same results
okay let me do that.
GitHub
GitHub - talhaazeemmughal/ash_authentication_phoenix_example: The s...
The simplest password authentication with Ash Framework, Ash Authentication and Phoenix. - GitHub - talhaazeemmughal/ash_authentication_phoenix_example: The simplest password authentication with As...
here is the forked version
Found it 🙂
I don't know why the JWT library gives such a bad error here
This config:
Combined with this:
Is returning
{:ok, signing_secret: "dummy_salt"}
causing us to call Joken.Signer.create(algorithm, signing_secret: "dummy_salt")
The signing_secret fn _, _ ->
callback should be returning {:ok, <string>}
not {:ok, signing_secret: <string>}
If the config was this instead:
Then it would workokay let me check
yes it worked. Thank you so much
It should be adding tokens automatically now, right?
Do you want a token created for every session?
yes
You probably want this config in your tokens section then:
without
store_all_tokens
it only stores confirmation/reset tokens
and with require_token_presence_for_authentication?
it will look up tokens in the tokens table before authenticatingNoted. Thank you @Zach Daniel . I have gotten really interested in it.
I've made a PR to prevent this error in the future by validating the value better.