SSO from Wordpress for Two Different Discourse Sites

(Matt) #1

I have SSO set up for my multi-site Wordpress via the plugin and @AdamCapriola’s helper class.

I want to have SSO work for two separate Discourse sites from one Wordpress site. Is this possible?

The Discourse sites are hosted on two separate digital ocean droplets.

Thank you!

(Kane York) #2

Yup, perfectly possible! Just point them to the same SSO endpoint.

(Matt) #3

Thanks but when I do just that I get an error for the second Discourse site. The first Discourse site is entered into @AdamCapriola’s helper class on line 14 as with the corresponding SSO secret on line 13.

When I try to log in to the second Discourse site which has a url of: I get an error saying “Timeout expired” but the url is going to the first discourse site with this in the browser:

Here is the helper class:

(Kane York) #4

Okay, so you’ll have to determine discourse_url from the Referer headers. And you could do that for sso_secret too, or just keep them the same.

(Matt) #5

Thank you. I just don’t know quite how to do that. Is it one of the methods described here
Thanks for you help!

(Steven Greco) #6

I would guess the easiest way would be to create a separate template for the second discourse site.

(Kane York) #7

Hah, didn’t consider that. Yeah that would be easier heh :slight_smile:

(Matt) #8

Thanks @Grex315. Could you help me understand how to add an include statement to the template file itself for the helper class as you mentioned below? I just have the helper class added to my function.php file. Thank you!

(Matt) #9

Would it be:

<?php include 'page_discourse-sso.php';?> add to the template.php file somewhere?

Then I would duplicate the page_discourse-sso.php file and call it page_discourse-sso2.php

And add <?php include 'page_discourse-sso2.php';?> to the template.php file.

(Kane York) #10

Here’s a cleaner implementation.

$sso_secret = '1234567890';
$discourse_url = '';

include 'sso-common.php';

$sso_secret = '0987654321';
$discourse_url = '';

include 'sso-common.php';

(Steven Greco) #11

yup. the way Kane has it is the way I set mine up. I try and stay away from editing the functions.php file. Just put the include statement right into the wordpress page template for Armed guy’s sso helper class.

(Matt) #12

Thank you that really helped and it is working for me. I’m have one other related error however.
When the user logs in to Wordpress and then goes to the discourse forum and clicks login the user is logged in perfectly.

####However if the user visits the Discourse site first and then click login they are taken to the Wordpress login page as expect but an Invalid Request error is given after attempting to login. This is the resulting url:;sig=5baef3f02735f089349739292201d12cb3ddf704723091bf0848e456869254ef

Any ideas?

Thank you!