@@ -174,6 +174,8 @@ mod session {
174174 runtime_generation : SandboxGenerationId ,
175175 auth_epoch : CredentialEpoch ,
176176 component : SessionComponent ,
177+ #[ serde( default , skip_serializing_if = "BTreeMap::is_empty" ) ]
178+ resource_binding : BTreeMap < String , String > ,
177179 }
178180
179181 /// Durable identity shared by every short-lived token for one sandbox runtime.
@@ -675,6 +677,32 @@ mod session {
675677 identity : & SandboxRuntimeIdentity ,
676678 token_id : Uuid ,
677679 issued_at : i64 ,
680+ ) -> Result < MintedSessionToken , SessionJwtError > {
681+ self . mint_bound ( profile, identity, token_id, issued_at, BTreeMap :: new ( ) )
682+ }
683+
684+ /// Authorize initial assignment to an exact driver-provisioned runtime.
685+ pub fn mint_bound_sandbox_token (
686+ & self ,
687+ identity : & SandboxRuntimeIdentity ,
688+ resource_binding : BTreeMap < String , String > ,
689+ ) -> Result < MintedSessionToken , SessionJwtError > {
690+ self . mint_bound (
691+ SessionTokenProfile :: Sandbox ,
692+ identity,
693+ Uuid :: new_v4 ( ) ,
694+ self . clock . now_unix_seconds ( ) ,
695+ resource_binding,
696+ )
697+ }
698+
699+ fn mint_bound (
700+ & self ,
701+ profile : SessionTokenProfile ,
702+ identity : & SandboxRuntimeIdentity ,
703+ token_id : Uuid ,
704+ issued_at : i64 ,
705+ resource_binding : BTreeMap < String , String > ,
678706 ) -> Result < MintedSessionToken , SessionJwtError > {
679707 let expires_at = self . ttl . map_or ( 0 , |ttl| {
680708 issued_at. saturating_add ( i64:: try_from ( ttl. as_secs ( ) ) . unwrap_or ( i64:: MAX ) )
@@ -690,6 +718,7 @@ mod session {
690718 runtime_generation : identity. runtime_generation . clone ( ) ,
691719 auth_epoch : identity. auth_epoch ,
692720 component : SessionComponent :: OpenShellSupervisor ,
721+ resource_binding,
693722 } ;
694723 let mut header = Header :: new ( Algorithm :: EdDSA ) ;
695724 header. kid = Some ( self . key_id . clone ( ) ) ;
@@ -733,6 +762,8 @@ mod session {
733762
734763 #[ derive( Clone , Debug , PartialEq , Eq ) ]
735764 pub struct AuthenticatedSandboxSession {
765+ /// Signed physical-runtime binding, required for initial late assignment.
766+ pub resource_binding : BTreeMap < String , String > ,
736767 pub sandbox_id : SandboxId ,
737768 pub runtime_generation : SandboxGenerationId ,
738769 pub auth_epoch : CredentialEpoch ,
@@ -829,6 +860,7 @@ mod session {
829860 }
830861 }
831862 Ok ( AuthenticatedSandboxSession {
863+ resource_binding : claims. resource_binding ,
832864 sandbox_id : claims. sandbox_id ,
833865 runtime_generation : claims. runtime_generation ,
834866 auth_epoch : claims. auth_epoch ,
0 commit comments