Accedi automaticamente tramite SSO

Ho configurato l’SSO e funziona tutto correttamente. Tuttavia, vorrei che gli utenti venissero automaticamente registrati quando visitano la nostra community Discourse, se sono già registrati sul nostro sito principale. In pratica, cliccare sul pulsante “Accedi” per avviare l’SSO e riportarli alla pagina di Discourse da cui provenivano.

Ho appena iniziato a esaminare il codice di accesso, ma speravo che qualcuno potesse darmi qualche indicazione su come avviare il login da un componente di tema personalizzato.

This can be done, but can cause issues logging into your SSO provider site if SSO is ever misconfigured. A safer approach is to add an SSO Login link to website that will automatically log users into Discourse and redirect them to a specified page when they click the link. See Create a DiscourseConnect login link for details.

Can you expand on what kinds of issues I could expect?

In my particular case, visitors will not hit the main app first - in a particular session. They will be visiting the community site but they will have been logged into the main app at some point. I’d like to pull in the login session automatically without any user interaction.

I ran into an issue with this when I was attempting to log users into Discourse from WordPress by silently redirecting them to Discourse and then back to WordPress as a part of the WordPress login process. If SSO was misconfigured, users would be locked out of WordPress.

If you do want to try this type of approach, you will need to enable the sso allows all return paths setting on Discourse. If you do that, you can then redirect users to:

https://discourse.example.com/session/sso?return_path=path_back_to_your_sso_provider_site