| 94 | } |
| 95 | |
| 96 | pub fn complete_local_jwt_config() -> Result<Option<GatewayJwtConfig>> { |
| 97 | let dir = default_local_tls_dir()?; |
| 98 | let paths = LocalJwtPaths::resolve(&dir); |
| 99 | let present = paths.files().iter().filter(|path| path.is_file()).count(); |
| 100 | match present { |
| 101 | 0 => Ok(None), |
| 102 | 3 => Ok(Some(GatewayJwtConfig { |
| 103 | signing_key_path: paths.signing_key, |
| 104 | public_key_path: paths.public_key, |
| 105 | kid_path: paths.kid, |
| 106 | gateway_id: "openshell".to_string(), |
| 107 | ttl_secs: 0, |
| 108 | })), |
| 109 | _ => Err(miette::miette!( |
| 110 | "partial local sandbox JWT state in {}: expected jwt/signing.pem, jwt/public.pem, and jwt/kid", |
| 111 | dir.display() |
| 112 | )), |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | #[cfg(test)] |
| 117 | mod tests { |