AuthPlugOptional (auth_plug v1.2.2)
AuthPlugOptional
handles any route where authentication is optional
e.g. if you're building a CMS where content is public
but seeing comments requires auth, the same page can show different
content depending on if the person has logged in or not.
Please see README.md
for for optional auth usage.
Link to this section Summary
Functions
call/2
is invoked to handle each HTTP request which auth_plug
protects.
If the conn
contains a valid JWT in Authentication Headers, URL or Cookie,
then continue to the optionally protected route,
else redirect to the auth_url
with the referer set as the continuation URL.
NOTE: this plug does NOT set the HTTP Status on a request, that is left to you.
init/1
returns options unmodified
Link to this section Functions
call(conn, options)
call/2
is invoked to handle each HTTP request which auth_plug
protects.
If the conn
contains a valid JWT in Authentication Headers, URL or Cookie,
then continue to the optionally protected route,
else redirect to the auth_url
with the referer set as the continuation URL.
NOTE: this plug does NOT set the HTTP Status on a request, that is left to you.
init(options)
init/1
returns options unmodified