Skip to content

Instantly share code, notes, and snippets.

@elmuerte
Last active April 20, 2021 20:57
Show Gist options
  • Save elmuerte/48a4b5f659271025cb5a792c9f2fa500 to your computer and use it in GitHub Desktop.
Save elmuerte/48a4b5f659271025cb5a792c9f2fa500 to your computer and use it in GitHub Desktop.
Discourse SAML with Google

Setting up Discourse to perform authentication via Google G-Suite using SAML is quite easy once you figure it out.

Add the discourse-saml plugin to your discourse as documented.

To configure the plugin you need some information from Google G-Suite. In the admin console add a new SAML application and setup a "Custom application". This will show you the information you need. The URL mentioned in SSO URL needs to be used as the DISCOURSE_SAML_TARGET_URL. This is something like https://accounts.google.com/o/saml2/idp?idpid=XXXXX Now you need the certificate information you put in DISCOURSE_SAML_CERT and DISCOURSE_SAML_CERT_FINGERPRINT. This is a bit more tricky. The content for DISCOURSE_SAML_CERT can easily be retrieved from the IDP metadata you can download. It contains a Base64 encoded version of the certificate. Simply copy-paste this as follows:

  DISCOURSE_SAML_CERT: "-----BEGIN CERTIFICATE-----
  base64 content here
  -----END CERTIFICATE-----"

To get the fingerprint you can download the certificate file and inspect it.

I also configured DISCOURSE_SAML_FULL_SCREEN_LOGIN: true. And did not set DISCOURSE_SAML_REQUEST_METHOD: post as it did not work.

To complete the setup in Google G Suite you have to enter the following details. This assumes your discourse site is running at https://discourse.example.org

As customer attribute I also added screenName using Basic Information > Primary Email.

And that's pretty much it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment