Git Product home page Git Product logo

discoursesso's Introduction

Discourse SSO

Easy, configurable Discourse SSO: GET api/auth/login -> recieve a JWT with user data. Allows using Discord as your SSO provider to authenticate users into your own websites.

Based on the official implementation, written in ASP.NET Core, but you needn't touch the code, everything is setup using configuration. This means you can use this regardless of your tech stack.

Using this will allow you to share your discourse userbase with your websites!

Usage

  1. Build the project for your target OS (probably ubuntu)
  2. Add your configuration to appsettings.json
  3. In your Discourse app, go to settings -> login -> and set enable sso provider to true, also enter the sso secret
  4. That's it! Perform GET api/auth/login to get a JWT contining user data! (the user will be prompted to log in if not already logged in)

Ideally your JS client would make that request then store the JWT and use it in the authorization header when querying your APIs, once the JWT experies it would make that request again to get another JWT and so on.

Configuration

The configuration is located in the file appsettings.json, resembling:

{
  "DiscourseSso": {
    "SsoSecret": "Xmp4wB6aMULmujXd", // sso secret you setup in Discourse settings
    "DiscourseRootUrl": "http://community.example.com" // your discourse site URL without the trailing backslash at end
  },
  "Jwt": {
    "SecretKey": "Xmp4wB6aMULmujXd", // key used to sign the JWT (the one your APIs will use to validate it)
    "Issuer": "DiscourseSso", // "iss" claim in JWT
    "Expiry": "", // "exp" claim in JWT, if empty will default to 30 days
    "Audience": "DefaultAud" // "aud" claim in JWT
  }
}

Token

The JWT that you'll receive will look like this:

{
  "sub": "1",
  "iss": "DiscourseSso",
  "iat": 1485393544,
  "exp": 1487985544,
  "aud": "DefaultAud",
  "name": "UserName+LastName",
  "username": "user",
  "email": "[email protected]",
  "external_id": "1",
  "admin": "true",
  "moderator": "false"
}

The sub claim is equivalent to external_id.

discoursesso's People

Contributors

biarity avatar amanvell avatar

Watchers

veblock avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.