0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-07 13:19:19 +08:00
discourse/app/controllers/users
Chris Alberti aa157f5ea5
FIX: Delete destination_url cookie when it's used to set origin param during redirect to social auth (#36194)
When we navigate out to a social auth method, we set the origin param on
that request to the value of the destination_url.

Upon returning to Discourse, that origin param is returned and [we use
it to
set](4dd3becec1/config/initializers/009-omniauth.rb (L24))
server_session["destination_url"].

Then during the [omniauth
callback](4dd3becec1/app/controllers/users/omniauth_callbacks_controller.rb (L43)),
we use the server_session["destination_url"] value to redirect back to
the page the destination_url cookie originally pointed to.

The problem is that in this scenario, the destination_url cookie never
gets deleted. This was causing a bug with Discourse ID in a corner case
where [the discourse-login plugin sets the destination_url
cookie](646e32f4a6/config/initializers/doorkeeper.rb (L38))
to a url that contains an OAuth state parameter which can become stale,
and the cookie keeps getting re-used for redirection but not deleted,
resulting in an error message "Sorry, the authorization timed out, or
you have switched browsers. Please try again." which the user can't
escape.

The solution is to make sure that when we return to the omniauth callback we always clean up both the server_session[:destination_url] and cookies[:destination_url]
2025-11-25 09:15:03 -06:00
..
associate_accounts_controller.rb DEV: Allow ServerSession to store arbitrary data (#34919) 2025-09-26 10:35:28 +02:00
discourse_id_controller.rb DEV: Update rubocop-discourse to 3.13 and autofix issues (#35073) 2025-10-06 16:11:01 +02:00
omniauth_callbacks_controller.rb FIX: Delete destination_url cookie when it's used to set origin param during redirect to social auth (#36194) 2025-11-25 09:15:03 -06:00