-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add config option to selectively delegate different operations to account threepid delegates #7611
Conversation
e21805f
to
c0b5c18
Compare
Hmm, I think I've identified a bug with this approach which is that we currently don't seem to store 3PIDs that have been registered with a delegated config, so password resets happening on Synapse might not work. I'll investigate this. |
a7bcc0c
to
1b82724
Compare
On the wording, we chose "bind" for binding a 3pid to an IS, and "add" for adding a 3pid to a user's account on a HS. |
This is waiting for some feedback, @anoadragon453 said on #synapse-dev:matrix.org:
|
Hrmm, we have access to the session ID. I wonder if we could store metadata about a UI Auth session and then read it later. |
@anoadragon453 Maybe the following are useful? synapse/synapse/handlers/auth.py Lines 452 to 482 in d0a43d4
|
@clokep Ooo, generic, I love it, thank you! |
It does persist things into a database though so consider:
|
@clokep I'm envsioning just "register" and "password_reset", so should be fine 😁 |
As I will be checking this value during UI Auth, I need to classify the ui auth type while creating the session. As such, it doesn't look like I should use I initially thought about using My next thought is to add an I think this works well, though a slight niggle is backwards compatibility for all the existing sessions in that table. I could technically check the session We could also just wipe all ongoing UI auth sessions for an update. What do you think? |
Isn't this basically what the method + URI is used for? In terms of modifying this table, I think we've generally considered it OK to be backwards incompatible. It is not ideal but the user impact is fairly low in this case. |
@clokep hmm, this could work, but may be slightly iffy with URI's that include variables like:
|
Also uh oh: synapse/synapse/handlers/auth.py Lines 305 to 306 in 5d64fef
|
Already fixed: #7689 |
eb06fb0
to
91f1132
Compare
And update sample_config.yaml.
So we initially had a variable called `threepid_behaviour_email` attached to the config object which was an instance of ThreepidBehaviour, the latter having three possible values - REMOTE, LOCAL or OFF. The rest of the codebase would basically use this to determine whether to try and do email stuff itself, or to delegate the operation to a third-party service (an identity server usually). Well, now that the sysadmin can choose whether to do this for adding a threepid vs. password reset, we now need two ThreepidBehaviour values. The code can then check either the one for adding a threepid, or the one for password reset, depending on what it's doing. This commit is breaking that up and also cleaning up the email template loading code such that templates are only loaded if necessary i.e. we'll be sending emails with that template. Oh, we also introduce ThreepidService, which is another enum like ThreepidBehaviour, but this one specifies which service you're validating (whether it's password reset or adding a threepid). I chose and enum again instead of a straight string as then we can easily avoid typos.
Now we start using the different `threepid_behaviour_email.*` variants for different account/registration operations.
7bc0549
to
6cedf93
Compare
Some additional refactoring for: * docstrings * lessening config option polling
We have a problem whereby during threepid (email) validation we need to know whether to handle the validation token ourselves or via an account threepid delegate. Earlier we could just check whether we were delegating email or not, but now that email can be either Synapse or a threepid delegate depending on which service (adding threepids, password reset) the validation is for, we need a way to find that out. So we store that information along with the validation session in the DB.
Store the type of service so that we can reference it during token validation.
The changes to identity.py are just threading the service through to `start_or_continue_validation_session`.
If a service is specified, check with our new `delegate_for` option for whether this should be handled by an account threepid delegate, or remotely. If there isn't a threepid session found with the details given by the client, assume that this is a remote session. Also modify the `is_enabled` method to check both `add_threepid` and `password_reset` services. If any of them are configured, then this checker is enabled. And again, refactor a little bit by pulling config option polling into the constructor.
6cedf93
to
38c755f
Compare
38c755f
to
667d075
Compare
This is now ready for review. @clokep I ended up attaching a |
667d075
to
e446977
Compare
We've decided to go with matrix-org/synapse-dinsic#51 as a solution to DINUM's problem instead. Additionally, this will hopefully allow for the deprecation of |
Add aregistration_only
configuration flag toaccount_threepid_delegates
to allow only delegating 3PID registration, and letting Synapse handle password resets.This PR adds a
delegate_for
config option toaccount_threepid_delegates
which allows you to decide which services should be delegated to configured account threepid delegates, and which should remain as operations for the local Synapse to handle.For context:
account_threepid_delegates
are intended to allow Synapse to ask a third-party process (usually an identity service) to handle sending emails/text messages for it. More information is available in the config option comment.The reason this PR is so chunky is due to some refactoring around the complicated configuration handling of the
account_threepid_delegates
config option. This could probably be taken out into a separate PR, though it's a little fiddly.I've tried my best to make this easy to review by commit, with explanations in each commit message.
~anoa