Moodle

use of SESSION in export plugins prevents opening of multiple windows

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 2.0
  • Fix Version/s: 2.0
  • Component/s: Portfolio API
  • Labels:
    None
  • Affected Branches:
    MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

I remember we discussed it before, I objected that the use of session will result in a lot of confusion when using multiple windows. Unfortunately it is worse than I expected

Example:
1/ enable Download plugin
2/ create new forum with some posts
3/ "Save" posts one by one
4/ now open "Save..." of first post in new window
5/ close that new window
6/ save another post

result - first post is saved instead of the second, this feels very confusing to me

====

if the export fails with "You tried to repeat the export of some information, or start an empty export. To do that properly you should go back to the original location and start again. This sometimes happens if you use the back button after an export has completed, or by bookmarking an invalid url." the continue button leads to $CFG->wwwroot

====

Obvious solution is to use Ajax popups.
Alternative solution would be to use hidden params for original tracking where possible and only exceptionally rely on session data in plugins that do not have callbacks with custom parameters
.

Activity

Hide
Penny Leach added a comment -

I agree about ajax popups. See this bug which I opened early November last year: http://tracker.moodle.org/browse/MDL-17146 and has no resolution yet.

Show
Penny Leach added a comment - I agree about ajax popups. See this bug which I opened early November last year: http://tracker.moodle.org/browse/MDL-17146 and has no resolution yet.
Hide
Penny Leach added a comment -

box.net still doesn't support dynamically constructing urls. I've already updated the mahara plugin (in my git repository, pending merge to head) to not require session. I talked to Dan about picassa and googledocs, and he's going to update them to not use session as well. Not sure about Flickr, nico wrote that one, I'll have to test it.

I propose adding a new abstract method to the base portfolio_plugin class, supports_multiple_exports (or similar), which defaults to true, but will be overridden for box.net. Then, the portfolio code can support multiple exports per session, but NOT multiple exports of the same type of any plugins which don't support it. Then, we add portfolio/return.php?type=xxxx which box.net (and any other plugins that get written) can use, upon return from authenticating at external system. This figures out the id, and redirects to portfolio/add.php?postcontrol=1&id=xxx to pick up again.

Petr - is this an acceptable solution for you?

Show
Penny Leach added a comment - box.net still doesn't support dynamically constructing urls. I've already updated the mahara plugin (in my git repository, pending merge to head) to not require session. I talked to Dan about picassa and googledocs, and he's going to update them to not use session as well. Not sure about Flickr, nico wrote that one, I'll have to test it. I propose adding a new abstract method to the base portfolio_plugin class, supports_multiple_exports (or similar), which defaults to true, but will be overridden for box.net. Then, the portfolio code can support multiple exports per session, but NOT multiple exports of the same type of any plugins which don't support it. Then, we add portfolio/return.php?type=xxxx which box.net (and any other plugins that get written) can use, upon return from authenticating at external system. This figures out the id, and redirects to portfolio/add.php?postcontrol=1&id=xxx to pick up again. Petr - is this an acceptable solution for you?
Hide
Petr Škoda (skodak) added a comment -

Limitation in one plugin is not important imho, they keep improving public APIs in those public services. From my point of view is the most important user experience - is it going to work when users is opening multiple windows each with different course and exports at the same time?

Show
Petr Škoda (skodak) added a comment - Limitation in one plugin is not important imho, they keep improving public APIs in those public services. From my point of view is the most important user experience - is it going to work when users is opening multiple windows each with different course and exports at the same time?
Hide
Penny Leach added a comment -

That is what I am aiming for, with the exception of the plugins (only box.net) that don't support it because their external service is unable to handle it. In that case, you can still have an export to mahara in a different tab to an export to box.net - you just can't have two box.net exports in different tabs.

Which raises another question - I've just written some code which allows you to see a list of all current in-progress exports, and either cancel, or continue them.

A situation can happen where the stored sesskey in an export becomes expired. for example:

  • start an export
  • session dies - browser crashes or whatever
  • user tries to restart it but gets a portfolio verification error.

