Supabase.Auth.Plug (supabase_auth v0.10.0)
View SourceProvides Plug-based authentication support for the Supabase Auth authentication in Elixir applications.
This module offers a series of functions to manage user authentication through HTTP requests in Phoenix applications. It facilitates operations like logging in with a password, logging out users, fetching the current user from a session, and handling route protections based on authentication state.
Configuration
The module requires some options to be passed:
authentication_client: The Supabase client used for authentication.endpoint: Your web app endpoint, used internally for broadcasting user disconnection events.signed_in_path: The route to where socket should be redirected to after authenticationnot_authenticated_path: The route to where socket should be redirect to if user isn't authenticated- use_storage_key_namespacing?: Optionally use the
client.auth.storage_keyto namespace the session keys, for example:"user_token"comes"sb-auth-key_user_token"
Usage
Typically, you need to define a module to be your Plug Authentication entrypoint and use this module to inject the necessary functions that you will use on your MyAppWeb.Router.