Fix CKAN 2.11 compatibility: use session.clear() for Flask-Session#91
Closed
maxwellyoung wants to merge 1 commit into
Closed
Fix CKAN 2.11 compatibility: use session.clear() for Flask-Session#91maxwellyoung wants to merge 1 commit into
maxwellyoung wants to merge 1 commit into
Conversation
CKAN 2.11 replaced Beaker with Flask-Session for session management. Flask-Session uses clear() instead of invalidate() to destroy sessions. This change adds a version check to use the appropriate method: - CKAN 2.11+: session.clear() (Flask-Session) - CKAN <2.11: session.invalidate() (Beaker) Fixes data-govt-nz#90
Contributor
|
Thanks for this, I've added it into #92 and that will get shipped in the near future. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #90 - CKAN 2.11 replaced Beaker with Flask-Session for session management. The
logout()method was callingsession.invalidate()which doesn't exist in Flask-Session, causing anAttributeError: 'RedisSession' object has no attribute 'invalidate'error.Solution
Added a CKAN version check to use the appropriate session termination method:
session.clear()(Flask-Session API)session.invalidate()(Beaker API)This maintains backward compatibility with older CKAN versions while fixing the logout error in 2.11+.
Changes
ckanext/security/plugin/flask_plugin.py: Import toolkit, add version-conditional logout logicReferences