Closed iacobson closed 5 years ago
Which options are you trying to configure?
Configuring the user_context
and the token_module
as in the example: https://github.com/riverrun/phauxth-example/blob/master/config/config.exs#L21 would result in something like this
# umbrella_app_1 config
config :phauxth,
user_context: UmbrellaApp1.Accounts,
token_module: UmbrellaApp1.Auth.Token
# umbrella_app_2 config
config :phauxth,
user_context: UmbrellaApp2.Accounts,
token_module: UmbrellaApp2.Auth.Token
Those config options will get overwritten in the umbrella.
The user_context
can already be set as an option (keyword argument) for authenticate, login and confirm.
As for the token_module
, do you want to use different token modules for the different apps? I can add this - I just want to clarify what you want.
For point 1, I was not aware of the user_context
option.
So having something like this
plug Phauxth.Authenticate, user_context: UmbrellaApp1.Accounts
in the router works perfectly!
For point 2, yes, that would be the idea. Having different token modules for different apps. It would be great if you add the option to the library.
Thanks so much! Not sure if I should close the ticket or leave it open for this new feature. So I will leave the decision to you.
Adding token_module
as an option should be fairly straightforward. I will get back to you soon.
Just added token_module
as an option. It's available in version 2.3.0.
There are examples of how to use it in the authenticate/token_test.exs
, confirm/base_test.exs
and remember_test.exs
test files.
Closing this issue now. If you have any questions / comments, just let me know.
Problem
Using the Phauxth library for a Phonix app inside an umbrella. However, there are more Phoenix apps in the umbrella and I would like to use Phauxth for many of them. As the umbrella apps share the configuration, setting the
config :phauxth,
for each of them is not possible.Solution
Would it be a potential solution to provide the configuration through the Plug options? The way it is handled for the
create_session_func
https://github.com/riverrun/phauxth-example/blob/master/lib/forks_the_egg_sample_web/router.ex#L11Or any other way to get the configuration at run time?
Thank you.