You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-07-29 22:01:14 +03:00
Save the session activity in the database
This commit is contained in:
@ -12,7 +12,10 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::net::IpAddr;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use chrono::{DateTime, Utc};
|
||||
use mas_data_model::{CompatSession, CompatSsoLogin, Device, User};
|
||||
use rand_core::RngCore;
|
||||
use ulid::Ulid;
|
||||
@ -236,6 +239,21 @@ pub trait CompatSessionRepository: Send + Sync {
|
||||
///
|
||||
/// Returns [`Self::Error`] if the underlying repository fails
|
||||
async fn count(&mut self, filter: CompatSessionFilter<'_>) -> Result<usize, Self::Error>;
|
||||
|
||||
/// Record a batch of [`Session`] activity
|
||||
///
|
||||
/// # Parameters
|
||||
///
|
||||
/// * `activity`: A list of tuples containing the session ID, the last
|
||||
/// activity timestamp and the IP address of the client
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns [`Self::Error`] if the underlying repository fails
|
||||
async fn record_batch_activity(
|
||||
&mut self,
|
||||
activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>,
|
||||
) -> Result<(), Self::Error>;
|
||||
}
|
||||
|
||||
repository_impl!(CompatSessionRepository:
|
||||
@ -269,4 +287,9 @@ repository_impl!(CompatSessionRepository:
|
||||
) -> Result<Page<(CompatSession, Option<CompatSsoLogin>)>, Self::Error>;
|
||||
|
||||
async fn count(&mut self, filter: CompatSessionFilter<'_>) -> Result<usize, Self::Error>;
|
||||
|
||||
async fn record_batch_activity(
|
||||
&mut self,
|
||||
activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>,
|
||||
) -> Result<(), Self::Error>;
|
||||
);
|
||||
|
@ -12,7 +12,10 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::net::IpAddr;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use chrono::{DateTime, Utc};
|
||||
use mas_data_model::{BrowserSession, Client, Session, User};
|
||||
use oauth2_types::scope::Scope;
|
||||
use rand_core::RngCore;
|
||||
@ -268,6 +271,21 @@ pub trait OAuth2SessionRepository: Send + Sync {
|
||||
///
|
||||
/// Returns [`Self::Error`] if the underlying repository fails
|
||||
async fn count(&mut self, filter: OAuth2SessionFilter<'_>) -> Result<usize, Self::Error>;
|
||||
|
||||
/// Record a batch of [`Session`] activity
|
||||
///
|
||||
/// # Parameters
|
||||
///
|
||||
/// * `activity`: A list of tuples containing the session ID, the last
|
||||
/// activity timestamp and the IP address of the client
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns [`Self::Error`] if the underlying repository fails
|
||||
async fn record_batch_activity(
|
||||
&mut self,
|
||||
activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>,
|
||||
) -> Result<(), Self::Error>;
|
||||
}
|
||||
|
||||
repository_impl!(OAuth2SessionRepository:
|
||||
@ -310,4 +328,9 @@ repository_impl!(OAuth2SessionRepository:
|
||||
) -> Result<Page<Session>, Self::Error>;
|
||||
|
||||
async fn count(&mut self, filter: OAuth2SessionFilter<'_>) -> Result<usize, Self::Error>;
|
||||
|
||||
async fn record_batch_activity(
|
||||
&mut self,
|
||||
activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>,
|
||||
) -> Result<(), Self::Error>;
|
||||
);
|
||||
|
@ -12,7 +12,10 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::net::IpAddr;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use chrono::{DateTime, Utc};
|
||||
use mas_data_model::{
|
||||
Authentication, BrowserSession, Password, UpstreamOAuthAuthorizationSession, User,
|
||||
};
|
||||
@ -227,6 +230,21 @@ pub trait BrowserSessionRepository: Send + Sync {
|
||||
&mut self,
|
||||
user_session: &BrowserSession,
|
||||
) -> Result<Option<Authentication>, Self::Error>;
|
||||
|
||||
/// Record a batch of [`Session`] activity
|
||||
///
|
||||
/// # Parameters
|
||||
///
|
||||
/// * `activity`: A list of tuples containing the session ID, the last
|
||||
/// activity timestamp and the IP address of the client
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns [`Self::Error`] if the underlying repository fails
|
||||
async fn record_batch_activity(
|
||||
&mut self,
|
||||
activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>,
|
||||
) -> Result<(), Self::Error>;
|
||||
}
|
||||
|
||||
repository_impl!(BrowserSessionRepository:
|
||||
@ -272,4 +290,9 @@ repository_impl!(BrowserSessionRepository:
|
||||
&mut self,
|
||||
user_session: &BrowserSession,
|
||||
) -> Result<Option<Authentication>, Self::Error>;
|
||||
|
||||
async fn record_batch_activity(
|
||||
&mut self,
|
||||
activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>,
|
||||
) -> Result<(), Self::Error>;
|
||||
);
|
||||
|
Reference in New Issue
Block a user