1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-31 09:24:31 +03:00

Record user agents on OAuth 2.0 and compat sessions (#2386)

* Record user agents on OAuth 2.0 and compat sessions

* Add tests for recording user agent in sessions
This commit is contained in:
Quentin Gliech
2024-02-22 10:01:32 +01:00
committed by GitHub
parent 7de4be219b
commit f171d76dc5
17 changed files with 303 additions and 13 deletions

View File

@ -252,6 +252,22 @@ pub trait CompatSessionRepository: Send + Sync {
&mut self,
activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>,
) -> Result<(), Self::Error>;
/// Record the user agent of a compat session
///
/// # Parameters
///
/// * `compat_session`: The compat session to record the user agent for
/// * `user_agent`: The user agent to record
///
/// # Errors
///
/// Returns [`Self::Error`] if the underlying repository fails
async fn record_user_agent(
&mut self,
compat_session: CompatSession,
user_agent: String,
) -> Result<CompatSession, Self::Error>;
}
repository_impl!(CompatSessionRepository:
@ -285,4 +301,10 @@ repository_impl!(CompatSessionRepository:
&mut self,
activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>,
) -> Result<(), Self::Error>;
async fn record_user_agent(
&mut self,
compat_session: CompatSession,
user_agent: String,
) -> Result<CompatSession, Self::Error>;
);

View File

@ -286,6 +286,18 @@ pub trait OAuth2SessionRepository: Send + Sync {
&mut self,
activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>,
) -> Result<(), Self::Error>;
/// Record the user agent of a [`Session`]
///
/// # Parameters
///
/// * `session`: The [`Session`] to record the user agent for
/// * `user_agent`: The user agent to record
async fn record_user_agent(
&mut self,
session: Session,
user_agent: String,
) -> Result<Session, Self::Error>;
}
repository_impl!(OAuth2SessionRepository:
@ -333,4 +345,10 @@ repository_impl!(OAuth2SessionRepository:
&mut self,
activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>,
) -> Result<(), Self::Error>;
async fn record_user_agent(
&mut self,
session: Session,
user_agent: String,
) -> Result<Session, Self::Error>;
);