Skip to content

Track user sessions - #21592

Closed
MorrisJobke wants to merge 4 commits into
masterfrom
session-tracking
Closed

MorrisJobke wants to merge 4 commits into
masterfrom
session-tracking

Conversation

@MorrisJobke

Copy link
Copy Markdown
Contributor

missing items:

  • occ command to list sessions of a user and kill user sessions
  • acceptance test that verifies the logout mechanism works
  • background job to clean up timed out sessions

cc @DeepDiver1975 @PVince81 @LukasReschke

@MorrisJobke MorrisJobke added this to the 9.0-current milestone Jan 10, 2016
@mention-bot

Copy link
Copy Markdown

By analyzing the blame information on this pull request, we identified @rullzer, @icewind1991 and @tanghus to be potential reviewers

@karlitschek

Copy link
Copy Markdown
Contributor

Do you have performance tests for that? Duplicating sessions in ownCloud doesn't sound like a good idea from a scalability point of view.
Why is this a blue ticket?

@karlitschek

Copy link
Copy Markdown
Contributor

By the way. Please mention me at big low level changes like that :-)

@MorrisJobke

Copy link
Copy Markdown
Contributor Author

Do you have performance tests for that?

I will do some.

Why is this a blue ticket?

This is a blue one, because some other blue tickets are relying on such a feature (for example LDAP password change enforce, remote log out a given user, ...)

@MorrisJobke

Copy link
Copy Markdown
Contributor Author

Do you have performance tests for that?

BTW: I tested this with few queries in mind - for example I added a 5 second timeout for recurring DB queries (both to add updated timestamps and checks if the session was killed). So a page load with e.g. 100 requests will only result in one additional queries and not 100 additional queries.

Those 5 seconds are still to tweak - was just a first guesstimate ;)

@karlitschek

Copy link
Copy Markdown
Contributor

O.K. Thanks. So this is basically a feature that was requested and not a bugfix?

@MorrisJobke

Copy link
Copy Markdown
Contributor Author

Duplicating sessions in ownCloud doesn't sound like a good idea from a scalability point of view.

Sadly it's needed to allow the relation of "sessionID <-> user" :(

@MorrisJobke

Copy link
Copy Markdown
Contributor Author

O.K. Thanks. So this is basically a feature that was requested and not a bugfix?

Yep. But this change would have prevent stuff like https://github.com/owncloud/enterprise/issues/940 and https://github.com/owncloud/enterprise/issues/445 even before they became an actual problem.

@rullzer

rullzer commented Jan 11, 2016

Copy link
Copy Markdown
Contributor

@MorrisJobke any reason for the 5 seconds? Or just some number had to be picked?

@DeepDiver1975

Copy link
Copy Markdown
Contributor

Things coming to my mind when looking at this:

  • if we store the session in the db - there is absolutely no reason anymore to use php session because everything is already in the db which acts as single shared session store then
  • this has a close relation to client tokens and token based authentication
  • an approach like this is necessary to implement session invalidation on password change and user deletion etc

@MorrisJobke

Copy link
Copy Markdown
Contributor Author

Or just some number had to be picked?

correct.

@rullzer

rullzer commented Jan 11, 2016

Copy link
Copy Markdown
Contributor

if we store the session in the db - there is absolutely no reason anymore to use php session because everything is already in the db which acts as single shared session store then

Probabaly a good idea to look into http://php.net/manual/en/class.sessionhandlerinterface.php then.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

@karlitschek I'd like to address this topic in the dev cycle of 9.1 including proper analysis of opportunities and impact - this touches too many pieces which are connected.

Objections?

@MorrisJobke Thanks for the work on this!

@DeepDiver1975 DeepDiver1975 modified the milestones: 9.1-next, 9.0-current Jan 11, 2016
@MorrisJobke

Copy link
Copy Markdown
Contributor Author

@karlitschek

Copy link
Copy Markdown
Contributor

agreed. let's move it to 9.1

@DeepDiver1975

Copy link
Copy Markdown
Contributor

Now we have to wait 🕐

@MorrisJobke any results? 😉

Comment thread db_structure.xml
<name>session_id</name>
<type>text</type>
<default></default>
<length>128</length>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this enough? @LukasReschke

Comment thread db_structure.xml

<field>
<name>created_at</name>
<type>integer</type>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timestamp ?

* introduced a timeout for writing the updated session information to DB (at most every 5 seconds)
* logout and session regeneration will result in dropping the session from DB
* IP and user agent of the session starting request is stored (for information about the session)
* allows to drop the session from the database and then kill the active session automatically
* this check is done at most once every 5 seconds
* ref #18410
@MorrisJobke

Copy link
Copy Markdown
Contributor Author

@MorrisJobke any results?

Ummm I will check later.

@rullzer

rullzer commented Apr 8, 2016

Copy link
Copy Markdown
Contributor

While this is awesome. I still think we should do it right from the start and implement a session handle (http://php.net/manual/en/class.sessionhandlerinterface.php). That way ownCloud handles all of the session.
Instead of letting PHP do a part and we do a part on top of that.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

Session handler is out of scope currently from my pov. The arch impact is too big.
Many Installations use different PHP based implementations of the session handler.

@PVince81

Copy link
Copy Markdown
Contributor

Not sure how much overlaps with @ChristophWurst's work ?

@ChristophWurst

Copy link
Copy Markdown
Contributor

logs the session IDs to the database
done, but hashed. Is the raw session id needed?

checks if the session is still in the DB if the session is resumed (checked at most every 5 seconds)

done

updates the last used time of a session (for invalidation purposes - also updated at most every 5 seconds)

done, once per minute though

removes the session on logout/timeout

done

logs the IP and user agent of the session during session creation (for easier identification of a session and fraud detection)

only the user agent is saved for the session token

this will allow stuff like #18410, #19529, owncloud/client#3912 (force a logout of a given client)

users are logged out if the password was changed (user backend is queried once per 5 minues)
device specific tokens are generated and thus tracked

@MorrisJobke

Copy link
Copy Markdown
Contributor Author

@ChristophWurst This means, that you implemented all of this already? That would be super nice. I want to talk to you about this anyway :)

@ChristophWurst

Copy link
Copy Markdown
Contributor

@ChristophWurst This means, that you implemented all of this already? That would be super nice. I want to talk to you about this anyway :)

Nor sure if it's all, but most of it I think ;-)

@MorrisJobke

Copy link
Copy Markdown
Contributor Author

#24189 is a lot better and my PR is superseeded by this -> closing

@MorrisJobke
MorrisJobke deleted the session-tracking branch May 13, 2016 20:16
@lock

lock Bot commented Aug 5, 2019

Copy link
Copy Markdown

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.

@lock lock Bot locked as resolved and limited conversation to collaborators Aug 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants