View Source Gamora (gamora v0.13.0)
Provides an Ueberauth strategy for authenticating with Amco.
setup
Setup
Request to Amco IT an application in Amco for you to use.
Include the provider in your configuration for Ueberauth;
config :ueberauth, Ueberauth,
providers: [
amco: { Gamora, [] }
]
Then include the configuration for Amco:
config :ueberauth, Gamora.OAuth,
client_id: System.get_env("AMCO_CLIENT_ID"),
client_secret: System.get_env("AMCO_CLIENT_SECRET")
If you haven't already, setup routes for your request and callback handler
scope "/auth" do
pipe_through [:browser, :auth]
get "/:provider", AuthController, :request
get "/:provider/callback", AuthController, :callback
end
Create an endpoint for the request and callback where you will handle the
Ueberauth.Auth
struct:
defmodule MyApp.AuthController do
use MyApp.Web, :controller
plug Ueberauth
def callback_phase(%{ assigns: %{ ueberauth_failure: fails } } = conn, _params) do
# do things with the failure
end
def callback_phase(%{ assigns: %{ ueberauth_auth: auth } } = conn, params) do
# do things with the auth
end
end
You can edit the behaviour of the Strategy by including some options when you register your provider.
To set the prompt
:
config :ueberauth, Ueberauth,
providers: [
amco: { Gamora, [prompt: "login"] }
]
To set the default 'scopes' (permissions):
config :ueberauth, Ueberauth,
providers: [
amco: { Gamora, [default_scope: "openid email phone"] }
]
Default is empty ("openid profile email").
Link to this section Summary
Functions
Includes the credentials from the Amco response.
Callback implementation for Ueberauth.Strategy.default_options/0
.
Stores the raw information (including the token) obtained from the Amco callback.
Cleans up the private area of the connection used for passing the raw Amco response around during the callback.
Handles the initial redirect to the amco authentication page.
Fetches the fields to populate the info section of the Ueberauth.Auth
struct.
Fetches the :uid
field from the Amco response.
Link to this section Functions
Includes the credentials from the Amco response.
Callback implementation for Ueberauth.Strategy.default_options/0
.
Stores the raw information (including the token) obtained from the Amco callback.
Cleans up the private area of the connection used for passing the raw Amco response around during the callback.
Handles the initial redirect to the amco authentication page.
To customize the scope (permissions) that are requested by amco include them as part of your url:
"/auth/amco?scope=openid,profile,email,phone"
Fetches the fields to populate the info section of the Ueberauth.Auth
struct.
Fetches the :uid
field from the Amco response.
This defaults to the option :uid_field
which in-turn defaults to :id