Skip to content

Fix CKAN 2.11 compatibility: use session.clear() for Flask-Session#91

Closed
maxwellyoung wants to merge 1 commit into
data-govt-nz:masterfrom
maxwellyoung:fix/ckan-2.11-session-compat-90
Closed

Fix CKAN 2.11 compatibility: use session.clear() for Flask-Session#91
maxwellyoung wants to merge 1 commit into
data-govt-nz:masterfrom
maxwellyoung:fix/ckan-2.11-session-compat-90

Conversation

@maxwellyoung
Copy link
Copy Markdown

Summary

Fixes #90 - CKAN 2.11 replaced Beaker with Flask-Session for session management. The logout() method was calling session.invalidate() which doesn't exist in Flask-Session, causing an AttributeError: 'RedisSession' object has no attribute 'invalidate' error.

Solution

Added a CKAN version check to use the appropriate session termination method:

  • CKAN 2.11+: session.clear() (Flask-Session API)
  • CKAN <2.11: 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 logic

References

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
@markstuart
Copy link
Copy Markdown
Contributor

Thanks for this, I've added it into #92 and that will get shipped in the near future.

@markstuart markstuart closed this Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CKAN 2.11 Compatiblity

2 participants