ueberauth / guardian

Elixir Authentication
MIT License
3.43k stars 382 forks source link

Override cookie defaults in remember_me with values from module config #570

Closed sparta-developers closed 5 years ago

sparta-developers commented 5 years ago

We found that when we attempt to set the max_age in our Guardian module's config, this value would not override the default cookie_options in Guardian.Plug.remember_me. This is because the options list is concatenated (defaults last) and eventually Phoenix uses :maps.from_list/1 which prefers the right most value. This PR should fix the issue.

Example config:

config :my_app, MyApp.Guardian,
  issuer: "MyApp",
  secret_key: "...",
  permissions: %{
    default: [:read_users, :write_users]
  },
  cookie_options: [max_age: 100]
yordis commented 5 years ago

@sparta-developers hey, would you mind to fix the issues from the Travis? You need to run mix format

codecov-io commented 5 years ago

Codecov Report

Merging #570 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #570   +/-   ##
=======================================
  Coverage   85.57%   85.57%           
=======================================
  Files          18       18           
  Lines         423      423           
=======================================
  Hits          362      362           
  Misses         61       61
Impacted Files Coverage Δ
lib/guardian/plug.ex 83.78% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 8930f7b...d625c7d. Read the comment docs.

sparta-developers commented 5 years ago

@yordis fixed. Thanks