Simple Discourse library including SSO support.
The package can be installed
by adding discourse
to your list of dependencies in mix.exs
:
def deps do
[
{:discourse, "~> 0.0.1"}
]
end
The docs can be found at https://hexdocs.pm/discourse.
Configure :discourse
:
config :discourse,
url: "http://discuss.example.com",
secret: "d836444a9e4084d5b224a60c208dce14"
Handle login request: (based on Phoenix)
defmodule MyAppWeb.UserController do
use MyAppWeb, :controller
alias Discourse.SSO
def login(conn, %{"sso" => sso, "sig" => sig}) do
{:ok, nonce} = SSO.validate(sso, sig)
# User login
user = get_session(conn, :user)
redirect(conn, external: SSO.sign_url(user.id, user.email, nonce))
end
end
Copyright (c) 2018, SQUARE ENIX LTD.
Discourse code is licensed under the MIT License.