riverrun / phauxth

Not actively maintained - Authentication library for Phoenix, and other Plug-based, web applications
409 stars 20 forks source link

What's the best way to have both token and session auth? #45

Closed sotojuan closed 6 years ago

sotojuan commented 6 years ago

This is more of a Phoenix question, but I want both kinds of auth in my app (token for API access, session for the website). Is the correct way to have two SessionController modules?

riverrun commented 6 years ago

One option is to use an umbrella app.

I think there are ways of doing it without setting up an umbrella app, but I haven't tried them :) Using Phauxth.Authenticate with api and sessions is quite easy because you can set up different pipelines in the router.ex file and use Phauxth.Authenticate with the browser pipeline and Phauxth.Authenticate, method: :token with the api pipeline.

If you ask this question on elixirforum.com, I'm sure you will get some informative answers.

sotojuan commented 6 years ago

Thanks. I was able to get some good answers. I'll just have two session controllers.