cassette_plug v1.1.0 Cassette.Plug.DefaultHandler

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

Summary

Functions

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

Functions

init(options)

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

invalid_authentication(conn, options)

Renders a Forbidden response

service(conn, options)

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

unauthenticated(conn, options)

Redirects the user to the cas login page with the service computed by service/2

url(conn, options)

Specs

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.

user_authenticated(conn, user, options)

Stores the current user in the session under the cas_user key

user_or_token(conn, options)

Get the current user from session and the ticket from the query string