SupabaseSurface.Plugs.Session (supabase_surface v0.4.0)

A plug to handle access and refresh tokens.

In case access_token and refresh_token are not available in the session, it redirects to a login_endpoint.

If the session already contains those tokens, it checks the expiration time of the access token. In case the token is already expired or expires in less than the (optionally provided) expiry_tolerance, it tries to refresh it.

Options

  • :login_endpoint - a endpoint to redirect to in case of invalid tokens (default: "/login")
  • :expiry_tolerance - time in seconds the access_token still has to be valid, otherwise it should be refreshed (default: 60)

Examples

plug SupabaseSurface.Plugs.Session, login_endpoint: "/auth", expiry_tolerance: 120

Link to this section Summary

Link to this section Functions

Link to this function

call(conn, map)

Link to this function

init(options \\ [])