The question is - can we securely work around this case somehow ? Petr do you feel that we can restart an expired export in this case, with a different session key if we ensure that the user is the same?

Show
Penny Leach added a comment - That is what I am aiming for, with the exception of the plugins (only box.net) that don't support it because their external service is unable to handle it. In that case, you can still have an export to mahara in a different tab to an export to box.net - you just can't have two box.net exports in different tabs. Which raises another question - I've just written some code which allows you to see a list of all current in-progress exports, and either cancel, or continue them. A situation can happen where the stored sesskey in an export becomes expired. for example:
  • start an export
  • session dies - browser crashes or whatever
  • user tries to restart it but gets a portfolio verification error.
The question is - can we securely work around this case somehow ? Petr do you feel that we can restart an expired export in this case, with a different session key if we ensure that the user is the same?
Hide
Petr Škoda (skodak) added a comment -

I do not understand the problem with sesskey, it is stored only in session and is compared when receiving request from browser, it should not be transmitted to other systems or stored anywhere else in DB or session.

Show
Petr Škoda (skodak) added a comment - I do not understand the problem with sesskey, it is stored only in session and is compared when receiving request from browser, it should not be transmitted to other systems or stored anywhere else in DB or session.
Hide
Penny Leach added a comment -

It's stored in the exporter object, which persists between requests. It's not transmitted to any other systems. I guess it could be removed from the exporter object and passed along portfolio/add.php each request.

Show
Penny Leach added a comment - It's stored in the exporter object, which persists between requests. It's not transmitted to any other systems. I guess it could be removed from the exporter object and passed along portfolio/add.php each request.
Hide
Petr Škoda (skodak) added a comment -

sesskey should be passed with each request and there should not be any true objects in session

Show
Petr Škoda (skodak) added a comment - sesskey should be passed with each request and there should not be any true objects in session
Hide
Petr Škoda (skodak) added a comment -

not really each request, only those that modify the DB or session - I hope tim explained this in the new security page and everybody understands that now

Show
Petr Škoda (skodak) added a comment - not really each request, only those that modify the DB or session - I hope tim explained this in the new security page and everybody understands that now
Hide
Penny Leach added a comment -

Yeah I guess I was probably being too clever and trying to encapsulate this by storing it in the export object rather than the calling script.

I think portfolio definitely needs sesskey to prevent users triggering a portfolio request "on behalf of" someone else, but it can be managed better, by using sesskey in the url of portfolio/add.php rather than the export object.

I just wanted to double check that I wasn't hurting security by removing this.

Show
Penny Leach added a comment - Yeah I guess I was probably being too clever and trying to encapsulate this by storing it in the export object rather than the calling script. I think portfolio definitely needs sesskey to prevent users triggering a portfolio request "on behalf of" someone else, but it can be managed better, by using sesskey in the url of portfolio/add.php rather than the export object. I just wanted to double check that I wasn't hurting security by removing this.
Hide
Penny Leach added a comment -

I just committed a huge amount of code to the core portfolio api to deal with this problem.

I need to retest all the different plugins and update them to work with the new api but it seems to be working (multiple exports in different tabs, etc)

Show
Penny Leach added a comment - I just committed a huge amount of code to the core portfolio api to deal with this problem. I need to retest all the different plugins and update them to work with the new api but it seems to be working (multiple exports in different tabs, etc)
Hide
Penny Leach added a comment -

Petr can you please review and close this

Show
Penny Leach added a comment - Petr can you please review and close this
Hide
Penny Leach added a comment -

Petr review ping please!

Show
Penny Leach added a comment - Petr review ping please!
Hide
Penny Leach added a comment -

btw box.net wrote to me about one of these bugs and i suggested they improve their api, so even box.net may be able to support multiple exports per session at some point in the future.

Show
Penny Leach added a comment - btw box.net wrote to me about one of these bugs and i suggested they improve their api, so even box.net may be able to support multiple exports per session at some point in the future.
Hide
Martin Dougiamas added a comment -

Resolving for now. Any problems can make new bugs or reopen.

Show
Martin Dougiamas added a comment - Resolving for now. Any problems can make new bugs or reopen.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: