We use DiscourseSSO and sporadically users run into login issues (similar to Sporadic issue wp-discourse/SSO: Nonce has already expired). I was trying to debug this by adding some extra logging and luckily ran into the issue after a couple of days. To be clear, login works most of the times, just that sporadically (may be for 5 mins a day) users run into login issues.
We use subfolder setup on multi-node cluster, using external shared DB and Redis if that makes any difference. There are two failing scenarios:
-
Nonce expired
When the user is redirected to /session/sso_login, SessionController does not get session_id in the session and thus is not able to lookup the nonce. I tried logging the session (Rails.logger.warn("Verbose SSO log: Session #{session.keys.map {|key| [key, session[key]].join('=')}.join(',')}")
) and it printed empty session. I verified that the browser is sending β_forum_sessionβ cookie as received in the previous request and the cookie is logged on the server if logging in SessionController (Rails.logger.warn("Verbose SSO log: Cookies #{cookies.map {|cookie| cookie.join('=')}.join(',')}")
). -
Login completes but the user gets Login error on the screen
When the user is redirected to /session/sso_login, SessionController is able to verify SSO data and log the user in (I seeVerbose SSO log: User was logged on user5
in the logs). But when it redirects the user to /forums/latest, user sees an error on the screen. I noticed that in the working flow this action clears/returns-empty βcnβ cookie but in the failing scenario, it just updates and returns β_tβ cookie. My guess is this scenario might also be related to missing session data.
If we wait for 5 mins or so and try again, then everything starts working fine again.
I have not tested if all users hitting the site at that time run into the issue or not, but I have been told anecdotally that multiple users ran into it once on our instance.