Move the "email unsubscribe" resource, refactor the macaroon generator &...
Move the "email unsubscribe" resource, refactor the macaroon generator & simplify the access token verification logic. (#12986) This simplifies the access token verification logic by removing the `rights` parameter which was only ever used for the unsubscribe link in email notifications. The latter has been moved under the `/_synapse` namespace, since it is not a standard API. This also makes the email verification link more secure, by embedding the app_id and pushkey in the macaroon and verifying it. This prevents the user from tampering the query parameters of that unsubscribe link. Macaroon generation is refactored: - Centralised all macaroon generation and verification logic to the `MacaroonGenerator` - Moved to `synapse.utils` - Changed the constructor to require only a `Clock`, hostname, and a secret key (instead of a full `Homeserver`). - Added tests for all methods.
Showing
- changelog.d/12986.misc 1 addition, 0 deletionschangelog.d/12986.misc
- synapse/api/auth.py 45 additions, 148 deletionssynapse/api/auth.py
- synapse/config/key.py 4 additions, 2 deletionssynapse/config/key.py
- synapse/handlers/auth.py 1 addition, 108 deletionssynapse/handlers/auth.py
- synapse/handlers/oidc.py 8 additions, 123 deletionssynapse/handlers/oidc.py
- synapse/push/mailer.py 4 additions, 3 deletionssynapse/push/mailer.py
- synapse/rest/client/pusher.py 12 additions, 38 deletionssynapse/rest/client/pusher.py
- synapse/rest/synapse/client/__init__.py 3 additions, 0 deletionssynapse/rest/synapse/client/__init__.py
- synapse/rest/synapse/client/unsubscribe.py 64 additions, 0 deletionssynapse/rest/synapse/client/unsubscribe.py
- synapse/server.py 5 additions, 2 deletionssynapse/server.py
- synapse/util/macaroons.py 308 additions, 0 deletionssynapse/util/macaroons.py
- tests/api/test_auth.py 5 additions, 10 deletionstests/api/test_auth.py
- tests/handlers/test_oidc.py 3 additions, 4 deletionstests/handlers/test_oidc.py
- tests/test_state.py 9 additions, 2 deletionstests/test_state.py
- tests/unittest.py 1 addition, 1 deletiontests/unittest.py
- tests/util/test_macaroons.py 146 additions, 0 deletionstests/util/test_macaroons.py
Loading
Please register or sign in to comment