cassette_plug v1.1.6 Cassette.Plug.DefaultHandler View Source
Default implementation of the Cassette.Plug.AuthenticationHandler
behaviour
Assumptions for this module:
- An already authenticated user is stored in session in the
cas_user
key - The ticket is provided by a query string parameter called
ticket
- The service is the current request url
- When not authenticated the user will be directed to the CAS server using the current url for the
service
- If the ticket is invalid or expired the user will be presented with a simple “Forbidden” response
Link to this section Summary
Functions
Initializes this handler with the given options
Renders a Forbidden response
Builds the current request url to be used as the CAS service
Redirects the user to the cas login page with the service computed by service/2
Computes the service from the URL requested in the conn
argument.
It will remove the ticket
from the query string paramaters since the ticket has not been generated with it
Stores the current user in the session under the cas_user
key
Get the current user from session and the ticket from the query string
Link to this section Functions
Initializes this handler with the given options.
They will be forwarded to the other functions.
Callback implementation for Cassette.Plug.AuthenticationHandler.init/1
.
invalid_authentication(conn :: Plug.Conn.t(), options :: term()) :: Plug.Conn.t()
Renders a Forbidden response
service(conn :: Plug.Conn.t(), options :: term()) :: String.t()
Builds the current request url to be used as the CAS service
unauthenticated(conn :: Plug.Conn.t(), options :: term()) :: Plug.Conn.t()
Redirects the user to the cas login page with the service computed by service/2
Computes the service from the URL requested in the conn
argument.
It will remove the ticket
from the query string paramaters since the ticket has not been generated with it.
user_authenticated(conn :: Plug.Conn.t(), user :: Cassette.User.t(), options :: term()) :: Plug.Conn.t()
Stores the current user in the session under the cas_user
key
user_or_token(conn :: Plug.Conn.t(), options :: term()) :: {Cassette.User.t() | nil, {:ok, String.t()} | :error}
Get the current user from session and the ticket from the query string