# Discourse は、プライベートサイトでのログイン後に return\_sso\_url にリダイレクトしません

**URL:** <https://meta.discourse.org/t/discourse-doesnt-redirect-to-return-sso-url-after-user-logs-in-on-private-site/97201>\
**Category:** Product Support\
**Created:** [2018 年 9 月 14 日午後 5:40 UTC](https://meta.discourse.org/t/discourse-doesnt-redirect-to-return-sso-url-after-user-logs-in-on-private-site/97201 "2018-09-14T17:40:22Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![tdfischer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tdfischer/32/103856_2.png) [@tdfischer](https://meta.discourse.org/u/tdfischer)\
**Post date:** [2018 年 9 月 14 日午後 5:40 UTC](https://meta.discourse.org/t/discourse-doesnt-redirect-to-return-sso-url-after-user-logs-in-on-private-site/97201/1 "2018-09-14T17:40:22Z")

</div>

I have a discourse instance which requires you to login, and doesn’t support anonymous browsing.

I also have a separate django app that uses python-social-auth to login to Discourse using its SSO protocol.

When a user logs in to the django app using the [discourse SSO](https://meta.discourse.org/t/13045?silent=true) login, one of the two following sequences happen:

If the user is already logged in to discourse:

1. They click the login button in the django app
2. and are redirected to discourse’s SSO url
3. and are immediately redirected back to the django app

However, if they’re not already logged in to discourse:

1. They click the login button in the django app
2. and are redirected to discourse’s SSO url
3. which then redirects them to /login in the discourse app
4. the user logs in to discourse
5. they are redirected to the front discourse page
6. and are never redirected back to the django app, meaning they need to remember to go back to the app after logging in to discourse and /start over from step 1, but now following other sequence of steps I wrote above/

My django app’s [discourse SSO](https://meta.discourse.org/t/13045?silent=true) code can be found here:

> <https://github.com/tdfischer/organizer/blob/master/organizer/auth.py#L12>

I followed the steps here:

> [@Use Discourse as an identity provider (SSO, DiscourseConnect)](https://meta.discourse.org/t/using-discourse-as-a-sso-provider/32974):
>
> So you want to use Discourse as an identity provider for your own web app? Great! Let’s get started. Enable [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) provider setting Under Discourse admin site settings (/admin/site\_settings) enable setting enable discourse connect provider and add a secret string to discourse connect provider secrets (used to hash SSO payloads). Implement [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) in your web app: Generate a random [nonce](https://en.wikipedia.org/wiki/Cryptographic_nonce). Let’s call this value NONCE. Save it temporarily so that you can verify it with the …

Am I missing something that isn’t documented? I see a lot of posts on [discourse.org](http://discourse.org) and a few merged pull requests in github that seem to allude to this having been fixed once before in 2015, but I can’t get it to work for some reason.

---

_[View the full topic](https://meta.discourse.org/t/discourse-doesnt-redirect-to-return-sso-url-after-user-logs-in-on-private-site/97201)._
