You've already forked authentication-service
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:
@ -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`]
|
||||
|
Reference in New Issue
Block a user