# Issues using SSO in custom web app

**URL:** <https://meta.discourse.org/t/issues-using-sso-in-custom-web-app/77429>\
**Category:** Development\
**Created:** [Janeiro 6, 2018, 6:30am UTC](https://meta.discourse.org/t/issues-using-sso-in-custom-web-app/77429 "2018-01-06T06:30:49Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![supernaturally](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@supernaturally](https://meta.discourse.org/u/supernaturally)\
**Post date:** [Janeiro 7, 2018, 10:37pm UTC](https://meta.discourse.org/t/issues-using-sso-in-custom-web-app/77429/4 "2018-01-07T22:37:10Z")

</div>

> [@Setup DiscourseConnect - Official Single-Sign-On for Discourse (sso)](https://meta.discourse.org/t/setup-discourseconnect-official-single-sign-on-for-discourse-sso/13045/393):
>
> Not following at all, how can you even initiate an SSO login if the browser is logged on?

Sorry, I may have confused things a bit. The issue for us is when a user in our web app is different from the user logged into our Discourse instance. I am trying to figure out of there is a way for Discourse to recognize that an incoming user visiting from our web app is different than the currently logged-in Discourse user:

- Two applications exist “wrapped” into a mobile hybrid app: 1. [mycompany.com](http://mycompany.com) (i.e. our web app) and 2. [forum.mycompany.com](http://forum.mycompany.com) (i.e. Discourse). From a usability standpoint, both of these applications are packaged into a mobile application, which utilizes a webview, called MyCompany App…forum.mycompany.com is just a menu item called “Community”
- [John@mycompany.com](mailto:John@mycompany.com) is logged into the webapp ([mycompany.com](http://mycompany.com)) and decides to click on the “Community” menu item inside of the mobile app (MyCompany App), which redirects him to [forum.mycompany.com](http://forum.mycompany.com)  
– Upon entering [forum.mycompany.com](http://forum.mycompany.com) (i.e. Discourse) inside of MyCompany App, John immediately notices that he is logged in under [sarah@mycompany.com](mailto:sarah@mycompany.com), who was using the company’s shared smartphone the day before (her session at [mycompany.com](http://mycompany.com) had timed out and made MyComapny App appear as if nobody was authenticated on the smartphone…however, Sarah was still authenticated inside of Discourse, so when John logged in to the MyCompany App via the webapp’s webview ([mycompany.com](http://mycompany.com)) using his credentials and attempted to navigate to the “Community” menu item ([forum.mycompany.com](http://forum.mycompany.com)), Sarah was still authenticated inside of Discourse).

My question is this - can we fix this issue by passing our webapp’s authenticated user via url to Discourse when mobile app users click the “Community” menu item? (ex. instead of just hyperlinking the menu item to [forum.mycompany.com](http://forum.mycompany.com), we might dynamically link [forum.mycompany.com/{externalID}](http://forum.mycompany.com/%7BexternalID%7D)). In this way, Discourse would be able to identify whether the user visiting from our web app ([mycompany.com](http://mycompany.com)) is the same user as the current authenticated user inside of [forum.mycompany.com](http://forum.mycompany.com). If the users’ externalID does not match, discourse can log out the current user and then redirect the browser back to [mycompany.com/discourse/sso](http://mycompany.com/discourse/sso), which will then in turn authenticate the correct user back into Discourse. This issue only exists when a user’s session times out in our web app, in which case using the API to log out the user from the Discourse instance will not work.

---

_[View the full topic](https://meta.discourse.org/t/issues-using-sso-in-custom-web-app/77429)._
