I am trying to build a simple auth system in elixir/phoenix that can be used as a dependency in any phoenix application.
I have followed the steps taken in the programming-phoenix-1.4
book and set up a basic auth system easily enough.
In this book they talk about separating a users sensitive and non-sensitive information into different places in the application and database. All the non-sensitive info (username, name, etc) is put in the users
table while the sensitive info (email, password, etc) is put in the credentials
table.
Based on this, I wondered if it would be possible to separate out the auth logic into its own application.
This auth module will need to:
- create a
credentials
table in the database of the requiring application - update said table based on info passed from the parent app
- contain an
auth plug
capable of updating theconn
from the parent application (for example adding:current_user
to theconn
with theassign
function)
Unfortunately I am falling at the first hurdle at the moment. I am not sure if it is possible to require a module that can create a database table.
I imagine that if step 1 is possible step 2 will be straightforward. Step 3 looks like it can be achieved with the Router.forward/4 function.
Guardian
? - Aleksei MatiushkinGuardian
in a "real" project. - RobStallion