simpers
simpers
AEAsh Elixir
Created by simpers on 6/28/2023 in #support
AshAuthentication error when trying to use password hashing change in seed action
I'm trying to use this action to seed some test accounts:
create :seed do
accept [
:email,
:username,
:first_name,
:last_name,
]

argument :password, :string do
allow_nil? false
sensitive? true
end

change AshAuthentication.Strategy.Password.HashPasswordChange
end
create :seed do
accept [
:email,
:username,
:first_name,
:last_name,
]

argument :password, :string do
allow_nil? false
sensitive? true
end

change AshAuthentication.Strategy.Password.HashPasswordChange
end
This action has no :password_confirmation field as it is just a seed action. However, if I do not include that and the password validation, I get this error:
** (Ash.Error.Framework) Framework Error

Context: resolving data on perform Lpe.User.seed
* Context: resolving data on perform Lpe.User.seed

Assumption failed: Error hashing password.

This should not be possible, please report a detailed bug at:

https://github.com/ash-project/ash/issues/new?assignees=&labels=bug%2C+needs+review&template=bug_report.md&title=

(ash_authentication 3.11.6) lib/ash_authentication/strategies/password/hash_password_change.ex:55: anonymous fn/3 in AshAuthentication.Strategy.Password.HashPasswordChange.change/3
(ash 2.10.2) lib/ash/changeset/changeset.ex:1978: anonymous fn/2 in Ash.Changeset.run_before_actions/1
(elixir 1.15.0) lib/enum.ex:4830: Enumerable.List.reduce/3
(elixir 1.15.0) lib/enum.ex:2564: Enum.reduce_while/3
(ash 2.10.2) lib/ash/changeset/changeset.ex:2063: Ash.Changeset.run_around_actions/2
(ash 2.10.2) lib/ash/changeset/changeset.ex:1735: anonymous fn/2 in Ash.Changeset.with_hooks/3
...
** (Ash.Error.Framework) Framework Error

Context: resolving data on perform Lpe.User.seed
* Context: resolving data on perform Lpe.User.seed

Assumption failed: Error hashing password.

This should not be possible, please report a detailed bug at:

https://github.com/ash-project/ash/issues/new?assignees=&labels=bug%2C+needs+review&template=bug_report.md&title=

(ash_authentication 3.11.6) lib/ash_authentication/strategies/password/hash_password_change.ex:55: anonymous fn/3 in AshAuthentication.Strategy.Password.HashPasswordChange.change/3
(ash 2.10.2) lib/ash/changeset/changeset.ex:1978: anonymous fn/2 in Ash.Changeset.run_before_actions/1
(elixir 1.15.0) lib/enum.ex:4830: Enumerable.List.reduce/3
(elixir 1.15.0) lib/enum.ex:2564: Enum.reduce_while/3
(ash 2.10.2) lib/ash/changeset/changeset.ex:2063: Ash.Changeset.run_around_actions/2
(ash 2.10.2) lib/ash/changeset/changeset.ex:1735: anonymous fn/2 in Ash.Changeset.with_hooks/3
...
If I add
argument :password_confirmation, :string do
allow_nil? false
sensitive? true
end

validate AshAuthentication.Strategy.Password.PasswordConfirmationValidation
argument :password_confirmation, :string do
allow_nil? false
sensitive? true
end

validate AshAuthentication.Strategy.Password.PasswordConfirmationValidation
to the seed action, the error instead becomes:
** (Ash.Error.Framework) Framework Error

* Assumption failed: Action does not correlate with an authentication strategy

This should not be possible, please report a detailed bug at:

https://github.com/ash-project/ash/issues/new?assignees=&labels=bug%2C+needs+review&template=bug_report.md&title=

(ash 2.10.2) lib/ash/api/api.ex:2123: Ash.Api.unwrap_or_raise!/3
(lpe 0.1.0-81ecaa1) priv/repo/seeds/dev_data_seed.ex:20: LpePriv.Seeds.DevDataSeed.seed/0
priv/repo/seeds.exs:19: (file)
(elixir 1.15.0) lib/code.ex:1432: Code.require_file/2
...
** (Ash.Error.Framework) Framework Error

* Assumption failed: Action does not correlate with an authentication strategy

This should not be possible, please report a detailed bug at:

https://github.com/ash-project/ash/issues/new?assignees=&labels=bug%2C+needs+review&template=bug_report.md&title=

(ash 2.10.2) lib/ash/api/api.ex:2123: Ash.Api.unwrap_or_raise!/3
(lpe 0.1.0-81ecaa1) priv/repo/seeds/dev_data_seed.ex:20: LpePriv.Seeds.DevDataSeed.seed/0
priv/repo/seeds.exs:19: (file)
(elixir 1.15.0) lib/code.ex:1432: Code.require_file/2
...
3 replies
AEAsh Elixir
Created by simpers on 6/2/2023 in #support
Authentication.Plug - What to do as an API? I use Phoenix, but not with views. What is provided?
As I'm exploring and trying to setup AshAuthentication I ended up using use AshAuthentication.Plug for a plug, thinking this would provide the same set of routes as the Phoenix view version would, but it doesn't seem like it. I'm not even sure, as the docs aren't clear on this and I'm at this point digging in the code itself. Do I have to implement my own plug and controller(s) for this? I have an Angular frontend, and will maybe consume the same API from native apps later on. And also, does this mean that some features aren't available unless I use Phoenix?
130 replies