conwetlab / ckanext-oauth2

OAuth2 support for CKAN
GNU Affero General Public License v3.0
25 stars 56 forks source link

Session files being created for each request #9

Closed amercader closed 8 years ago

amercader commented 8 years ago

This call here:

https://github.com/conwetlab/ckanext-oauth2/blob/4833c26eb617763d8304635657ceb9748af6125a/ckanext/oauth2/plugin.py#L110

essentially means that a session file is created for every single request that is made to CKAN, which would explain the massive number of session files. This leads to millions and millions of session files being created, which eventually means that the server will run out of inodes, causing the application to crash.

Session files should only be created when needed (eg to display flash messages)

aitormagan commented 8 years ago

As stated in the previous line to the one you've remarked, the session.save() instruction is there because in some cases we are required to use a flash message to inform the user the logging process has failed. The flash message is displayed here: https://github.com/conwetlab/ckanext-oauth2/blob/master/ckanext/oauth2/controller.py#L63.

I cannot remember it very well right now, but I think that line is there because otherwise the flash message did not work (I think I tried different places with no results). Anyway, I will try to fix it as soon as possible...

aitormagan commented 8 years ago

As you can see, I have moved the session.save() statement to the place where the session need to be created in order to display the flash message. In this regard, I think no more unnecessary session files will be created by this extension.

PS: I have updated the FIWARE Lab instance with the last version of the plugin :)

amercader commented 8 years ago

Great, thanks @aitormagan