Active Directory Ueberauth strategy using Exldap.
Add ueberauth_active_directory to your list of dependencies in mix.exs
:
def deps do
[{:ueberauth_active_directory, "~> 0.1"}]
end
Ensure ueberauth_active_directory is started before your application:
def application do
[applications: [:ueberauth_active_directory]]
end
Run mix deps.get
Add AD server information to <mix env>.secret.exs
Config Value | Usage |
---|---|
server | Your Active Directory server address |
base | Base distingushed name for your domain. e.g. lab.local would be DC=lab,DC=local |
port | Ldap listening port |
ssl | Enable SSL |
user_dn | Bind account username in distinguishedName format |
password | Bind account password |
# config/dev.secret.exs
config :ueberauth, Ueberauth.Strategy.ActiveDirectory.Ldap,
server: "192.168.250.2",
base: "DC=lab,DC=local",
port: 389,
ssl: false,
user_dn: "CN=vagrant,CN=Users,DC=lab,DC=local",
password: "vagrant"
Configure Ueberauth to use the strategy
# config/dev.exs
config :ueberauth, Ueberauth,
providers: [
active_directory: { Ueberauth.Strategy.ActiveDirectory, [] },
]
Configure authentication routes
scope "/auth", MyApp do
pipe_through :browser
get "/:provider", AuthController, :request
get "/:provider/callback", AuthController, :callback
end
Include Überauth plug in your controller
defmodule MyApp.AuthController do
use MyApp.Web, :controller
plug Ueberauth
...
end
Tests require an AD environment to run. The vagrantfile included in the repo will take care of setting up the environment for you.
- Clone the repo
cd ueberauth_active_directory
- Run
vagrant up
- Run
mix test