This repository was archived by the owner on Jan 2, 2026. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,24 @@ impl<E: Endpoint> Endpoint for AuthenticationMiddlewareImpl<E> {
3131
3232 let token_store = req. data :: < TokenStore > ( ) . unwrap ( ) ;
3333 let hashed_user_token = hash_auth_token ( auth) ;
34+ // We first get the serial_number of the cert that this token is associated with...
35+ let user_serial_number = token_store
36+ . get_token_serial_number ( & hashed_user_token)
37+ . await
38+ . map_err ( |_| poem:: error:: Error :: from_status ( StatusCode :: INTERNAL_SERVER_ERROR ) ) ?
39+ . ok_or ( poem:: error:: Error :: from_status ( StatusCode :: UNAUTHORIZED ) ) ?;
40+ // ...then we check, if this token has not been invalidated
41+ let valid_token_in_db_for_user = token_store
42+ . get_token_userid ( & user_serial_number)
43+ . await
44+ . map_err ( |_| poem:: error:: Error :: from_status ( StatusCode :: INTERNAL_SERVER_ERROR ) ) ?
45+ . ok_or ( poem:: error:: Error :: from_status ( StatusCode :: UNAUTHORIZED ) ) ?;
46+ // And then we compare the two!
47+ if valid_token_in_db_for_user. token == hashed_user_token. into ( ) {
48+ // TODO: Get actor uaid, set in request
49+ } else {
50+ return Err ( poem:: error:: Error :: from_status ( StatusCode :: UNAUTHORIZED ) ) ;
51+ }
3452
3553 self . ep . call ( req) . await
3654 }
You can’t perform that action at this time.
0 commit comments