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

storage: Allow filtering oauth2 sessions by scope

This commit is contained in:
Quentin Gliech
2023-08-29 14:26:09 +02:00
parent 1826120f10
commit d7abdccc0a
4 changed files with 75 additions and 7 deletions

View File

@ -42,6 +42,7 @@ pub struct OAuth2SessionFilter<'a> {
user: Option<&'a User>,
client: Option<&'a Client>,
state: Option<OAuth2SessionState>,
scope: Option<&'a Scope>,
}
impl<'a> OAuth2SessionFilter<'a> {
@ -102,6 +103,21 @@ impl<'a> OAuth2SessionFilter<'a> {
pub fn state(&self) -> Option<OAuth2SessionState> {
self.state
}
/// Only return sessions with the given scope
#[must_use]
pub fn with_scope(mut self, scope: &'a Scope) -> Self {
self.scope = Some(scope);
self
}
/// Get the scope filter
///
/// Returns [`None`] if no scope filter was set
#[must_use]
pub fn scope(&self) -> Option<&Scope> {
self.scope
}
}
/// An [`OAuth2SessionRepository`] helps interacting with [`Session`]