Skip to content

Instantly share code, notes, and snippets.

@olivermt
Created August 26, 2015 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olivermt/91c2892e515b7b82f298 to your computer and use it in GitHub Desktop.
Save olivermt/91c2892e515b7b82f298 to your computer and use it in GitHub Desktop.
defmodule RestAuth.RestAuthHandler do
use Behaviour
@doc "Loads a user from the database, will be used by `get_user_roles/1` function and ´get_user_metadata/1` functions"
defcallback load_user(username :: String.t, password :: String.t) :: Any
@doc "Fetches user roles from user object"
defcallback get_user_roles(user :: Any) :: []
@doc "Returns default set of roles, for example `[\"ROLE_USER\"]`."
defcallback get_user_default_roles() :: []
@doc "Fetches any optional metadata you want to store as a map. Can be accessed through `RestAuth.Utility.get_user_metadata`"
defcallback get_user_metadata(user :: Any) :: Map
@doc "The uri to look for that is used for `POST` to login, for example `/api/auth/login`"
defcallback get_login_path() :: String.t
@doc "The uri to look for that is used for `POST` to logout, for example `/api/auth/logout`"
defcallback get_logout_path() :: String.t
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment