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

Policies validation #69

Open
dcdourado opened this issue Jul 23, 2021 · 1 comment
Open

Policies validation #69

dcdourado opened this issue Jul 23, 2021 · 1 comment

Comments

@dcdourado
Copy link
Collaborator

dcdourado commented Jul 23, 2021

I was reading the policies on authorizer app and something came into my mind when I read the validation part. Shouldn't we catch all on validation failure? I mean, when the first function clause doesn't match.

  def validate(%Conn{private: %{session: session}} = context) when is_map(session) do
    case session do
      %{subject_id: id, subject_type: type} when is_binary(id) and type in @subject_types ->
        Logger.debug("Policity #{__MODULE__} validated with success")
        {:ok, context}

      _any ->
        Logger.error("Policy #{__MODULE__} failed on validation because session is invalid")
        {:error, :unauthorized}
    end
  end

  def validate(%Conn{private: %{session: _}}) do
    Logger.error("Policy #{__MODULE__} failed on validation because session was not found")
    {:error, :unauthorized}
  end

The difference is that it returns a 50x instead of 403 because the process dies (right?)

@lcpojr
Copy link
Owner

lcpojr commented Aug 1, 2021

I don't get it.
Could please give me an example of how would you do it?

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