Überauth Auth0
Auth0 OAuth2 strategy for Überauth.
Installation
-
Set up your Auth0 application at Auth0 dashboard.
-
Add
:ueberauth_auth0to your list of dependencies inmix.exs:def deps do[{:ueberauth_auth0, "~> 2.0"}]end -
Ensure
ueberauth_auth0is started before your application:def application do[applications: [:ueberauth_auth0]]end -
Add Auth0 to your Überauth configuration:
config :ueberauth, Ueberauth,providers: [auth0: {Ueberauth.Strategy.Auth0, []}],# If you wish to customize the OAuth serializer,# add the line below. Defaults to Jason.json_library: Poisonor with per-app config:
config :my_app, Ueberauth,providers: [auth0: {Ueberauth.Strategy.Auth0, [otp_app: :my_app]}] -
Update your provider configuration:
config :ueberauth, Ueberauth.Strategy.Auth0.OAuth,domain: System.get_env("AUTH0_DOMAIN"),client_id: System.get_env("AUTH0_CLIENT_ID"),client_secret: System.get_env("AUTH0_CLIENT_SECRET")or with per-app config:
config :my_app, Ueberauth.Strategy.Auth0.OAuth,domain: System.get_env("AUTH0_DOMAIN"),client_id: System.get_env("AUTH0_CLIENT_ID"),client_secret: System.get_env("AUTH0_CLIENT_SECRET")See the
Ueberauth.Strategy.Auth0module docs for more configuration options. -
Include the Überauth plug in your controller:
defmodule MyApp.AuthController douse MyApp.Web, :controllerplug Ueberauth...endor with per-app config:
defmodule MyApp.AuthController douse MyApp.Web, :controllerplug Ueberauth, otp_app: :my_app...end -
Create the request and callback routes if you haven't already:
scope "/auth", MyApp dopipe_through :browserget "/:provider", AuthController, :requestget "/:provider/callback", AuthController, :callbackend -
You controller needs to implement callbacks to deal with Ueberauth.Auth and Ueberauth.Failure responses.
For an example implementation see the Überauth Example application.
Copyright and License
Copyright (c) 2015 Son Tran-Nguyen
Copyright (c) 2020 Klemen Sever
This library is released under the MIT License. See the LICENSE.md file for further details.