icarus_envy version bump #65
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -759,7 +759,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icarus_auth"
|
name = "icarus_auth"
|
||||||
version = "0.5.1"
|
version = "0.5.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"argon2",
|
"argon2",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -786,8 +786,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icarus_envy"
|
name = "icarus_envy"
|
||||||
version = "0.3.5"
|
version = "0.4.1"
|
||||||
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_envy.git?tag=v0.3.5-main-86c5050c7b-006#86c5050c7bd5164bc6e773fc404195023f7f7aaa"
|
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_envy.git?tag=v0.4.1-main-8f0d123db5-006#8f0d123db51b18e9cc4ab5bd39a474ba99bd39c3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"const_format",
|
"const_format",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "icarus_auth"
|
name = "icarus_auth"
|
||||||
version = "0.5.1"
|
version = "0.5.2"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.88"
|
rust-version = "1.88"
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ josekit = { version = "0.10.3" }
|
|||||||
utoipa = { version = "5.4.0", features = ["axum_extras"] }
|
utoipa = { version = "5.4.0", features = ["axum_extras"] }
|
||||||
utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] }
|
utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] }
|
||||||
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.5.6" }
|
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.5.6" }
|
||||||
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.3.5-main-86c5050c7b-006" }
|
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.4.1-main-8f0d123db5-006" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
http-body-util = { version = "0.1.3" }
|
http-body-util = { version = "0.1.3" }
|
||||||
|
@@ -96,7 +96,7 @@ pub mod endpoint {
|
|||||||
Ok(user) => {
|
Ok(user) => {
|
||||||
if hashing::verify_password(&payload.password, user.password.clone()).unwrap() {
|
if hashing::verify_password(&payload.password, user.password.clone()).unwrap() {
|
||||||
// Create token
|
// Create token
|
||||||
let key = icarus_envy::environment::get_secret_key().await;
|
let key = icarus_envy::environment::get_secret_key().await.value;
|
||||||
let (token_literal, duration) =
|
let (token_literal, duration) =
|
||||||
token_stuff::create_token(&key, &user.id).unwrap();
|
token_stuff::create_token(&key, &user.id).unwrap();
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ pub mod endpoint {
|
|||||||
|
|
||||||
match repo::service::valid_passphrase(&pool, &payload.passphrase).await {
|
match repo::service::valid_passphrase(&pool, &payload.passphrase).await {
|
||||||
Ok((id, _passphrase, _date_created)) => {
|
Ok((id, _passphrase, _date_created)) => {
|
||||||
let key = icarus_envy::environment::get_secret_key().await;
|
let key = icarus_envy::environment::get_secret_key().await.value;
|
||||||
let (token_literal, duration) =
|
let (token_literal, duration) =
|
||||||
token_stuff::create_service_token(&key, &id).unwrap();
|
token_stuff::create_service_token(&key, &id).unwrap();
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ pub mod endpoint {
|
|||||||
axum::Json<response::refresh_token::Response>,
|
axum::Json<response::refresh_token::Response>,
|
||||||
) {
|
) {
|
||||||
let mut response = response::refresh_token::Response::default();
|
let mut response = response::refresh_token::Response::default();
|
||||||
let key = icarus_envy::environment::get_secret_key().await;
|
let key = icarus_envy::environment::get_secret_key().await.value;
|
||||||
|
|
||||||
if token_stuff::verify_token(&key, &payload.access_token) {
|
if token_stuff::verify_token(&key, &payload.access_token) {
|
||||||
let token_type = token_stuff::get_token_type(&key, &payload.access_token).unwrap();
|
let token_type = token_stuff::get_token_type(&key, &payload.access_token).unwrap();
|
||||||
|
@@ -16,7 +16,7 @@ pub mod db {
|
|||||||
use crate::connection_settings;
|
use crate::connection_settings;
|
||||||
|
|
||||||
pub async fn create_pool() -> Result<sqlx::PgPool, sqlx::Error> {
|
pub async fn create_pool() -> Result<sqlx::PgPool, sqlx::Error> {
|
||||||
let database_url = icarus_envy::environment::get_db_url().await;
|
let database_url = icarus_envy::environment::get_db_url().await.value;
|
||||||
println!("Database url: {database_url}");
|
println!("Database url: {database_url}");
|
||||||
|
|
||||||
PgPoolOptions::new()
|
PgPoolOptions::new()
|
||||||
|
22
src/main.rs
22
src/main.rs
@@ -66,12 +66,22 @@ mod init {
|
|||||||
match std::env::var(icarus_envy::keys::APP_ENV).as_deref() {
|
match std::env::var(icarus_envy::keys::APP_ENV).as_deref() {
|
||||||
Ok("production") => {
|
Ok("production") => {
|
||||||
let allowed_origins_env = icarus_envy::environment::get_allowed_origins().await;
|
let allowed_origins_env = icarus_envy::environment::get_allowed_origins().await;
|
||||||
let allowed_origins: Vec<axum::http::HeaderValue> = allowed_origins_env
|
match icarus_envy::utility::delimitize(&allowed_origins_env) {
|
||||||
.split(",")
|
Ok(alwd) => {
|
||||||
|
let allowed_origins: Vec<axum::http::HeaderValue> = alwd
|
||||||
|
.into_iter()
|
||||||
.map(|s| s.parse::<axum::http::HeaderValue>().unwrap())
|
.map(|s| s.parse::<axum::http::HeaderValue>().unwrap())
|
||||||
.collect();
|
.collect();
|
||||||
cors.allow_origin(allowed_origins)
|
cors.allow_origin(allowed_origins)
|
||||||
}
|
}
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!(
|
||||||
|
"Could not parse out allowed origins from env: Error: {err:?}"
|
||||||
|
);
|
||||||
|
std::process::exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// Development (default): Allow localhost origins
|
// Development (default): Allow localhost origins
|
||||||
cors.allow_origin(vec![
|
cors.allow_origin(vec![
|
||||||
@@ -148,7 +158,7 @@ mod tests {
|
|||||||
pub const LIMIT: usize = 6;
|
pub const LIMIT: usize = 6;
|
||||||
|
|
||||||
pub async fn get_pool() -> Result<sqlx::PgPool, sqlx::Error> {
|
pub async fn get_pool() -> Result<sqlx::PgPool, sqlx::Error> {
|
||||||
let tm_db_url = icarus_envy::environment::get_db_url().await;
|
let tm_db_url = icarus_envy::environment::get_db_url().await.value;
|
||||||
let tm_options = sqlx::postgres::PgConnectOptions::from_str(&tm_db_url).unwrap();
|
let tm_options = sqlx::postgres::PgConnectOptions::from_str(&tm_db_url).unwrap();
|
||||||
sqlx::PgPool::connect_with(tm_options).await
|
sqlx::PgPool::connect_with(tm_options).await
|
||||||
}
|
}
|
||||||
@@ -161,7 +171,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn connect_to_db(db_name: &str) -> Result<sqlx::PgPool, sqlx::Error> {
|
pub async fn connect_to_db(db_name: &str) -> Result<sqlx::PgPool, sqlx::Error> {
|
||||||
let db_url = icarus_envy::environment::get_db_url().await;
|
let db_url = icarus_envy::environment::get_db_url().await.value;
|
||||||
let options = sqlx::postgres::PgConnectOptions::from_str(&db_url)?.database(db_name);
|
let options = sqlx::postgres::PgConnectOptions::from_str(&db_url)?.database(db_name);
|
||||||
sqlx::PgPool::connect_with(options).await
|
sqlx::PgPool::connect_with(options).await
|
||||||
}
|
}
|
||||||
@@ -188,7 +198,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_database_name() -> Result<String, Box<dyn std::error::Error>> {
|
pub async fn get_database_name() -> Result<String, Box<dyn std::error::Error>> {
|
||||||
let database_url = icarus_envy::environment::get_db_url().await;
|
let database_url = icarus_envy::environment::get_db_url().await.value;
|
||||||
|
|
||||||
let parsed_url = url::Url::parse(&database_url)?;
|
let parsed_url = url::Url::parse(&database_url)?;
|
||||||
if parsed_url.scheme() == "postgres" || parsed_url.scheme() == "postgresql" {
|
if parsed_url.scheme() == "postgres" || parsed_url.scheme() == "postgresql" {
|
||||||
@@ -491,7 +501,7 @@ mod tests {
|
|||||||
|
|
||||||
let app = init::routes().await.layer(axum::Extension(pool));
|
let app = init::routes().await.layer(axum::Extension(pool));
|
||||||
let id = uuid::Uuid::parse_str("22f9c775-cce9-457a-a147-9dafbb801f61").unwrap();
|
let id = uuid::Uuid::parse_str("22f9c775-cce9-457a-a147-9dafbb801f61").unwrap();
|
||||||
let key = icarus_envy::environment::get_secret_key().await;
|
let key = icarus_envy::environment::get_secret_key().await.value;
|
||||||
|
|
||||||
match icarus_auth::token_stuff::create_service_token(&key, &id) {
|
match icarus_auth::token_stuff::create_service_token(&key, &id) {
|
||||||
Ok((token, _expire)) => {
|
Ok((token, _expire)) => {
|
||||||
|
@@ -124,7 +124,9 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_tokenize() {
|
fn test_tokenize() {
|
||||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||||
let special_key = rt.block_on(icarus_envy::environment::get_secret_key());
|
let special_key = rt
|
||||||
|
.block_on(icarus_envy::environment::get_secret_key())
|
||||||
|
.value;
|
||||||
let id = uuid::Uuid::new_v4();
|
let id = uuid::Uuid::new_v4();
|
||||||
match create_token(&special_key, &id) {
|
match create_token(&special_key, &id) {
|
||||||
Ok((token, _duration)) => {
|
Ok((token, _duration)) => {
|
||||||
|
Reference in New Issue
Block a user