Discourse with SSO from Nextcloud

Couldn’t find a guide for this. But what I’d like to do is to “integrate” Discourse as an “app” inside the open source collaborative environment Nextcloud. I believe this is done by opening Discourse - kind of like an iframe - as an “external site” in Nextcloud. These are my steps:

  1. Notice there is some kind of “integration app” for using SSO between Nextcloud/Discourse:
    Discourse SSO - Apps - App Store - Nextcloud

  2. In Nextcloud, go to + Apps -> Integration -> Discourse SSO. Install this, and enable it.

  3. Go to my settings, and enter my SSO information:

  4. I go to my Discourse forum site (which is in Swedish, sorry), and go to my admin settings:


    And scroll down to fill out these 3 fields:

  5. I log out from both Discourse and Nextcloud. Log in to Nextcloud (using the same email at both Nextcloud and Discourse), but cannot successfully open the “external site” to reveal my Discourse forum.

Why does Firefox interpret my forum as being embedded?

Are you sure you’re using the correct endpoint for sso?

Second would be to see if CSP is causing this behaviour (I’m not sure how or why)

I’ve tried disabling SSO, but the subdomain where my forum is located still cannot be opened within Nextcloud. My regular domain name does however open.
By CSP you mean the Cloud Service Provider where my Discourse is at?

From Nextcloud

Your links may or may not work correctly due to the various ways that Web browsers and Web sites handle HTTP and HTTPS URLs, and because the External Sites app embeds external links in IFrames.

Discourse does not work in an <iframe> tag and your Discourse server will refuse the connection.

3 Likes

Thank you! But why then is there a “SSO integration” app, if the integration is impossible? Is there some workaround to allow for Discourse to be embedded as an iframe?

Edit: I created a post at the Nextcloud forum now. Will report back if I get any clarity from there.

Okay, so a user at the Nextcloud forum simply confirms that Discourse seems to be the issue, as it does not work in iframe. A quick google pointed me to this 4 year old Github project though:
https://github.com/BeXcellent/discourse-allowiframe/

After I’ve edited app.yml to account for this plugin, what do I do next? Do I need to rebuild Discourse to fully install it?

Yes, a rebuild will be required to install any plugin

Just as a heads up, a plugin not maintained for over 4 years has a strong chance of breaking.

2 Likes

You can submit issues and feature requests on the project github. Note it hasn’t been updated for version 20 yet. Click for details.

1 Like

Thanks for the tip! You haven’t used this app yourself, have you?

For the record: I installed the “allowifram”-plugin, and my Discourse did indeed crash. :stuck_out_tongue:

For anyone interested, I did ask the developer if there had been an attempt to integrate Discourse into Nextcloud: https://github.com/soudis/discoursesso/issues/18
The developer said no, but that he/she had hacked around the iframe issue with the following plugin: https://github.com/soudis/discourse-allow-same-origin
Have not yet tried it myself.

2 Likes

Sorry for the late response here but I have been exploring nextcloud and discourse integration options recently. You’ve probably figured all this out by now but I’d be interested to compare notes. Are you still using discourse and nextcloud together and if so can you share some more info on what you’re trying to achieve and how it’s working out for you? I’d appreciate it!

Yes, as you have learned, Discourse does not like to be loaded in an iframe. It has always been this way. The workaround is to use Discourse’s own very flexible theming system to add a header that matches your main site. You can also then use nextcloud’s theming system to update it to match, as you see fit. In the nextcloud external sites admin setting, you’ll then select the redirect option meaning the site does not allow embedding. The link to discourse will then open in the same browser tab, without the iframe.

Screen Shot 2021-05-05 at 3.58.30 PM

The Nextcloud discoursesso app you refer to is just about allowing people to authenticate to your discourse site via Nextcloud. Looks like you are setting it up correctly. You just need to go to the URL of your discourse and try to log in, and you will see you are logged in using your nextcloud credentials.

Note that in Discourse, Discourse SSO has been renamed to Discourse Connect. Enabling it will totally replace any other login options in your discourse so you will want to use it carefully.

3 Likes

Any luck with this plugin? :eyes:

I have installed the plugin but I still get “Failed to get Discourse notifications”