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

First call to postgres store fails #4

Closed
dfalling opened this issue Feb 25, 2020 · 7 comments
Closed

First call to postgres store fails #4

dfalling opened this issue Feb 25, 2020 · 7 comments

Comments

@dfalling
Copy link
Contributor

I think this may be related to #2.

The first time I try use pow_postgres_store to refresh a session cookie, it fails, without even reading my persistent session cookies. Subsequent calls work great. I'm hoping this is somehow related to Pow displaying the deprecation warning in #2 on the first call but not subsequent calls.

@narrowtux
Copy link
Contributor

Do you have the error message that's thrown?

@dfalling
Copy link
Contributor Author

The error message is the deprecation warning in #2:

warning: binary key for backend stores is depecated, update `Elixir.Pow.Postgres.Store` to accept erlang terms instead
  (pow) lib/pow/store/base.ex:140: Pow.Store.Base.backwards_compatible_call/3
  (pow) lib/extensions/persistent_session/plug/cookie.ex:197: PowPersistentSession.Plug.Cookie.do_authenticate/3
  (pow) lib/extensions/persistent_session/plug/cookie.ex:65: PowPersistentSession.Plug.Cookie.call/2

My app doesn't appear to read any of the persistent session cookies, but I do see the pow_postgres_store database queries being fired. My app then fails the request, responding with 401. Subsequent requests do read my cookies before making the database call.

@nduitz
Copy link

nduitz commented Mar 10, 2020

Hey there.
I am experiencing the same issue I guess.

The first time I try to login I get this:

function Pow.Postgres.Store.keys/1 is undefined or private

this code is called:

  # TODO: Remove by 1.1.0

  defp binary_key_all(store, [backend_config, match_spec]) do
    match_spec = :ets.match_spec_compile([{match_spec, [], [:"$_"]}])

    backend_config
    |> store.keys()
    |> Enum.map(&:erlang.binary_to_term/1)
    |> :ets.match_spec_run(match_spec)
    |> Enum.map(&{&1, binary_key_get(store, [backend_config, &1])})
  end

@nduitz
Copy link

nduitz commented Mar 11, 2020

I looked into it and opened an issue in the pow repo: pow-auth/pow#451
The attached MR should fix that issue.

@danschultzer
Copy link

danschultzer commented Mar 12, 2020

FYI it has been fixed upstream. Next Pow release (v1.0.19) will resolve it. I'm very sure this only happens when you use dynamic code reloading (e.g. starts mix phx.server) instead of running it as e.g. release where it's statically compiled.

@alecho
Copy link
Contributor

alecho commented Apr 3, 2020

Confirming Pow 1.0.19 resolves this.

@narrowtux
Copy link
Contributor

Thanks for confirming this, I'll close this then.

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

5 participants