Skip to content

Expand on_user_login callback parameters to include login IP and user-agent #19931

Description

@watermelon0339

Matrix Synapse currently provides the on_user_login callback in the Modules API:
on_user_login

This callback is extremely helpful for building custom login‑related logic, but the parameters it exposes are very limited. At the moment, module developers cannot access important contextual information about the login event, such as:

  • the login IP address
  • the user-agent / device information

Adding these fields would significantly expand what developers can build. For example, it would enable modules to implement security notifications similar to Telegram’s login alerts:

  • “Your account was just logged in from IP X.X.X.X using device Y.”
  • “If this wasn’t you, please remove the device in Settings.”

This is valuable for account security, auditing, and user transparency. It also enables custom risk scoring, anomaly detection, and device‑based policy enforcement.

Requested enhancement

Please extend the on_user_login callback signature to include additional parameters, such as:

  • login_ip: str
  • user_agent: str

Or alternatively, provide a structured LoginContext object containing these fields.

Why this matters

  • Enables security notifications and login anomaly detection
  • Allows modules to implement device‑aware policies
  • Improves user trust by providing visibility into account activity
  • Aligns Synapse with modern security practices used by major messaging platforms

Thank you for considering this enhancement. It would greatly improve the flexibility and security capabilities of Synapse modules.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions