Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Persist user interactive authentication sessions #7302

Merged
merged 36 commits into from
Apr 30, 2020
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b030fdb
Persist the storage of UI Auth sessions into the database.
clokep Apr 10, 2020
4a83da9
Ensure that UI auth stages are idempotent.
clokep Apr 15, 2020
e7a2db6
Fix postgresql issues.
clokep Apr 17, 2020
b9dd110
Add a changelog file.
clokep Apr 20, 2020
831f8a2
Expire old sessions.
clokep Apr 20, 2020
04d3d8b
Keep the last_used time up-to-date.
clokep Apr 20, 2020
0fdb22c
Properly run the looping call in the background.
clokep Apr 20, 2020
3d9b3a8
Properly call get_session as async.
clokep Apr 20, 2020
b5fc1b9
Attempt to avoid clashes in session IDs.
clokep Apr 20, 2020
d9157c4
Properly await runInteraction calls.
clokep Apr 20, 2020
ae45238
Add the UIAuthStore to workers.
clokep Apr 21, 2020
9ac9c54
Remove unnecessary lambda
clokep Apr 21, 2020
1c861b8
Only expire old sessions on the master.
clokep Apr 21, 2020
0895971
Match the looping_call signature in unit tests.
clokep Apr 21, 2020
42c4bca
Fix mypy typing and run mypy on the new file.
clokep Apr 21, 2020
2d1bcad
Add a few return types.
clokep Apr 21, 2020
f2e5151
Prefix a number to the delta file.
clokep Apr 22, 2020
7091341
Clarify comments.
clokep Apr 22, 2020
ff14b66
Rename methods based on feedback.
clokep Apr 22, 2020
2a4a910
Avoid re-doing work.
clokep Apr 22, 2020
5a60f2d
Use JsonDict in some places.
clokep Apr 22, 2020
6b4a6df
Create a return type for UI auth session data.
clokep Apr 22, 2020
1a5101b
Ensure the session exists before marking a stage complete.
clokep Apr 22, 2020
264ef03
Use creation time instead of last updated time.
clokep Apr 22, 2020
8b5ef4a
Rename the identity parameter to result.
clokep Apr 22, 2020
f179c21
Separate the unsafe worker methods to a separate object.
clokep Apr 22, 2020
64c709b
Use _txn in method names.
clokep Apr 29, 2020
568a778
Document possible error states better.
clokep Apr 29, 2020
79c5be5
Review feedback.
clokep Apr 29, 2020
18b3494
Do not directly raise SynapseError.
clokep Apr 29, 2020
5340662
Use foreign keys to simplify logic.
clokep Apr 29, 2020
5f0bf19
Again fix idempotency of the registration API.
clokep Apr 29, 2020
eccb670
Fix lint.
clokep Apr 29, 2020
106dca9
Fix typo in docstring.
clokep Apr 30, 2020
64852bf
Raise a 400 error, not 404.
clokep Apr 30, 2020
ae27afd
Convert StoreErrors to SynapseErrors.
clokep Apr 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix postgresql issues.
  • Loading branch information
clokep committed Apr 22, 2020
commit e7a2db6fcb2af26d0671ed3ffa35ce96e2f126f0
8 changes: 6 additions & 2 deletions synapse/handlers/auth.py
Original file line number Diff line number Diff line change
@@ -289,10 +289,14 @@ async def check_auth(
if "session" in authdict:
sid = authdict["session"]

# Convert the URI and method to strings.
uri = request.uri.decode("utf-8")
method = request.uri.decode("utf-8")

# If there's no session ID, create a new session.
if not sid:
session_id = await self.store.create_session(
clientdict, request.uri, request.method, description
clientdict, uri, method, description
)

else:
@@ -316,7 +320,7 @@ async def check_auth(
# comparator based on the URI, method, and body (minus the auth dict)
# and storing it during the initial query. Subsequent queries ensure
# that this comparator has not changed.
comparator = (request.uri, request.method, clientdict)
comparator = (uri, method, clientdict)
if (session["uri"], session["method"], session["clientdict"]) != comparator:
raise SynapseError(
403,
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@

CREATE TABLE IF NOT EXISTS ui_auth_sessions(
session_id TEXT NOT NULL, -- The session ID passed to the client.
last_used BIGINT UNSIGNED NOT NULL, -- The last time this session was seen.
last_used BIGINT NOT NULL, -- The last time this session was seen.
serverdict TEXT NOT NULL, -- A JSON dictionary of arbitrary data added by Synapse.
clientdict TEXT NOT NULL, -- A JSON dictionary of arbitrary data from the client.
uri TEXT NOT NULL, -- The URI the UI authentication session is using.