You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
S2S: Reuse session instead of authenticating on every request #12228
, in this code the password is verified for every single request.
This is a very huge performance drawback as the password is hashed using bcrypt which consumes a lot of CPU power. Instead we should generate a session which can be then reused by the remote ownCloud server instead of re-authenticating on every request.
There are actually two levels of reusing the session:
Level 1: within a single PHP request, we already do many calls to the remote server. Keeping a single session within that PHP request would already reduce the load significantly.
Level 2: store the session id in the database to be able to reuse it in separate PHP requests. When expired, need to refresh it. (this all somehow reminds me of OAuth...)
Hmm strange thing, I just tested on master and looking at access_log I only saw a single 401 appearing instead of multiple ones. Maybe one of the Sabre upgrades brought cookie support. Need to double check this.
I'll check on the remote server to see if we're indeed reusing a session.
Then: identify which version this stated happening and hopefully close this ticket 😄
Okay, I did some debugging on the target server and noticed that the sabre client was already sending the Authorization header for any requests that follow the one with 401. So the 401 only happens once.
Now let's see if we can also reuse the session to reduce the load even more.
Now thinking of it the public webdav usually isn't supposed to have a session.
But it does have one because someone can authenticate several link shares using their password and that information is stored in the session to avoid re-auth multiple times.
Activity
PVince81 commentedon Jan 21, 2015
Setting to 8.1 as this makes server to server sharing very slow, something to look at.
CC @DeepDiver1975 @karlitschek
PVince81 commentedon Feb 11, 2015
So, as discussed on IRC with @LukasReschke we need to catch the cookie and resend it with auth, then just reuse it for further requests.
But currently we use Sabre\Client which relies on
curl.And you mentionned that Guzzle is a nice HTTP client that could do it.
Possibly solutions:
or
or
LukasReschke commentedon Feb 11, 2015
Let me dig into the code some time… Assigning to myself.
PVince81 commentedon Feb 11, 2015
I had a quick look and our current version of Sabre wouldn't fit.
But the new Sabre version seems to come with an improved client: https://github.com/fruux/sabre-dav/blob/2.1/lib/DAV/Client.php
That one is based on the Sabre\Http\Client here: https://github.com/fruux/sabre-http/blob/master/lib/Client.php#L18 which has events "beforeRequest" and "afterRequest" that give access to the headers. This means that we could just implement those and do the cookie magic.
It also means that it's really time to upgrade Sabre... #12876
PVince81 commentedon Feb 25, 2015
🔔 the new Sabre has arrived which means it will be possible to work with the cookies now 😄
PVince81 commentedon Apr 23, 2015
Moving to 8.2
PVince81 commentedon Sep 21, 2015
@LukasReschke any update ?
10 remaining items
PVince81 commentedon Oct 10, 2016
Reuse session or send an Authentication header as per #11815.
But reusing the session should reduce the burden on the remote server.
PVince81 commentedon Oct 10, 2016
There are actually two levels of reusing the session:
Level 1: within a single PHP request, we already do many calls to the remote server. Keeping a single session within that PHP request would already reduce the load significantly.
Level 2: store the session id in the database to be able to reuse it in separate PHP requests. When expired, need to refresh it. (this all somehow reminds me of OAuth...)
PVince81 commentedon Oct 10, 2016
Hmm strange thing, I just tested on master and looking at access_log I only saw a single 401 appearing instead of multiple ones. Maybe one of the Sabre upgrades brought cookie support. Need to double check this.
PVince81 commentedon Oct 10, 2016
From what I see and remember, Sabre client's HTTP layer has changed a bit. And from what I see here https://github.com/fruux/sabre-http/blob/4.2.1/lib/Client.php#L348 it might be using a single curl session, which is likely to keep cookies.
I'll check on the remote server to see if we're indeed reusing a session.
Then: identify which version this stated happening and hopefully close this ticket 😄
PVince81 commentedon Oct 10, 2016
Okay, I did some debugging on the target server and noticed that the sabre client was already sending the Authorization header for any requests that follow the one with 401. So the 401 only happens once.
Now let's see if we can also reuse the session to reduce the load even more.
PVince81 commentedon Oct 10, 2016
Now thinking of it the public webdav usually isn't supposed to have a session.
But it does have one because someone can authenticate several link shares using their password and that information is stored in the session to avoid re-auth multiple times.
So there is still a little bit to save here.
PVince81 commentedon Dec 15, 2017
Will be obsoleted by #29779
lock commentedon Aug 2, 2019
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.