Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.6.7, 2.7.4, 2.8, 2.9
-
MOODLE_26_STABLE, MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE
-
MOODLE_29_STABLE
-
MDL-48887-fastredirect -
Description
Looking at a typical login flow in the browser reveals a lot of redirects. ie if we use the saml auth plugin, and assume the best case scenario on the saml IDP side where the user is already logged in, but no session on the moodle side, then we still end up with a staggering 7 redirects between clicking on the page we want and then actually being served that page. The saml protocol itself only requires a single redirect, so the rest are potentially redundant in some way.
On networks with high latency, eg mobile, each redirect can be upwards of 100's of ms so combined they can easily account for seconds of time wasted for no reason.
Some of the issues / solutions are in core, some others would be in the various auth plugins like saml. eg a typical saml flow:
Try to view a protect page eg /course/view.php?id=10
1) 303 redirect to /login/index.php
2) 303 redirect to /auth/saml/login.php
3) 302 redirect to /auth/saml/index.php?wantsurl=XX
4) 302 redirect to IDP url
5) 200 IDP redirects back to simplesaml
6) 303 simplesaml redirect back to /auth/saml/index/php?YYY
7) 303 redirect to original course url
8) 200 render of desired url
Some ideas:
a) If 'alternateloginurl' is forced in config.php and so unchangeable, we can skip 2 redirects and redirect directly to url #3 or possibly even url #4. The login link in the header on public pages would link directly to this as well. ie add logic to get_login_url() in moodlelib.php Or make this is tick box in the auth settings page eg 'Fast redirect to alternate login page'. Bonus points: there still seems to be a lot of places in core hard code /login/index.php instead of calling get_login_url() This would have potential benefits across many auth plugin types without them needing to be modified.
b) Redirect #6 could also be removed if there was an optional moodle auth hook which allows an auth plugin code to run just prior to the user being redirected to the login page, and give it a chance to authenticate them and then keep going. ie the simplesaml plugin can check the dual session, confirm it's validity and then log the user in and continue. Same for other auth types without password forms, ie an external cookie, http header, ip check etc. Something like prelogin_hook(). So if this new API hook was added the redirect to the IDP could be handled directly here, and avoid the 'alternateloginurl' solution above, saving at least 3 redirects with a single API hook.
So thoughts and feedback?