@@ -13,15 +13,15 @@ use chrono::{DateTime, Duration, Utc};
1313use dropshot:: HttpError ;
1414use http:: HeaderValue ;
1515use nexus_types:: authn:: cookies:: parse_cookies;
16- use omicron_uuid_kinds:: { ConsoleSessionKind , TypedUuid } ;
16+ use omicron_uuid_kinds:: ConsoleSessionUuid ;
1717use slog:: debug;
1818use uuid:: Uuid ;
1919
2020// many parts of the implementation will reference this OWASP guide
2121// https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html
2222
2323pub trait Session {
24- fn id ( & self ) -> TypedUuid < ConsoleSessionKind > ;
24+ fn id ( & self ) -> ConsoleSessionUuid ;
2525 fn silo_user_id ( & self ) -> Uuid ;
2626 fn silo_id ( & self ) -> Uuid ;
2727 fn time_last_used ( & self ) -> DateTime < Utc > ;
@@ -41,14 +41,11 @@ pub trait SessionStore {
4141 /// Extend session by updating time_last_used to now
4242 async fn session_update_last_used (
4343 & self ,
44- id : TypedUuid < ConsoleSessionKind > ,
44+ id : ConsoleSessionUuid ,
4545 ) -> Option < Self :: SessionModel > ;
4646
4747 /// Mark session expired
48- async fn session_expire (
49- & self ,
50- id : TypedUuid < ConsoleSessionKind > ,
51- ) -> Option < ( ) > ;
48+ async fn session_expire ( & self , id : ConsoleSessionUuid ) -> Option < ( ) > ;
5249
5350 /// Maximum time session can remain idle before expiring
5451 fn session_idle_timeout ( & self ) -> Duration ;
@@ -204,8 +201,7 @@ mod test {
204201 use async_trait:: async_trait;
205202 use chrono:: { DateTime , Duration , Utc } ;
206203 use http;
207- use omicron_uuid_kinds:: ConsoleSessionKind ;
208- use omicron_uuid_kinds:: TypedUuid ;
204+ use omicron_uuid_kinds:: ConsoleSessionUuid ;
209205 use slog;
210206 use std:: sync:: Mutex ;
211207 use uuid:: Uuid ;
@@ -218,7 +214,7 @@ mod test {
218214
219215 #[ derive( Clone ) ]
220216 struct FakeSession {
221- id : TypedUuid < ConsoleSessionKind > ,
217+ id : ConsoleSessionUuid ,
222218 token : String ,
223219 silo_user_id : Uuid ,
224220 silo_id : Uuid ,
@@ -227,7 +223,7 @@ mod test {
227223 }
228224
229225 impl Session for FakeSession {
230- fn id ( & self ) -> TypedUuid < ConsoleSessionKind > {
226+ fn id ( & self ) -> ConsoleSessionUuid {
231227 self . id
232228 }
233229 fn silo_user_id ( & self ) -> Uuid {
@@ -262,7 +258,7 @@ mod test {
262258
263259 async fn session_update_last_used (
264260 & self ,
265- id : TypedUuid < ConsoleSessionKind > ,
261+ id : ConsoleSessionUuid ,
266262 ) -> Option < Self :: SessionModel > {
267263 let mut sessions = self . sessions . lock ( ) . unwrap ( ) ;
268264 if let Some ( pos) = sessions. iter ( ) . position ( |s| s. id == id) {
@@ -277,10 +273,7 @@ mod test {
277273 }
278274 }
279275
280- async fn session_expire (
281- & self ,
282- id : TypedUuid < ConsoleSessionKind > ,
283- ) -> Option < ( ) > {
276+ async fn session_expire ( & self , id : ConsoleSessionUuid ) -> Option < ( ) > {
284277 let mut sessions = self . sessions . lock ( ) . unwrap ( ) ;
285278 sessions. retain ( |s| s. id != id) ;
286279 Some ( ( ) )
@@ -336,7 +329,7 @@ mod test {
336329 async fn test_expired_cookie_idle ( ) {
337330 let context = TestServerContext {
338331 sessions : Mutex :: new ( vec ! [ FakeSession {
339- id: TypedUuid :: new_v4( ) ,
332+ id: ConsoleSessionUuid :: new_v4( ) ,
340333 token: "abc" . to_string( ) ,
341334 silo_user_id: Uuid :: new_v4( ) ,
342335 silo_id: Uuid :: new_v4( ) ,
@@ -362,7 +355,7 @@ mod test {
362355 async fn test_expired_cookie_absolute ( ) {
363356 let context = TestServerContext {
364357 sessions : Mutex :: new ( vec ! [ FakeSession {
365- id: TypedUuid :: new_v4( ) ,
358+ id: ConsoleSessionUuid :: new_v4( ) ,
366359 token: "abc" . to_string( ) ,
367360 silo_user_id: Uuid :: new_v4( ) ,
368361 silo_id: Uuid :: new_v4( ) ,
@@ -389,7 +382,7 @@ mod test {
389382 let time_last_used = Utc :: now ( ) - Duration :: seconds ( 5 ) ;
390383 let context = TestServerContext {
391384 sessions : Mutex :: new ( vec ! [ FakeSession {
392- id: TypedUuid :: new_v4( ) ,
385+ id: ConsoleSessionUuid :: new_v4( ) ,
393386 token: "abc" . to_string( ) ,
394387 silo_user_id: Uuid :: new_v4( ) ,
395388 silo_id: Uuid :: new_v4( ) ,
0 commit comments