TechnoMage
AEAsh Elixir
•Created by TechnoMage on 6/20/2023 in #support
Authentication failures
I am trying to debug authentication failures in a multi-node setup (load balanced not Elixir multi-node).
I get session data written: "user" => "user?id=6a6ece18-0ede-4b81-a22a-73edc43db6a8" implying the authentication was sucessful, but the failure callback is being invoked in the auth controller. I presume this may be related to the web socket possibly happening before the session data is recorded from the live session? Any pointers on how to debug welcome.
5 replies
AEAsh Elixir
•Created by TechnoMage on 5/24/2023 in #support
Setting Actor from Ash.Authentication
Is the actor automatically set or must I do that in my live session on_mount?
8 replies
AEAsh Elixir
•Created by TechnoMage on 5/23/2023 in #support
Bulk Delete/Truncate
What is the best way to delete all resources that pass a filter, or in some cases truncate a table to ensure it is empty. This is mostly for admin type functions to reset after some issue with normal operation where the data can be reloaded afterwards.
3 replies
AEAsh Elixir
•Created by TechnoMage on 5/21/2023 in #support
Custom validation example
It would be very helpful to have an example validation in the docs for custom validations. I am getting hung up creating an error that implements the form error protocol. The following generates an error but is then stripped out before rending the form.
error = Ash.Error.to_ash_error("Domain or company is required")
15 replies
AEAsh Elixir
•Created by TechnoMage on 5/19/2023 in #support
Authentication crashing
I had authentication working, and introduced some bad data in my DB and it is now crashing. The data is in a table not the user table, so I am not sure why it is blowing up when associating a user with a subject. It looks like Ash.Authentication is keeping in the mix after authentication has completed but the view has not yet rendered and is eating the error. Still investigating on my end of course.
[info] GET /admin/companies
[debug] Processing with TacitRedOTPWeb.CompanyLive.Index.index/2
Parameters: %{}
Pipelines: [:browser]
[info] Sent 500 in 2ms
[debug] Converted error :function_clause to 500 response
[error] #PID<0.1561.0> running Phoenix.Endpoint.SyncCodeReloadPlug (connection #PID<0.1159.0>, stream id 7) terminated
Server: localhost:4000 (http)
Request: GET /admin/companies
(exit) an exception was raised:
(FunctionClauseError) no function clause matching in AshAuthentication.subject_to_user/3
(ash_authentication 3.11.1) lib/ash_authentication.ex:208: AshAuthentication.subject_to_user(#TacitRedOTP.Auth.User<account: #Ash.NotLoaded<:relationship>, meta: #Ecto.Schema.Metadata<:loaded, "users">, id: "bd78bc20-1193-49e7-9cc0-e94fc010bea0", inserted_at: ~U[2023-05-19 15:04:51.743133Z], updated_at: ~U[2023-05-19 15:04:51.743133Z], email: #Ash.CiString<"[email protected]">, active: true, lock_version: 1, account_id: "d7d6ee62-4422-4668-8fbe-c80a880b26cf", aggregates: %{}, calculations: %{}, order: nil, ...>, TacitRedOTP.Auth.User, [tenant: nil])
(ash_authentication_phoenix 1.7.2) lib/ash_authentication_phoenix/live_session.ex💯 anonymous fn/4 in AshAuthentication.Phoenix.LiveSession.on_mount/4
(stdlib 4.3) maps.erl:411: :maps.fold_1/3
(ash_authentication_phoenix 1.7.2) lib/ash_authentication_phoenix/live_session.ex:97:
25 replies
AEAsh Elixir
•Created by TechnoMage on 5/18/2023 in #support
Authentication debug help
Is there a way to watch the traffic to/from the OAuth2 provider? All I see in the browser network tab is XHR traffic and none that appers to be auth related. The error I am getting is "unknown client" which could be the client_id is not getting sent correctly (config probably on my part), or something else is wrong like the endpoint I am using for authorize_url.
8 replies
AEAsh Elixir
•Created by TechnoMage on 5/17/2023 in #support
Trouble with setting up Ash.Authentication
I am getting the following compile error and have no clue what it means. "Module" does not appear in my files. I have attempted to follow the various guides to setup google to use OAuth2.
(EXIT from #PID<0.95.0>) an exception was raised:
(Spark.Error.DslError) [nil]
authentication -> api:
Module is not an Ash.Api.
The resource is:
7 replies
AEAsh Elixir
•Created by TechnoMage on 5/13/2023 in #support
Manage relationship argument question
I do not see an argument type for changes when providing a list of target IDs and I want manage_relationship to just add/remove relationships between existing resources (many-to-many). I will try map with just id populated, but that seems redundant.
6 replies
AEAsh Elixir
•Created by TechnoMage on 5/10/2023 in #support
Use of managed_relationship not clear
I am trying to create an action that will create a Supplier and populate the 2 belongs_to relationships it has. I have tried a default create action with the id fields populated, but they do not get set. I have tried manage_relationship with both ids as action arguments and with records as arguments.
The most recent attempt: create :new do argument :company, :uuid do allow_nil? false end argument :account, :uuid do allow_nil? false end change manage_relationship(:company, type: :append_and_remove) change manage_relationship(:account, type: :append_and_remove) end
The most recent attempt: create :new do argument :company, :uuid do allow_nil? false end argument :account, :uuid do allow_nil? false end change manage_relationship(:company, type: :append_and_remove) change manage_relationship(:account, type: :append_and_remove) end
4 replies
AEAsh Elixir
•Created by TechnoMage on 5/9/2023 in #support
AshPhoenix form handling
Question about Ash Phoenix forms. When using ecto and assign_form the names in the form are user[active] for the active field of user schema. For AshPhoenix forms with assign(:form, form) the names are form[active] so it does not know the resource type when building the form. Is there another way to deal with this so the forms do have the resource name in the element names, or do I just need to change the js that was using the old names? This also impacts the LiveView tests using the form helper
3 replies