# Codice di esempio su come una soluzione ospitata si integrerebbe con Discourse

**URL:** https://meta.discourse.org/t/example-code-for-how-a-hosted-solution-would-integrate-with-discourse/139424
**Category:** SSO
**Created:** [22 Gennaio 2020, 2:33pm UTC](https://meta.discourse.org/t/example-code-for-how-a-hosted-solution-would-integrate-with-discourse/139424 "2020-01-22T14:33:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rubydoob](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rubydoob/32/103165_2.png) [@rubydoob](https://meta.discourse.org/u/rubydoob)
#### Post date: [22 Gennaio 2020, 2:33pm UTC](https://meta.discourse.org/t/example-code-for-how-a-hosted-solution-would-integrate-with-discourse/139424/1 "2020-01-22T14:33:13Z")

</div>

Ci sono soluzioni hosted che consentono l’integrazione con Discourse.

Esiste del codice di esempio che mostri cosa dovrebbe fare una soluzione hosted per integrarsi con il sistema di login di Discourse?

Ad esempio, Patreon ha un plugin che permette agli utenti Patreon di accedere a Discourse. Sto cercando del codice di esempio che mostri cosa dovrebbe fare una soluzione hosted come Patreon dalla propria parte per consentire questo tipo di integrazione.

Potrei aver usato la terminologia sbagliata, ma si tratta di Patreon come provider SSO, corretto?

Grazie!

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [23 Gennaio 2020, 3:34am UTC](https://meta.discourse.org/t/example-code-for-how-a-hosted-solution-would-integrate-with-discourse/139424/7 "2020-01-23T03:34:43Z")

</div>

Oh, abbiamo parecchi esempi a riguardo:

> [@Discourse SSO in Nginx](https://meta.discourse.org/t/discourse-sso-in-nginx/47783?u=falco):
>
> If you are using Nginx (or the awesome OpenResty) to handle you user authentication, you can handle the [Discourse SSO](https://meta.discourse.org/t/13045?silent=true) on the Nginx too! This assumes you are using the ideas on this article to handle authentication: The following code implements the [Discourse SSO](https://meta.discourse.org/t/13045?silent=true) protocol in Lua, and even sets custom fields and the user birthday date for the [cakeday plugin](https://meta.discourse.org/t/cakeday-celebrating-birthdays-and-anniversaries/38447): -- First we inline this PR https://github.com/openresty/lua-resty-string/pull/18 -- You can remove this after @agentzh merges this patch…

> [@Bratwurst: the wurst possible production DiscourseConnect provider](https://meta.discourse.org/t/bratwurst-the-wurst-possible-production-sso-provider/72343?u=falco):
>
> I felt like making something the other night, so I implemented an [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) provider that is useful for development and testing: [https://github.com/Supermathie/bratwurst](https://github.com/Supermathie/bratwurst) The utility of this is to be able to configure an SSO backend so that you can test out the behaviour of Discourse with different scenarios from an external provider (e.g. “What happens if two users have the same email but different external IDs? What happens if the external ID changes? What happens if two users have the…

> [@Bratwurst: the wurst possible production DiscourseConnect provider](https://meta.discourse.org/t/bratwurst-the-wurst-possible-production-sso-provider/72343/2?u=falco):
>
> Just adding this here in case someone is in need of yet another example of how to do this in ruby: [https://meta.discourse.org/t/official-single-sign-on-for-discourse-sso/13045/372?u=blake](https://meta.discourse.org/t/official-single-sign-on-for-discourse-sso/13045/372)[https://github.com/oblakeerickson/sso\_endpoint](https://github.com/oblakeerickson/sso_endpoint)

[https://github.com/topics/discourse-sso](https://github.com/topics/discourse-sso)

Se il tuo sito web utilizza Ruby e Rails, puoi copiare e incollare il file [https://github.com/discourse/discourse/blob/master/lib/single\_sign\_on.rb](https://github.com/discourse/discourse/blob/master/lib/single_sign_on.rb) nella tua directory lib per gestire tutto il lavoro pesante, quindi aggiungere il controller e la rotta necessari.
