Giter Site home page Giter Site logo

Comments (8)

riverrun avatar riverrun commented on June 2, 2024 1

Glad to hear it's now fixed. I will close this issue now. I have made a few changes to the UPGRADE guide to make things a little clearer.

from phauxth.

riverrun avatar riverrun commented on June 2, 2024

Version 2.1 of Phauxth is now using version 5 of Comeonin, and the main change, as far as Phauxth is concerned, is that Comeonin is now not called directly.

The changes you will need to make are:

  • change Comeonin.Argon2 in the config file to Argon2
  • change Comeonin.Argon2.add_hash to Argon2.add_hash

I added a note about this to the Gitter channel and updated the UPGRADE_v2 guide, but it's not always easy to let everyone know when there is a change.

from phauxth.

dsignr avatar dsignr commented on June 2, 2024

Thanks David, I missed that. Probably because I was already on 2.0.0 so, must have totally missed it.
Ok, I fixed as you have mentioned and now I'm being hit with this:

Request: POST /api/core
** (exit) an exception was raised:
    ** (FunctionClauseError) no function clause matching in MyAppWeb.Auth.Login.report/2
        (myapp) lib/myapp_web/auth/login.ex:7: MyAppWeb.Auth.Login.report(:ok, [])

Inside my auth/login.ex:

defmodule MyAppWeb.Auth.Login do
  @moduledoc """
  Custom login module that checks if the user is confirmed before
  allowing the user to log in.
  """

  use Phauxth.Login.Base

  alias Comeonin.Argon2
  alias MyApp.IAM

  @impl true
  def authenticate(%{"password" => password} = params, _, opts) do
    case IAM.get_by(params) do
      nil -> {:error, "no user found"}
      %{confirmed_at: nil} -> {:error, "account unconfirmed"}
      user -> Argon2.check_pass(user, password, opts)
    end
  end
end

Seems like a struct mismatch within the report function. I can probably override it, but not sure it is a bug..

from phauxth.

dsignr avatar dsignr commented on June 2, 2024

Ok, I found out the issue. In this callback:

@impl true
 def authenticate(%{"password" => password} = params, _, opts) do
    case IAM.get_by(params) do
      nil -> {:error, "no user found"}
      %{confirmed_at: nil} -> {:error, "account unconfirmed"}
      user -> Argon2.check_pass(user, password, opts)
   end
end 

The success case returns just :ok, instead of the tuple {:ok, user} that the report function is expecting.

@impl true
 def authenticate(%{"password" => password} = params, _, opts) do
    case IAM.get_by(params) do
      nil -> {:error, "no user found"}
      %{confirmed_at: nil} -> {:error, "account unconfirmed"}
      user -> {Argon2.check_pass(user, password, opts), user} # <---  Changing it to this solved it
   end
end

Since it's a callback implementation, I don't think it's a bug per se, but then again, I'm upgrading from Phauxth 2.0.0 to 2.1.0, so my implementation hasn't changed, but seems like, as you have mentioned, the Argon function has changed.

from phauxth.

riverrun avatar riverrun commented on June 2, 2024

You need to remove the alias Comeonin.Argon2 line

from phauxth.

riverrun avatar riverrun commented on June 2, 2024

This commit shows the changes that I made to the example app to upgrade it to 2.1

from phauxth.

dsignr avatar dsignr commented on June 2, 2024

You need to remove the alias Comeonin.Argon2 line

That was it! I can confirm this was the issue. Thanks David. Should I close this issue now?

from phauxth.

dsignr avatar dsignr commented on June 2, 2024

Thank you David!

from phauxth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.