ueberauth / guardian

Elixir Authentication
MIT License
3.44k stars 381 forks source link

Using a function to fetch the secret fails in runtime #400

Closed drowzy closed 7 years ago

drowzy commented 7 years ago

Im using this approach to fetch the secret key:

config :my_app, MyApp.Guardian,
  allowed_algos: ["RS512"],
  secret_key: {MySecretKey, :fetch}

In v1.0.0-beta1 this does not work and fails with:

(FunctionClauseError) no function clause matching in :jose_jwk.from/1
        (jose) src/jose_jwk.erl:134: :jose_jwk.from({MySecretKey, :fetch})

However if a supply an argument to the fetch function it works

 secret_key: {MySecretKey, :fetch, []}

Expected: Should be possible to provide a function which takes no arguments to resolve the secret key.

doomspork commented 7 years ago

Howdy @drowzy! Thanks for the report but this is functioning as intended.

This was discussed quite a bit when we were working on v1 (see discussion here: https://github.com/ueberauth/guardian/pull/377#discussion_r135806789) and the decision was made to remove {MySecretKey, :fetch} since {{MySecretKey, :fetch, []} accomplishes the same goal while reducing the amount of code to maintain.