Commit Graph

48 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 2a9c384213 Update tests for randomly generated device IDs
Pin the device ID in tests by mocking the generation function.
And test said generation function.
2026-01-19 14:34:03 +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 b8fda8acdf lint 2026-01-19 13:04:31 +00:00
Andrew Morgan 41922415ba Update tests to run with MAS module variant
We now run the standard battery of tests with a MAS-enabled module. Some
minimal adjustment was needed to check MAS-specific outputs.
2026-01-16 19:21:38 +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 Morgan f117e745d5 Remove superfluous pin
The tox venv is what actually matters here.
2026-01-15 11:45:41 +00:00
Andrew Morgan d9c55189f4 Unbreak CI: pin prometheus-client dep 2026-01-15 11:40:58 +00:00
renovate[bot] c430d786e7 Pin dependencies (#63)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-11-19 20:09:05 +01:00
Michael Telatynski 9b57f46ccc Standardise lint/type scripts between modules/packages 2025-05-08 12:23:13 +01:00
Andrew Ferrazzutti dc94456ca2 Add line break in Synapse guest module README
so that the text after the numbered list appears in its own paragraph
2025-04-16 11:10:53 -04:00
Gaël Goinvic e068c9f60e copy cp to target image 2025-03-10 14:07:32 +01:00
Gaël Goinvic 774972817a add cp to synapse-guest-module image 2025-03-10 12:07:49 +01:00
Andrew Ferrazzutti 4890a7bd74 Add line break between README copyright lines 2025-03-06 11:50:29 -05:00
Andrew Ferrazzutti e66adfecba Fix minor typo in synapse guest module README 2025-03-06 11:24:08 -05:00
Andrew Ferrazzutti 8c11b576cb Include Python in static analysis job
Also refactor "yarn lint" of each module/package to run whatever lint
task is appropriate for it
2025-02-13 16:04:03 -05:00
Andrew Ferrazzutti ab17724182 Make "yarn test" always enable coverage 2025-02-13 11:37:53 -05:00
Andrew Ferrazzutti b429ae9c10 synapse guest module: generate coverage report 2025-02-12 16:01:24 -05:00
Andrew Ferrazzutti 504f35a65b synapse guest module: nitpick quote refactor 2025-02-12 15:42:59 -05: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 673bda4515 synapse guest module: set version to 1.0.0
as opposed to picking up from where upstream left off at 2.0.0.
(Note that CHANGELOG.md was already at 1.0.0.)
2025-02-10 15:37:11 -05:00
Andrew Ferrazzutti 65d75c3779 Split out vitest from general tests 2025-02-07 12:02:19 -05:00
Andrew Ferrazzutti 2e58691093 run_in_venv: skip unnecessary env reinstallation 2025-02-07 11:36:10 -05:00
Andrew Ferrazzutti d0f1835175 run_in_venv: allow setting Python version 2025-02-07 10:53:54 -05:00
Andrew Ferrazzutti 2f8c31797b Make run_in_venv POSIX compliant (not just Bash) 2025-02-07 10:06:01 -05:00
Andrew Ferrazzutti c6c04d399f Convert run_in_venv Node script to Bash
The work done by the script is simpler to achieve in Bash, and avoids a
potential mis-parsing of arguments.
2025-02-07 08:38:58 -05:00
Andrew Ferrazzutti 5fe56e414c synapse guest module: use minimal container image 2025-02-06 10:28:36 -05:00
Andrew Ferrazzutti 88f578a51b synapse guest module: replace ADD with COPY 2025-02-06 10:23:37 -05:00
Andrew Ferrazzutti 88f098a2f7 Use CI job for only synapse guest module
Also remove jobs for E2E & changeset, which aren't set up in this repo
2025-02-05 15:21:53 -05:00
Andrew Ferrazzutti 124068294e synapse guest module: add to yarn workspaces
This fixes a false-positive "missing file" check in knip
2025-02-05 10:48:53 -05:00
Andrew Ferrazzutti b36705c4f4 Run lint-staged on all new files 2025-02-05 09:43:21 -05:00
Andrew Ferrazzutti caabc37519 synapse guest module: update org name & docs 2025-02-05 08:18:25 -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