Ash_authentication: optionality of token

The Ash authentication getting started guide indicates that (in the example setup code) the Token is optional:

You can skip this step if you don’t want to use tokens, in which case remove the tokens DSL section in the user resource below.

However, I tried to follow the “tokens optional” instructions, but couldn’t get past this Spark DSL error (Panic is the app name):

ben@_ panic % mix compile
Compiling 28 files (.ex)
** (EXIT from #PID<0.98.0>) an exception was raised:
    ** (WithClauseError) no with clause matching: :error
        (ash_authentication 4.0.0-rc.6) lib/ash_authentication/verifier.ex:51: anonymous fn/1 in AshAuthentication.Verifier.validate_token_resource/1
        lib/panic/accounts/user.ex:1: anonymous fn/1 in Panic.Accounts.User.__verify_spark_dsl__/1
        (elixir 1.16.2) lib/enum.ex:987: Enum."-each/2-lists^foreach/1-0-"/2
        lib/panic/accounts/user.ex:1: Panic.Accounts.User.__verify_spark_dsl__/1
        (elixir 1.16.2) lib/enum.ex:987: Enum."-each/2-lists^foreach/1-0-"/2
        (elixir 1.16.2) lib/module/parallel_checker.ex:271: Module.ParallelChecker.check_module/3
        (elixir 1.16.2) lib/module/parallel_checker.ex:82: anonymous fn/6 in Module.ParallelChecker.spawn/4

After adding the Token stuff (from the same page) it compiled no worries.

Is the Token stuff actually optional and I just did it wrong (can send more code if it’s helpful, but I just copy-pasted the example code from the docs)? If not, it might be worth updating the docs.

my setup

fwiw, I’m on the very bleeding edge for everything (ash 3.0.0-rc.45, ash_authentication 4.0.0-rc.6) and I’m also using AshSqlite instead of AshPostgres. So I’m off the beaten path a bit (but still doing things that the docs seem to suggest should be supported).

Anyway, I’m not blocked (I just added the token resource) but wanted to raise the issue in case the docs need tweaking (I know that that’s part of the focus for Ash v3).

Keep up the good work :slight_smile:

I can’t help you directly but this sounds like a good candidate for an issue in the AshAuthentication repo.

The team is hard at work updating the documentation for the release so it may already be on their radar, but won’t hurt to post there.

2 Likes

Done, thanks.

Yeah I need to update the docs (which I’m working on at the moment) because tokens are no longer optional because sign-in-tokens are enabled by default for password authentication.

1 Like

Ah, great, thanks @jimsynz

@jimsynz they are optional as long as you turn off sign in tokens though right?

Hrm :thinking: I guess it should be. I just made it non-optional, but I’ll go back and make it more nuanced.

1 Like

Done in 4.0.0-rc.7

1 Like

thanks @jimsynz