This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Implement MSC3231: Token authenticated registration #10142
Merged
anoadragon453
merged 54 commits into
matrix-org:develop
from
govynnus:token-registration
Aug 21, 2021
Merged
Changes from 11 commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
5856f81
Hard-coded token authenticated registration
govynnus 5f21580
Create registration_tokens table
govynnus 2b8726c
Check in database to validate registration token
govynnus 5b1ec0b
Increment `completed` when registration token used
govynnus 15e5769
Rename total_uses to uses_allowed
govynnus 9c502b0
Improve unit tests
govynnus e7754a9
Increment pending while registration in progress
govynnus ef05a6d
Add unit test for registration token expiry
govynnus 53f0e05
Fix config file related bits
govynnus 7883191
Run connected database ops in same transaction
govynnus 1debc22
Fix some formatting problems
govynnus 6ac376d
Test `completed` is empty when auth should fail
govynnus dfa8fec
Override type of simple_select_one_txn
govynnus c89d786
Raise error if token changes during UIA
govynnus e7bd00a
Add validity checking endpoint
govynnus d6704fd
Use AuthHandler methods for accessing UIA session
govynnus 003e67d
Rate limit validity checking endpoint
govynnus 3c51680
Use LoginError rather than SynapseError in checker
govynnus af90be7
Add fallback
govynnus 1552b70
Docs for currently non-existent admin API
govynnus 4df4a6e
Implement admin API
govynnus 6901eee
Move admin api docs to correct location
govynnus 93f752d
Include general API shape in docstrings
govynnus b2bf3ac
More input validation when creating and updating
govynnus 5d5bdef
Add space to SQL query
govynnus b61c7f6
Fix SQL query for invalid tokens
govynnus e7495e6
Decrease pending when UIA session expires
govynnus 39d24d2
Add type to test argument
govynnus 70cc9d2
Add test for session expiry with deleted token
govynnus 09f6572
Use f-strings rather than str.format()
govynnus 36adec4
Update docs/usage/administration/admin_api/registration_tokens.md
govynnus 7e539f5
Use more descriptive name
govynnus 1cf29c9
Return 200 when nothing to update
govynnus 7f9efcd
Remove unneeded else and add missing f
govynnus e9435f8
Run linter
govynnus f6e4831
Add uses_allowed to updating example in docstring
govynnus 7208760
Add return values to docstring
govynnus 47b8837
Add docstring to validity checking endpoint
govynnus b76099e
Move functions into RegistrationWorkerStore
govynnus 86bbc24
Merge branch 'develop' into token-registration
govynnus c6cb80b
Add link to admin API docs in config file
govynnus ba22ffd
Move table creation SQL to latest delta
govynnus c775dce
Add changelog entry
govynnus f327b29
Regenerate sample config
govynnus c6bcae2
Move table creation sql to actual newest delta
govynnus 01a74da
Avoid integrity error when creating tokens
govynnus 5bfc707
Fix docs, comments and variable names
govynnus b5608c3
Try again if generated token already exists
govynnus bf28876
Let validity checking endpoint be used by workers
govynnus 2e59dda
Document usage of `null` when updating tokens
govynnus df0077d
Merge remote-tracking branch 'upstream/develop' into token-registration
govynnus 54867ef
Simplify retrying of token generation
govynnus 20b566c
Small additions to admin api documentation
govynnus 04b237a
Update synapse/storage/databases/main/registration.py
anoadragon453 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
synapse/storage/schema/main/delta/59/999create_registration_tokens.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* Copyright 2021 Callum Brown | ||
anoadragon453 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| CREATE TABLE IF NOT EXISTS registration_tokens( | ||
| token TEXT NOT NULL, -- The token that can be used for authentication. | ||
| uses_allowed INT, -- The total number of times this token can be used. NULL if no limit. | ||
| pending INT NOT NULL, -- The number of in progress registrations using this token. | ||
| completed INT NOT NULL, -- The number of times this token has been used to complete a registration. | ||
| expiry_time BIGINT, -- The latest time this token will be valid (epoch time in milliseconds). NULL if token doesn't expire. | ||
| UNIQUE (token) | ||
| ); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.