swap encoding key implementation, need to not-arcode it if possible next.

This commit is contained in:
2025-09-24 04:22:45 +02:00
parent af03bd4e31
commit f315ffbe7b
3 changed files with 29 additions and 11 deletions

View File

@@ -1,4 +1,6 @@
use axum::serve;
use axum::Extension;
use jsonwebtoken::{DecodingKey, EncodingKey};
use tokio::net::TcpListener;
mod utils;
@@ -8,7 +10,7 @@ use r2d2::{Pool};
use r2d2_sqlite::SqliteConnectionManager;
use crate::utils::db_pool::{HotelPool,AppState};
use routes::create_router;
use crate::utils::auth::JwtKeys;
@@ -25,11 +27,18 @@ async fn main() -> std::io::Result<()> {
let state = AppState {
hotel_pools,
logs_pool,
jwt_secret: "your_jwt_secret_key s".to_string(), // better: load from env var
//jwt_secret: "your_jwt_secret_key s".to_string(), // better: load from env var
};
let jwt_secret = "your_jwt_secret_key".to_string();
let jwt_keys = JwtKeys {
encoding: EncodingKey::from_secret(jwt_secret.as_ref()),
decoding: DecodingKey::from_secret(jwt_secret.as_ref()),
};
let app = create_router(state)
.layer(Extension(jwt_keys));
let app = create_router(state);
let listener = TcpListener::bind("0.0.0.0:3000").await?;
serve(listener, app).into_future().await?;
Ok(())