chore: refactor token authenticator - #93
Conversation
PR SummaryHigh Risk Overview Config now uses typed Pydantic models (JWT/OIDC/OAuth/ePA) with validators for secrets, JWKs, algorithms, and auth backends. HTTP auth helpers move into TokenAuthenticator is split up: web resources move to dedicated modules, and OAuth login is broken into JWT validation, introspection, and finish-login helpers. OpenID provider metadata parsing also moves onto a Pydantic model. Reviewed by Cursor Bugbot for commit 627183c. Bugbot is set up for automated code reviews on this repo. Configure here. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #93 +/- ##
==========================================
+ Coverage 72.05% 73.90% +1.85%
==========================================
Files 5 9 +4
Lines 773 801 +28
Branches 144 143 -1
==========================================
+ Hits 557 592 +35
+ Misses 157 150 -7
Partials 59 59
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
|
I think the title should really be more specific. The branch name for example has a lot more info already. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed: Wrong allowed_client_ids type
- Changed allowed_client_ids from str | None to list[str] | None so documented YAML lists validate and client_id membership checks work.
- ✅ Fixed: ePa path fields too narrow
- Typed EPaConfig.localpart_path and displayname_path as Path | None so list-form paths validate like OAuth configs.
Or push these changes by commenting:
@cursor push b023de2517
Preview (b023de2517)
diff --git a/synapse_token_authenticator/config.py b/synapse_token_authenticator/config.py
--- a/synapse_token_authenticator/config.py
+++ b/synapse_token_authenticator/config.py
@@ -89,7 +89,7 @@
client_secret: str
project_id: str
organization_id: str
- allowed_client_ids: str | None = None
+ allowed_client_ids: list[str] | None = None
allow_registration: bool = False
@@ -185,8 +185,8 @@
jwk_set: JwkSetField = None
jwk_file: str | None = None
jwks_endpoint: str | None = None
- localpart_path: str | None = None
- displayname_path: str | None = None
+ localpart_path: Path | None = None
+ displayname_path: Path | None = None
lowercase_localpart: bool = False
@model_validator(mode="after")You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 627183c. Configure here.
| client_secret: str | ||
| project_id: str | ||
| organization_id: str | ||
| allowed_client_ids: str | None = None |
There was a problem hiding this comment.
Wrong allowed_client_ids type
High Severity
Issue: allowed_client_ids is typed as str | None, so Pydantic rejects the documented list form and breaks OIDC config load. Membership checks and the README both treat it as a client-id list.
Fix: Type it as list[str] | None.
allowed_client_ids: list[str] | None = NoneReviewed by Cursor Bugbot for commit 627183c. Configure here.
| jwk_file: str | None = None | ||
| jwks_endpoint: str | None = None | ||
| localpart_path: str | None = None | ||
| displayname_path: str | None = None |
There was a problem hiding this comment.
ePa path fields too narrow
Medium Severity
Issue: EPaConfig.localpart_path and displayname_path are typed as str | None, but docs and get_path_in_dict support Path (str | list[str]). List-form paths that used to load now fail Pydantic validation.
Fix: Use Path | None, same as the OAuth validation configs.
localpart_path: Path | None = None
displayname_path: Path | None = NoneReviewed by Cursor Bugbot for commit 627183c. Configure here.



SYN-77
SYN-95