Commit Graph

20 Commits

Author SHA1 Message Date
Andrew Morgan a4173bb1dd expires_in -> expires_in_sec + docstring 2026-01-23 14:55:17 +00:00
Andrew Morgan e0304c627b created_at -> created_at_sec 2026-01-23 14:41:06 +00:00
Andrew Morgan 2e71abdfda Add user_id field to guest_module_mas_users
Currently unused, but may be useful in future.
2026-01-23 14:38:19 +00:00
Andrew Morgan 514c6957f7 Log MXID and MAS ID when registering guest user 2026-01-23 14:02:00 +00:00
Andrew Morgan f88a280b8b Correct typo in comment 2026-01-23 13:52:19 +00:00
Andrew Morgan 3f53333448 Return the correct device ID
Turns out the client needs to generate it, and pass it as a scope. Clever!
2026-01-19 13:56:57 +00:00
Andrew Morgan 55ca2be0f6 Update unit tests to check MAS config, deactivation works 2026-01-16 19:20:35 +00:00
Andrew Morgan 2aa16a8222 lint 2026-01-16 18:49:43 +00:00
Andrew Morgan d45fd845b3 Add client_secret_filepath option
To allow supplying the `client_secret` in a file, instead of directly in the configuration. I've found that ESS prefer this method in the past, so the entire config does not need to be a secret.
2026-01-16 18:05:33 +00:00
Andrew Morgan 9f4ca6f7e6 Store registered users in a namespaced table, deactivate upon expiry
To deactivate users, we need their `actor_user_id` (MAS-specific). I don't believe there's a way to get this from Synapse. So, we store user's detailed in a namespaced table upon registering them, along with the creation timestamp, and deactivate them once they're considered expired.
2026-01-16 18:05:33 +00:00
Andrew Morgan d0e17ae274 Add the ability to deactivate users in the MAS client
As we won't be able to deactivate them using the Synapse module API
2026-01-16 18:05:33 +00:00
Andrew Morgan 801d28f3ca Create a personal session on MAS
In order to get an access token for a user, one needs to create a personal session on MAS.

We now do so, and extract the access token and device ID from the response.

TODO: We're handing back the MAS user ID as the device ID. Is that correct?
2026-01-16 18:05:33 +00:00
Andrew Morgan 9c2b9463a9 Wire the new MasAdminClient in
If `mas` is defined in the config, then use it to create users instead
of Synapse's module API.
2026-01-16 18:05:33 +00:00
Andrew Morgan 04414e06a9 Add MasAdminClient class
A class to request OAuth2 tokens from MAS, and create users using them.

Requires data from the config options we defined.
2026-01-16 18:05:33 +00:00
Andrew Morgan 1cb888e4e7 Configuration options for MAS
In order to create and manage users with MAS enabled, we'll need to
reach out to the MAS admin API. We can do so automatically by requesting
an admin-enabled token, assuming a matching client has been configured
on the MAS side.

Add some config options for the guest module (OAuth2 client) side.
2026-01-16 18:05:33 +00:00
Andrew Ferrazzutti 523758cbea synapse guest module: move license files
Move them into the module folder so that they'll be properly included
in distribution builds, such as when installing this module via pip.

Also reword copyright headers to refer to the project root instead of
the repository root, which isn't included in distribution builds.
2025-02-12 15:42:18 -05:00
Andrew Ferrazzutti 3e107737aa Remove "(C)" from copyright lines
for consistency with other copyright lines, and readability
2025-02-11 14:00:07 -05:00
Andrew Ferrazzutti 226b89f846 synapse guest module: change license
Set license to multi-license of AGPL + Element Commercial, and add
associated license files to the repository root.

This does not add a notice of "This file includes modifications" to any
files because they were only moved and relicensed, but otherwise
unmodified.

The exception is run_in_venv.sh, which is a rewrite of upstream's
run_in_venv.js and thus lacks the original copyright entirely.
2025-02-10 15:39:48 -05:00
Andrew Ferrazzutti ffb5fdaa30 synapse guest module: update copyright 2025-02-05 08:18:25 -05:00
Andrew Ferrazzutti 386073c0e8 Merge commit '01af446be7cbd63b38f2fe35c2c9a25fac4fdef8' as 'modules/restricted-guests/synapse' 2025-02-04 09:21:06 -05:00