Skip to content

Latest commit

 

History

History
57 lines (41 loc) · 1.44 KB

README.md

File metadata and controls

57 lines (41 loc) · 1.44 KB

Discourse

Hex.pm Build Status Coverage Status Hex.pm

Simple Discourse library including SSO support.

Installation

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.

Quick Start

Configure :discourse:

config :discourse,
  url: "http://discuss.example.com",
  secret: "d836444a9e4084d5b224a60c208dce14"

SSO

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 and License

Copyright (c) 2018, SQUARE ENIX LTD.

Discourse code is licensed under the MIT License.