|
10 | 10 | #![deny(missing_docs)] |
11 | 11 |
|
12 | 12 | use std::net::SocketAddr; |
| 13 | +use std::sync::Arc; |
13 | 14 |
|
14 | 15 | use tokio::net::TcpListener; |
15 | 16 | use tokio::signal::unix::SignalKind; |
16 | 17 |
|
17 | 18 | use hyper::server::conn::http1; |
18 | 19 | use hyper_util::rt::TokioIo; |
19 | 20 |
|
20 | | -use crate::vss_service::VssService; |
21 | 21 | use api::auth::{Authorizer, NoopAuthorizer}; |
22 | 22 | use api::kv_store::KvStore; |
23 | | -use auth_impls::{DecodingKey, JWTAuthorizer}; |
| 23 | +use auth_impls::JWTAuthorizer; |
24 | 24 | use impls::postgres_store::{Certificate, PostgresPlaintextBackend, PostgresTlsBackend}; |
25 | | -use std::sync::Arc; |
| 25 | +use util::config::{Config, ServerConfig}; |
| 26 | +use vss_service::VssService; |
26 | 27 |
|
27 | 28 | mod util; |
28 | 29 | mod vss_service; |
29 | 30 |
|
30 | | -use util::config::{Config, ServerConfig}; |
31 | | - |
32 | 31 | fn main() { |
33 | 32 | let args: Vec<String> = std::env::args().collect(); |
34 | 33 | if args.len() != 2 { |
@@ -72,15 +71,15 @@ fn main() { |
72 | 71 | let rsa_pem = |
73 | 72 | std::env::var("VSS_JWT_RSA_PEM").ok().or(jwt_auth_config.map(|config| config.rsa_pem)); |
74 | 73 | let authorizer: Arc<dyn Authorizer> = if let Some(pem) = rsa_pem { |
75 | | - let rsa_public_key = match DecodingKey::from_rsa_pem(pem.as_bytes()) { |
76 | | - Ok(p) => p, |
| 74 | + let authorizer = match JWTAuthorizer::new(pem.as_str()).await { |
| 75 | + Ok(auth) => auth, |
77 | 76 | Err(e) => { |
78 | 77 | println!("Failed to parse RSA public key file: {}", e); |
79 | 78 | std::process::exit(-1); |
80 | 79 | }, |
81 | 80 | }; |
82 | 81 | println!("Configured JWT authorizer with RSA public key"); |
83 | | - Arc::new(JWTAuthorizer::new(rsa_public_key).await) |
| 82 | + Arc::new(authorizer) |
84 | 83 | } else { |
85 | 84 | println!("No JWT authentication method configured"); |
86 | 85 | Arc::new(NoopAuthorizer {}) |
|
0 commit comments