{@thread.name}

samoorai
2023-06-02

samoorai:

Hello, I’m trying to setup ash auth with Auth0 I followed the tutorial but I don’t understand how the “/auth” routes are created or how should I create them

dmitriid_dmitriid:

In router.ex :

  • Add use AshAuthentication.Phoenix.Router to the module

  • In whichever scope you use for auth, add the folliwing, e.g.

scope "/", YourAppWeb do
    pipe_through :browser
    
    #... whichever other routes you have ...

    # Ash auth
    sign_in_route()
    sign_out_route AuthController
    auth_routes_for YourApp.Module.Implementing.The.Auth, to: AuthController
    reset_route []
    # End Ash auth
  end

dmitriid_dmitriid:

(it took me a while to wrap my head around, too 🙂 )

samoorai:

Does this work for Auth0 though? Beacuse as far as I understand there should be a “/authorize” and a “/userinfo” as the documentation says https://ash-hq.org/docs/module/ash_authentication/3.10.6/ashauthentication-strategy-auth0

Am I missing something?

dmitriid_dmitriid:

This is the full setup I have: https://gist.github.com/dmitriid/2ae3ae7737c640e9a5de42e79bef1bfb

For

{:ash_authentication, "~> 3.11.1"},
{:ash_authentication_phoenix, "~> 1.7.2"},

I hope this helps.

samoorai:

thanks man

samoorai:

after a little digging I found out that the strategy auth0 create some “magic” routes by itself without needing to specify them in the router so that was the poblem

dmitriid_dmitriid:

No worries 🙂 It took me a while to understand how it’s wired. I think that’s all the modules you need

samoorai:

the documentation is not very clear about that

dmitriid_dmitriid:

Yup, there’s magic 🙂

dmitriid_dmitriid:

If I ever come around this, I should definitely do a PR against the docs

samoorai:

Yes I think a will make one in the future just to be more clear

samoorai:

thank you <@290405540176068618> I think I’m gonna “steal” some of your code ahahaha

samoorai:

🙂

dmitriid_dmitriid:

Of course 🙂