@@ -84,7 +84,7 @@ async fn gateway_discovery_handler(
8484 uri : Uri ,
8585) -> impl IntoResponse {
8686 gateway_discovery_response (
87- state. sandbox_jwt_authenticator . as_deref ( ) ,
87+ state. extension_jwt_issuer . as_deref ( ) ,
8888 & document_base_url ( & headers, & uri) ,
8989 )
9090}
@@ -113,10 +113,10 @@ fn document_base_url(headers: &HeaderMap, uri: &Uri) -> Option<String> {
113113}
114114
115115fn gateway_discovery_response (
116- authenticator : Option < & crate :: auth:: sandbox_jwt:: SandboxJwtAuthenticator > ,
116+ issuer : Option < & crate :: auth:: sandbox_jwt:: ExtensionJwtIssuer > ,
117117 base_url : & Option < String > ,
118118) -> axum:: response:: Response {
119- let Some ( authenticator ) = authenticator else {
119+ let Some ( issuer ) = issuer else {
120120 return StatusCode :: NOT_FOUND . into_response ( ) ;
121121 } ;
122122 let Some ( base_url) = base_url else {
@@ -126,7 +126,7 @@ fn gateway_discovery_response(
126126 return StatusCode :: BAD_REQUEST . into_response ( ) ;
127127 } ;
128128 Json ( serde_json:: json!( {
129- "issuer" : authenticator . issuer( ) ,
129+ "issuer" : issuer . issuer( ) ,
130130 "jwks_uri" : format!( "{base_url}/.well-known/jwks.json" ) ,
131131 "id_token_signing_alg_values_supported" : [ "EdDSA" ] ,
132132 "response_types_supported" : [ "id_token" ] ,
@@ -145,15 +145,15 @@ fn gateway_discovery_response(
145145/// gateway from which an integration bootstraps this document; integrations
146146/// then cache keys by `kid` and refresh when an unfamiliar `kid` appears.
147147async fn gateway_jwks_handler ( State ( state) : State < Arc < ServerState > > ) -> impl IntoResponse {
148- gateway_jwks_response ( state. sandbox_jwt_authenticator . as_deref ( ) )
148+ gateway_jwks_response ( state. extension_jwt_issuer . as_deref ( ) )
149149}
150150
151151fn gateway_jwks_response (
152- authenticator : Option < & crate :: auth:: sandbox_jwt:: SandboxJwtAuthenticator > ,
152+ issuer : Option < & crate :: auth:: sandbox_jwt:: ExtensionJwtIssuer > ,
153153) -> axum:: response:: Response {
154- authenticator . map_or_else (
154+ issuer . map_or_else (
155155 || StatusCode :: NOT_FOUND . into_response ( ) ,
156- |authenticator | Json ( authenticator . jwks ( ) ) . into_response ( ) ,
156+ |issuer | Json ( issuer . jwks ( ) ) . into_response ( ) ,
157157 )
158158}
159159
@@ -571,6 +571,7 @@ mod tests {
571571 use super :: * ;
572572 use axum:: body:: to_bytes;
573573 use openshell_bootstrap:: jwt:: generate_jwt_key;
574+ use std:: time:: Duration ;
574575
575576 #[ test]
576577 fn extract_cookie_finds_value ( ) {
@@ -687,16 +688,18 @@ mod tests {
687688 #[ test]
688689 fn jwks_response_publishes_configured_gateway_key ( ) {
689690 let material = generate_jwt_key ( ) . expect ( "key" ) ;
690- let authenticator = crate :: auth:: sandbox_jwt:: SandboxJwtAuthenticator :: from_pem (
691+ let issuer = crate :: auth:: sandbox_jwt:: ExtensionJwtIssuer :: from_pem (
692+ material. signing_key_pem . as_bytes ( ) ,
691693 material. public_key_pem . as_bytes ( ) ,
692694 material. kid . clone ( ) ,
693695 "gateway-a" ,
696+ Duration :: from_mins ( 15 ) ,
694697 )
695- . expect ( "authenticator " ) ;
698+ . expect ( "issuer " ) ;
696699
697- let response = gateway_jwks_response ( Some ( & authenticator ) ) ;
700+ let response = gateway_jwks_response ( Some ( & issuer ) ) ;
698701 assert_eq ! ( response. status( ) , StatusCode :: OK ) ;
699- let key = & authenticator . jwks ( ) . keys [ 0 ] ;
702+ let key = & issuer . jwks ( ) . keys [ 0 ] ;
700703 assert_eq ! ( key. kid, material. kid) ;
701704 assert_eq ! ( key. kty, "OKP" ) ;
702705 assert_eq ! ( key. crv, "Ed25519" ) ;
@@ -709,21 +712,23 @@ mod tests {
709712 assert_eq ! ( gateway_jwks_response( None ) . status( ) , StatusCode :: NOT_FOUND ) ;
710713 }
711714
712- fn test_authenticator ( ) -> crate :: auth:: sandbox_jwt:: SandboxJwtAuthenticator {
715+ fn test_issuer ( ) -> crate :: auth:: sandbox_jwt:: ExtensionJwtIssuer {
713716 let material = generate_jwt_key ( ) . expect ( "key" ) ;
714- crate :: auth:: sandbox_jwt:: SandboxJwtAuthenticator :: from_pem (
717+ crate :: auth:: sandbox_jwt:: ExtensionJwtIssuer :: from_pem (
718+ material. signing_key_pem . as_bytes ( ) ,
715719 material. public_key_pem . as_bytes ( ) ,
716720 material. kid ,
717721 "gateway-a" ,
722+ Duration :: from_mins ( 15 ) ,
718723 )
719- . expect ( "authenticator " )
724+ . expect ( "issuer " )
720725 }
721726
722727 #[ tokio:: test]
723728 async fn discovery_document_advertises_issuer_identity_and_absolute_jwks_uri ( ) {
724- let authenticator = test_authenticator ( ) ;
729+ let issuer = test_issuer ( ) ;
725730 let response = gateway_discovery_response (
726- Some ( & authenticator ) ,
731+ Some ( & issuer ) ,
727732 & Some ( "https://gateway.example:8443" . to_string ( ) ) ,
728733 ) ;
729734 assert_eq ! ( response. status( ) , StatusCode :: OK ) ;
@@ -755,7 +760,7 @@ mod tests {
755760 // A relative jwks_uri could be resolved against the wrong origin, so
756761 // refuse to emit a document rather than emit an ambiguous one.
757762 assert_eq ! (
758- gateway_discovery_response( Some ( & test_authenticator ( ) ) , & None ) . status( ) ,
763+ gateway_discovery_response( Some ( & test_issuer ( ) ) , & None ) . status( ) ,
759764 StatusCode :: BAD_REQUEST
760765 ) ;
761766 }
0 commit comments