Upgrading to ash_phoenix_authentication 2.10

When upgrading ash_phoenix_authentication to the most recent secure version (2.10), we get this error:

** (EXIT from #PID<0.95.0>) an exception was raised:
    ** (Spark.Error.DslError) authentication -> session_identifier:
  Must set `authentication.session_identifier` to either `:jti` or `:unsafe`,
unless `authentication.tokens.require_token_presence_for_authentication?` is set to `true`.

If you are seeing this error while upgrading ash_authentication, be aware that
updating this setting will log out all of your users.

When set to `:unsafe`, tokens are not revoked when the user logs out.
When set to `:jti`, we use this information to revoke tokens on logout.

We suggest setting `authentication.tokens.require_token_presence_for_authentication?` to `true`
to ensure that tokens are always present during authentication, which makes this option unnecessary.
Changing either of these settings will log out all of your users.

Following the advice, we set:

authentication do
    tokens do
      enabled? true
      token_resource Wink.Accounts.Token
      signing_secret Wink.Secrets
      require_token_presence_for_authentication? true
    end

The app compiles with no error after this change, but when trying to log in we get this error:

> Error returned from: Wink.Accounts.Token.revoke_token

Unknown Error

* ** (Postgrex.Error) ERROR 3F000 (invalid_schema_name) schema "excluded" does not exist

    query: INSERT INTO "tokens" AS t0 ("inserted_at","subject","updated_at","jti","purpose","expires_at","created_at") VALUES ($1,$2,$3,$4,$5,$6,$7) ON CONFLICT ("jti") DO UPDATE SET "subject" = EXCLUDED.identifier('subject'), "purpose" = EXCLUDED.identifier('purpose'), "expires_at" = EXCLUDED.identifier('expires_at'), "updated_at" = COALESCE(EXCLUDED.identifier('updated_at'), $8) RETURNING "updated_at","inserted_at","extra_data","purpose","expires_at","subject","jti","created_at"

This question is basically asking for a pointer :frowning: We’re not sure if this could be Ash, it could be our install, maybe there was a version update along the way or something?

:thinking: are you using ash_sqlite?

Hm…nevermind, that makes no sense, that says Postgrex. Are you using a standard postgres database?

This appears to be an interaction between AshPostgres and the latest release of Ecto. Please hold off on upgrading Ecto.

Actually, turns out you just need to also update ecto_sql :smiley:

1 Like

Perfect! Thank you so much Zach!

1 Like