Skip to content

bug: preserve FIELDS_STORED_IN_SESSION across OAuth session cleanup #471

Open

Description

@robrap

This is an extension of the fix introduced in:

Instead of only preserving next, we also preserve FIELDS_STORED_IN_SESSION.

The other PR hits a known issue we've seen in Production, and this hits an issue that might affect openedx-platform?

The following are notes from Claude on this issue. The proposed code change as not been verified:

Param next is the only thing restored, but do_auth() stores more than that before start(). It copies every name in FIELDS_STORED_IN_SESSION (default [], e.g. edx-platform LMS sets ['auth_entry', 'next']) and then separately handles next via redirect_name. Anything else a deployment lists there is flushed by logout() for the same reason next was.

         # logout() flushes the session, which also holds what social-auth just stored for this request:
         # the sanitized redirect and any FIELDS_STORED_IN_SESSION. Carry only those across.
         stored_names = ['next', *self.setting('FIELDS_STORED_IN_SESSION', [])]
         stored_values = {name: self.strategy.session_get(name) for name in stored_names}
         logout(request)
         for name, value in stored_values.items():
             if value is not None:
                 self.strategy.session_set(name, value)

Notes:

  • next may appear twice if a deployment also lists it in FIELDS_STORED_IN_SESSION. That should be harmless, since the same value is restored twice.
  • do_auth() writes None for listed fields missing from the request. The is not None guard avoids re-creating those keys, and session_get returns None either way.
  • The FIELDS_STORED_IN_SESSION could values are still dropped.
    For the test, adding a second field (e.g. FIELDS_STORED_IN_SESSION = ['auth_entry'], set to 'login' before do_start()) and asserting it survives would cover the list handling.

Activity

  1. added a commit that references this issue on Oct 28, 2026
    764465b
  2. djoseph-apphelix commented on Oct 28, 2026

    @djoseph-apphelix

    Folded into #470 as a second commit (764465b): start() now carries next plus every field in FIELDS_STORED_IN_SESSION across the forced logout, with the existing test extended to cover an auth_entry field.

    One note for the record: no current EdXOAuth2 consumer sets FIELDS_STORED_IN_SESSION. The LMS does, but it does not log in through this backend, and Studio leaves it empty. So this half is hardening rather than a reproducible production bug today. The PR closes this issue on merge.

  3. added a commit that references this issue on Oct 28, 2026
    9a97775
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions