swap encoding key implementation, need to not-arcode it if possible next.
This commit is contained in:
15
src/main.rs
15
src/main.rs
@@ -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(())
|
||||
|
||||
Reference in New Issue
Block a user