Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Make registration idempotent #649
Conversation
dbkr
assigned
erikjohnston
Mar 16, 2016
dbkr
added a commit
to matrix-org/sytest
that referenced
this pull request
Mar 16, 2016
dbkr
referenced this pull request
in matrix-org/sytest
Mar 16, 2016
Merged
Test registration idempotency #213
dbkr
added some commits
Mar 16, 2016
erikjohnston
commented on an outdated diff
Mar 16, 2016
| @@ -455,11 +485,17 @@ def add_threepid(self, user_id, medium, address, validated_at): | ||
| def _save_session(self, session): | ||
| # TODO: Persistent storage | ||
| logger.debug("Saving session %s", session) | ||
| + session["last_used"] = time.time() |
erikjohnston
Owner
|
erikjohnston
commented on an outdated diff
Mar 16, 2016
| @@ -35,6 +36,7 @@ | ||
| class AuthHandler(BaseHandler): | ||
| + SESSION_EXPIRE_SECS = 48 * 60 * 60 |
erikjohnston
Owner
|
|
To what extend do we care if session information gets dropped on the floor over restarts? |
|
We probably do care that session information gets dropped over restarts, but no more so now than before, so I think that would be a separate fix. |
erikjohnston
and 1 other
commented on an outdated diff
Mar 16, 2016
| @@ -263,7 +293,7 @@ def _get_session_info(self, session_id): | ||
| if not session_id: | ||
| # create a new session | ||
| while session_id is None or session_id in self.sessions: | ||
| - session_id = stringutils.random_string(24) | ||
| + session_id = stringutils.random_string_with_symbols(24) |
erikjohnston
Owner
|
Fair enough |
dbkr
added some commits
Mar 16, 2016
erikjohnston
commented on an outdated diff
Mar 16, 2016
| self.sessions[session["id"]] = session | ||
| - | ||
| - def _remove_session(self, session): | ||
| - logger.debug("Removing session %s", session) | ||
| - del self.sessions[session["id"]] | ||
| + self._prune_sessions() | ||
| + | ||
| + def _prune_sessions(self): | ||
| + for sid, sess in self.sessions.items(): | ||
| + last_used = 0 | ||
| + if 'last_used' in sess: | ||
| + last_used = sess['last_used'] | ||
| + if last_used < self.hs.get_clock().time() - AuthHandler.SESSION_EXPIRE_MS: |
|
|
dbkr
added some commits
Mar 16, 2016
|
LGTM |
dbkr commentedMar 16, 2016
If you specify the same session, make it give you an access token for the user that was registered on previous uses of that session. Tweak the UI auth layer to not delete sessions when their auth has completed and hence expire them so they don't hang around until server restart. Allow server-side data to be associated with UI auth sessions.
sytest: matrix-org/sytest#213
Fixes vector-im/vector-web#957