Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helpful Error from AshAuthentication.Secret secret_for #437

Open
dewetblomerus opened this issue Sep 26, 2023 · 2 comments
Open

Helpful Error from AshAuthentication.Secret secret_for #437

dewetblomerus opened this issue Sep 26, 2023 · 2 comments

Comments

@dewetblomerus
Copy link
Contributor

Trying to set up Auth0 using this guide I got to the login error page, but no errors were raised.

Here is the reason from the AuthController:

reason #=> %AshAuthentication.Errors.MissingSecret{
  resource: Red.Accounts.User,
  changeset: nil,
  query: nil,
  error_context: [],
  vars: [],
  path: [:authentication, :strategies, :auth0, :client_id],
  stacktrace: #Stacktrace<>,
  class: :forbidden
}

Eventually I tried this:

  def secret_for([:authentication, :strategies, :auth0, :redirect_uri], Red.Accounts.User, _) do
    get_config(:redirect_uri)
    |> dbg()
  end

Which showed me this:

get_config(:redirect_uri) #=> :error

Only here did I realize I made the mistake of saving the wrong key in my config file redirect_url

What I think should happen, is that if my secret_for function does not return the correct type, a helpful error is raised, letting me know what I returned.

@jimsynz
Copy link
Collaborator

jimsynz commented Sep 27, 2023

You're absolutely right. Thanks!

@jimsynz
Copy link
Collaborator

jimsynz commented Nov 15, 2023

We need to rearrange this function to validate the return value and return a useful error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants