shinyscorpion / discourse

Simple Discourse library including SSO support.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Simple Discourse library including SSO support.

License:MIT License


Languages

Language:Elixir 100.0%