diff --git a/src/auth/jwt.rs b/src/auth/jwt.rs index d9cf108..a1fc5aa 100644 --- a/src/auth/jwt.rs +++ b/src/auth/jwt.rs @@ -5,10 +5,14 @@ use rand::{thread_rng, Rng}; use serde::{Deserialize, Serialize}; use sha2::Sha256; -use crate::{ - errors::{RbError, RbResult}, - RbJwtConf, -}; +#[derive(Debug, Deserialize, Serialize, Clone)] +pub struct JwtConf { + key: String, + refresh_token_size: usize, + refresh_token_expire: i64, +} + +use crate::errors::{RbError, RbResult}; #[derive(Serialize)] #[serde(rename_all = "camelCase")] @@ -26,7 +30,7 @@ pub struct Claims { } pub fn generate_jwt_token( - jwt: &RbJwtConf, + jwt: &JwtConf, id: uuid::Uuid, username: String, is_admin: bool, @@ -64,7 +68,7 @@ pub fn generate_jwt_token( pub fn refresh_token( conn: &PgConnection, - jwt: &RbJwtConf, + jwt: &JwtConf, refresh_token: &str, ) -> RbResult { let token_bytes = diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..7c52178 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,8 @@ +use serde::{Serialize, Deserialize} + +#[derive(Debug, Deserialize, Serialize, Clone)] +pub struct RbJwtConf { + key: String, + refresh_token_size: usize, + refresh_token_expire: i64, +} diff --git a/src/lib.rs b/src/lib.rs index f34c28a..c62fb40 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ pub mod auth; +pub mod config; pub mod errors; pub mod guards;