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

Implement MSC3231: Token authenticated registration #10142

Merged
merged 54 commits into from
Aug 21, 2021

Conversation

govynnus
Copy link
Contributor

@govynnus govynnus commented Jun 8, 2021

Signed-off-by: Callum Brown callum@calcuode.com

This is part of my GSoC project implementing MSC3231.

Status:

  • Works with a list of hard-coded tokens
  • Checks against tokens stored in the database
  • Validity checking endpoint
  • Fallback
  • Admin API for managing tokens

Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
Copy link
Member

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

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

Looking excellent so far, nice work! I've dropped a myriad of comments all over the place, and I realise the PR is still in a draft state. In any case, let me know if any of them are unclear or don't make sense at this point 🙂

synapse/config/registration.py Outdated Show resolved Hide resolved
synapse/config/registration.py Outdated Show resolved Hide resolved
synapse/config/registration.py Outdated Show resolved Hide resolved
synapse/handlers/ui_auth/checkers.py Outdated Show resolved Hide resolved
synapse/storage/databases/main/registration.py Outdated Show resolved Hide resolved
tests/rest/client/v2_alpha/test_register.py Outdated Show resolved Hide resolved
tests/rest/client/v2_alpha/test_register.py Outdated Show resolved Hide resolved
synapse/handlers/ui_auth/checkers.py Outdated Show resolved Hide resolved
synapse/handlers/ui_auth/checkers.py Show resolved Hide resolved
Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
rather than using storage methods directly.
Also use UIAuthSessionDataConstants.

Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
So error fields are merged into UIA response.
(Failures are due to authentication)

Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
Copy link
Member

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

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

Apologies for taking a while to get back to this. I left a review mid-way and only now realised.

synapse/rest/client/v2_alpha/auth.py Outdated Show resolved Hide resolved
synapse/rest/client/v2_alpha/auth.py Outdated Show resolved Hide resolved
docs/SUMMARY.md Outdated Show resolved Hide resolved
Copy link
Member

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

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

Broadly this is looking excellent. I've got just a few notes below, but overall this looks solid.

synapse/rest/admin/__init__.py Outdated Show resolved Hide resolved
synapse/rest/admin/registration_tokens.py Outdated Show resolved Hide resolved
synapse/rest/admin/registration_tokens.py Outdated Show resolved Hide resolved
synapse/rest/admin/registration_tokens.py Outdated Show resolved Hide resolved
synapse/rest/admin/registration_tokens.py Outdated Show resolved Hide resolved
synapse/storage/databases/main/registration.py Outdated Show resolved Hide resolved
synapse/storage/databases/main/registration.py Outdated Show resolved Hide resolved
synapse/rest/admin/registration_tokens.py Show resolved Hide resolved
tests/rest/admin/test_registration_tokens.py Outdated Show resolved Hide resolved
synapse/storage/databases/main/registration.py Outdated Show resolved Hide resolved
@govynnus govynnus marked this pull request as ready for review August 19, 2021 16:36
Copy link
Member

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

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

Sorry, note that 63 is actually the latest schema delta, rather than 62. It was raised in this commit. It didn't involve a migration though, which could be confusing if one is just looking at the list of schema delta directories.

I'll need to take another overarching look at this tomorrow - but it's looking very close! I'd also at least try using it from a worker setup manually, by creating a generic worker alongside the main process that handles client traffic. Then, attempt to register through it using a token.

I need to try it again, but during my last review I was unable to call the verify endpoint on the worker (I got back an "Unrecognised request" error). So it looks like the endpoint wasn't mounted on the worker, but didn't look at deeper than that yet.

synapse/storage/databases/main/registration.py Outdated Show resolved Hide resolved
Signed-off-by: Callum Brown <callum@calcuode.com>
Check if token already exists before trying to create it

Signed-off-by: Callum Brown <callum@calcuode.com>
Copy link
Member

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

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

A few remaining bits and pieces, but otherwise this is looking ready to go!

synapse/rest/admin/registration_tokens.py Show resolved Hide resolved
synapse/rest/admin/registration_tokens.py Show resolved Hide resolved
docs/usage/administration/admin_api/registration_tokens.md Outdated Show resolved Hide resolved
synapse/rest/admin/registration_tokens.py Outdated Show resolved Hide resolved
synapse/rest/client/register.py Show resolved Hide resolved
synapse/handlers/ui_auth/__init__.py Outdated Show resolved Hide resolved
synapse/handlers/ui_auth/checkers.py Outdated Show resolved Hide resolved
synapse/rest/admin/registration_tokens.py Outdated Show resolved Hide resolved
synapse/rest/admin/registration_tokens.py Outdated Show resolved Hide resolved
govynnus and others added 5 commits August 20, 2021 13:27
Signed-off-by: Callum Brown <callum@calcuode.com>

Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
Copy link
Member

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

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

lgtm other than the outstanding comments!

docs/usage/administration/admin_api/registration_tokens.md Outdated Show resolved Hide resolved
synapse/rest/admin/registration_tokens.py Show resolved Hide resolved
Signed-off-by: Callum Brown <callum@calcuode.com>
Signed-off-by: Callum Brown <callum@calcuode.com>
Copy link
Member

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

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

Nice method of testing token generation collision.

This LGTM!

synapse/storage/databases/main/registration.py Outdated Show resolved Hide resolved
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants