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

Link to this function init(options) View Source
init(args :: term()) :: term()

Initializes this handler with the given options.

They will be forwarded to the other functions.

Callback implementation for Cassette.Plug.AuthenticationHandler.init/1.

Link to this function invalid_authentication(conn, options) View Source
invalid_authentication(conn :: Plug.Conn.t(), options :: term()) :: Plug.Conn.t()

Renders a Forbidden response

Link to this function service(conn, options) View Source
service(conn :: Plug.Conn.t(), options :: term()) :: String.t()

Builds the current request url to be used as the CAS service

Link to this function unauthenticated(conn, options) View Source
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

Link to this function url(conn, options) View Source
url(Plug.Conn.t(), term()) :: String.t()

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.

Link to this function user_authenticated(conn, user, options) View Source
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

Link to this function user_or_token(conn, options) View Source
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