Keep track of user_ips and monthly_active_users when delegating auth#16672
Keep track of user_ips and monthly_active_users when delegating auth#16672DMRobertson merged 12 commits intodevelopfrom
user_ips and monthly_active_users when delegating auth#16672Conversation
|
As a side-effect, this should reinstate MAU limiting in Synapse. Endpoints like /login and /register that are handled by the auth service won't be limited though. |
sandhose
left a comment
There was a problem hiding this comment.
Tested locally and it indeeds tracks MAU.
I although noticed that the special __oidc_admin virtual user gets tracked, which shouldn't be the case.
| ) | ||
| await self.store.insert_client_ip( | ||
| user_id=requester.authenticated_entity, | ||
| access_token=access_token, |
There was a problem hiding this comment.
A few things to note here.
-
OIDC access tokens have a limited lifetime and refresh. This means we'll end up writing a row once per refresh period per active device to this table. I'm not super keen on this. But stale entries automatically get cleaned up from this table, so it might not be the worst thing in the world.
-
We wondered if this might affect the user retention metrics. AFAICS these are based on the
user_daily_visitstable, which is updated with this query:synapse/synapse/storage/databases/main/metrics.py
Lines 403 to 417 in 736199b
That query groups on (user_ips.user_id, user_ips.device_id), so can handle the same device appearing twice in the user_ips table. (As indeed it may, for e.g. a mobile client moving between wifi and mobile internet connections.) So we haven't written a bug here.
- Both of these concerns would also affect people using non-OIDC refreshing access tokens. It's just that nobody really used them(?) after they got specced.
4 . A cleaner approach would be to change this table to be keyed off (user, device, ip) instead of today's (user, access_token, ip). But I'm punting that for the future.
Good spot, thank you. 45ffd5f should fix. |
sandhose
left a comment
There was a problem hiding this comment.
Tried locally, worked as expected
This was present in Synapse's "internal" auth, but was not available when delegating auth to an OIDC provider until now.
I haven't tested this end-to-end. But there isn't any variation in the way we write to the DB. So I'm fairly confident this should work. (Unless I'm missing something @sandhose?)