Protect Routes with Plugs

Learn how to add session management in a Phoenix application

The authentication service integrates with the Phoenix stack to provide infrastructure for session management including plugs that we can use in the router to control access to our routes.

Defining the authentication service

The authentication service is defined in the file pento/lib/pento_web/controllers/user_auth.ex. We could open up the code base, but instead, let’s do a quick review in IEx to see what the public API looks like. Fire up the IEx in the terminal below with iex -S mix, and key this in:

Get hands-on with 1200+ tech skills courses.