Skip to content

Commit f51747a

Browse files
committed
Check validity of token owner
1 parent a7d8354 commit f51747a

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

crates/handlers/src/admin/call_context.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ use headers::{Authorization, authorization::Bearer};
1717
use hyper::StatusCode;
1818
use mas_axum_utils::record_error;
1919
use mas_data_model::{
20-
BoxClock, Session, TokenFormatError, TokenType, User, personal::session::PersonalSession,
20+
BoxClock, Session, TokenFormatError, TokenType, User,
21+
personal::session::{PersonalSession, PersonalSessionOwner},
2122
};
2223
use mas_storage::{BoxRepository, RepositoryError};
2324
use oauth2_types::scope::Scope;
@@ -222,6 +223,23 @@ where
222223
return Err(Rejection::TokenExpired);
223224
}
224225

226+
// Check the validity of the owner of the personal session
227+
match session.owner {
228+
PersonalSessionOwner::User(owner_user_id) => {
229+
let owner_user = repo
230+
.user()
231+
.lookup(owner_user_id)
232+
.await?
233+
.ok_or_else(|| Rejection::LoadUser(owner_user_id))?;
234+
if !owner_user.is_valid() {
235+
return Err(Rejection::UserLocked);
236+
}
237+
}
238+
PersonalSessionOwner::OAuth2Client(_) => {
239+
// nop: Client owners are always valid
240+
}
241+
}
242+
225243
// Record the activity on the session
226244
activity_tracker
227245
.record_personal_session(&clock, &session)

0 commit comments

Comments
 (0)