Skip to content

Commit

Permalink
Middleware changes:
Browse files Browse the repository at this point in the history
* Moved SessionMiddelware to end of middleware stack
* Added CSRFMiddleware into stack
  • Loading branch information
Tobias Schulmann authored and wardi committed Jan 8, 2018
1 parent 540661f commit f0c6c7d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ckan/config/middleware/pylons_app.py
Expand Up @@ -61,7 +61,7 @@ def make_pylons_stack(conf, full_stack=True, static_files=True,
# we want to be able to retrieve the routes middleware to be able to update
# the mapper. We store it in the pylons config to allow this.
config['routes.middleware'] = app
app = SessionMiddleware(app, config)

app = CacheMiddleware(app, config)

# CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
Expand Down Expand Up @@ -130,6 +130,13 @@ def make_pylons_stack(conf, full_stack=True, static_files=True,
who_parser.remote_user_key
)

try:
from ckanext.security.middleware import CSRFMiddleware
app = CSRFMiddleware(app, config)
except ImportError:
pass
app = SessionMiddleware(app, config)

# Establish the Registry for this application
app = RegistryManager(app)

Expand Down

0 comments on commit f0c6c7d

Please sign in to comment.