File tree Expand file tree Collapse file tree 3 files changed +18
-15
lines changed
db-queries/src/db/datastore Expand file tree Collapse file tree 3 files changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -161,15 +161,17 @@ impl DataStore {
161
161
pub async fn silo_user_sessions_delete (
162
162
& self ,
163
163
opctx : & OpContext ,
164
- user : & authz:: SiloUser ,
164
+ authn_list : & authz:: SiloUserAuthnList ,
165
165
) -> Result < ( ) , Error > {
166
- // TODO: check for silo admin on opctx
167
- // TODO: ensure this can only be used in current silo
168
- // TODO: think about dueling admins problem
166
+ // authz policy enforces that the opctx actor is a silo admin on the
167
+ // target user's own silo in particular
168
+ opctx . authorize ( authz :: Action :: Modify , authn_list ) . await ? ;
169
169
170
170
use nexus_db_schema:: schema:: console_session;
171
171
diesel:: delete ( console_session:: table)
172
- . filter ( console_session:: silo_user_id. eq ( user. id ( ) ) )
172
+ . filter (
173
+ console_session:: silo_user_id. eq ( authn_list. silo_user ( ) . id ( ) ) ,
174
+ )
173
175
. execute_async ( & * self . pool_connection_authorized ( opctx) . await ?)
174
176
. await
175
177
. map_err ( |e| public_error_from_diesel ( e, ErrorHandler :: Server ) )
Original file line number Diff line number Diff line change @@ -246,15 +246,18 @@ impl DataStore {
246
246
pub async fn silo_user_tokens_delete (
247
247
& self ,
248
248
opctx : & OpContext ,
249
- user : & authz:: SiloUser ,
249
+ authn_list : & authz:: SiloUserAuthnList ,
250
250
) -> Result < ( ) , Error > {
251
- // TODO: check for silo admin on opctx
252
- // TODO: ensure this can only be used in current silo
253
- // TODO: think about dueling admins problem
251
+ // authz policy enforces that the opctx actor is a silo admin on the
252
+ // target user's own silo in particular
253
+ opctx . authorize ( authz :: Action :: Modify , authn_list ) . await ? ;
254
254
255
255
use nexus_db_schema:: schema:: device_access_token;
256
256
diesel:: delete ( device_access_token:: table)
257
- . filter ( device_access_token:: silo_user_id. eq ( user. id ( ) ) )
257
+ . filter (
258
+ device_access_token:: silo_user_id
259
+ . eq ( authn_list. silo_user ( ) . id ( ) ) ,
260
+ )
258
261
. execute_async ( & * self . pool_connection_authorized ( opctx) . await ?)
259
262
. await
260
263
. map_err ( |e| public_error_from_diesel ( e, ErrorHandler :: Server ) )
Original file line number Diff line number Diff line change @@ -324,17 +324,15 @@ impl super::Nexus {
324
324
. fetch ( )
325
325
. await ?;
326
326
327
- let authz_user_sessions =
327
+ let authz_authn_list =
328
328
authz:: SiloUserAuthnList :: new ( authz_silo_user. clone ( ) ) ;
329
- // TODO: would rather do this check in the datastore functions
330
- opctx. authorize ( authz:: Action :: Modify , & authz_user_sessions) . await ?;
331
329
332
330
self . datastore ( )
333
- . silo_user_tokens_delete ( opctx, & authz_silo_user )
331
+ . silo_user_tokens_delete ( opctx, & authz_authn_list )
334
332
. await ?;
335
333
336
334
self . datastore ( )
337
- . silo_user_sessions_delete ( opctx, & authz_silo_user )
335
+ . silo_user_sessions_delete ( opctx, & authz_authn_list )
338
336
. await ?;
339
337
340
338
Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments