icarus_envy -> sienvy
This commit is contained in:
Generated
+10
-10
@@ -1038,15 +1038,6 @@ dependencies = [
|
|||||||
"tower-service",
|
"tower-service",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "icarus_envy"
|
|
||||||
version = "0.8.0"
|
|
||||||
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_envy.git?tag=v0.8.0#349056db6e6254c2eb778fdcdd1d64de339f1309"
|
|
||||||
dependencies = [
|
|
||||||
"const_format",
|
|
||||||
"dotenvy",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icarus_meta"
|
name = "icarus_meta"
|
||||||
version = "0.6.1"
|
version = "0.6.1"
|
||||||
@@ -2129,6 +2120,15 @@ version = "2.0.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sienvy"
|
||||||
|
version = "0.8.0"
|
||||||
|
source = "git+ssh://git@git.kundeng.us/phoenix/sienvy.git?tag=v0.8.0-main-d06c8fdf49-006#d06c8fdf49920cf4d8ba0487c20f5bdc851c36de"
|
||||||
|
dependencies = [
|
||||||
|
"const_format",
|
||||||
|
"dotenvy",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "signal-hook-registry"
|
name = "signal-hook-registry"
|
||||||
version = "1.4.8"
|
version = "1.4.8"
|
||||||
@@ -2190,7 +2190,6 @@ dependencies = [
|
|||||||
"axum-extra",
|
"axum-extra",
|
||||||
"common-multipart-rfc7578",
|
"common-multipart-rfc7578",
|
||||||
"futures",
|
"futures",
|
||||||
"icarus_envy",
|
|
||||||
"icarus_meta",
|
"icarus_meta",
|
||||||
"icarus_models",
|
"icarus_models",
|
||||||
"josekit",
|
"josekit",
|
||||||
@@ -2199,6 +2198,7 @@ dependencies = [
|
|||||||
"openssl",
|
"openssl",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"sienvy",
|
||||||
"sqlx",
|
"sqlx",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"time",
|
"time",
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ utoipa = { version = "5.5.0", features = ["axum_extras"] }
|
|||||||
utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] }
|
utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] }
|
||||||
icarus_meta = { git = "ssh://git@git.kundeng.us/phoenix/icarus_meta.git", tag = "v0.6.1" }
|
icarus_meta = { git = "ssh://git@git.kundeng.us/phoenix/icarus_meta.git", tag = "v0.6.1" }
|
||||||
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.11.3" }
|
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.11.3" }
|
||||||
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.8.0" }
|
sienvy = { git = "ssh://git@git.kundeng.us/phoenix/sienvy.git", tag = "v0.8.0-main-d06c8fdf49-006" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
common-multipart-rfc7578 = { version = "0.7.0" }
|
common-multipart-rfc7578 = { version = "0.7.0" }
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ pub async fn auth<B>(
|
|||||||
(StatusCode::UNAUTHORIZED, Json(json_error))
|
(StatusCode::UNAUTHORIZED, Json(json_error))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let secret_key = icarus_envy::environment::get_secret_main_key().value;
|
let secret_key = sienvy::environment::get_secret_main_key().value;
|
||||||
|
|
||||||
let mut validation = Validation::new(jsonwebtoken::Algorithm::HS256);
|
let mut validation = Validation::new(jsonwebtoken::Algorithm::HS256);
|
||||||
validation.set_audience(&["icarus"]); // Must match exactly what's in the token
|
validation.set_audience(&["icarus"]); // Must match exactly what's in the token
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ pub mod endpoint {
|
|||||||
let song_id = payload.song_id;
|
let song_id = payload.song_id;
|
||||||
match crate::repo::song::get_song(&pool, &song_id).await {
|
match crate::repo::song::get_song(&pool, &song_id).await {
|
||||||
Ok(song) => {
|
Ok(song) => {
|
||||||
let directory = icarus_envy::environment::get_root_directory().value;
|
let directory = sienvy::environment::get_root_directory().value;
|
||||||
let file_type =
|
let file_type =
|
||||||
icarus_meta::detection::coverart::file_type_from_data(&data).unwrap();
|
icarus_meta::detection::coverart::file_type_from_data(&data).unwrap();
|
||||||
let coverart_type = if file_type.file_type
|
let coverart_type = if file_type.file_type
|
||||||
|
|||||||
+1
-1
@@ -139,7 +139,7 @@ pub mod endpoint {
|
|||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
song.directory = icarus_envy::environment::get_root_directory().value;
|
song.directory = sienvy::environment::get_root_directory().value;
|
||||||
|
|
||||||
match repo_queue::song::get_data(&pool, &payload.song_queue_id).await {
|
match repo_queue::song::get_data(&pool, &payload.song_queue_id).await {
|
||||||
Ok(data) => {
|
Ok(data) => {
|
||||||
|
|||||||
+14
-19
@@ -28,20 +28,18 @@ mod cors {
|
|||||||
axum::http::Method::POST,
|
axum::http::Method::POST,
|
||||||
axum::http::Method::PUT,
|
axum::http::Method::PUT,
|
||||||
axum::http::Method::DELETE,
|
axum::http::Method::DELETE,
|
||||||
]) // Specify allowed methods:cite[2]
|
])
|
||||||
.allow_headers([
|
.allow_headers([
|
||||||
axum::http::header::CONTENT_TYPE,
|
axum::http::header::CONTENT_TYPE,
|
||||||
axum::http::header::AUTHORIZATION,
|
axum::http::header::AUTHORIZATION,
|
||||||
]) // Specify allowed headers:cite[2]
|
])
|
||||||
.allow_credentials(true) // If you need to send cookies or authentication headers:cite[2]
|
.allow_credentials(true)
|
||||||
.max_age(std::time::Duration::from_secs(3600)); // Cache the preflight response for 1 hour:cite[2]
|
.max_age(std::time::Duration::from_secs(3600)); // Cache the preflight response for 1 hour:cite[2]
|
||||||
|
|
||||||
// Dynamically set the allowed origin based on the environment
|
match std::env::var(sienvy::keys::APP_ENV).as_deref() {
|
||||||
match std::env::var(icarus_envy::keys::APP_ENV).as_deref() {
|
|
||||||
Ok("production") => {
|
Ok("production") => {
|
||||||
// In production, allow only your specific, trusted origins
|
let allowed_origins_env = sienvy::environment::get_allowed_origins();
|
||||||
let allowed_origins_env = icarus_envy::environment::get_allowed_origins();
|
match sienvy::utility::delimitize(&allowed_origins_env) {
|
||||||
match icarus_envy::utility::delimitize(&allowed_origins_env) {
|
|
||||||
Ok(alwd) => {
|
Ok(alwd) => {
|
||||||
let allowed_origins: Vec<axum::http::HeaderValue> = alwd
|
let allowed_origins: Vec<axum::http::HeaderValue> = alwd
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@@ -55,17 +53,14 @@ mod cors {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => cors.allow_origin(vec![
|
||||||
// Development (default): Allow localhost origins
|
"http://localhost:8000".parse().unwrap(),
|
||||||
cors.allow_origin(vec![
|
"http://127.0.0.1:8000".parse().unwrap(),
|
||||||
"http://localhost:8000".parse().unwrap(),
|
"http://localhost:8001".parse().unwrap(),
|
||||||
"http://127.0.0.1:8000".parse().unwrap(),
|
"http://127.0.0.1:8001".parse().unwrap(),
|
||||||
"http://localhost:8001".parse().unwrap(),
|
"http://localhost:4200".parse().unwrap(),
|
||||||
"http://127.0.0.1:8001".parse().unwrap(),
|
"http://127.0.0.1:4200".parse().unwrap(),
|
||||||
"http://localhost:4200".parse().unwrap(),
|
]),
|
||||||
"http://127.0.0.1:4200".parse().unwrap(),
|
|
||||||
])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ pub mod 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().value;
|
let database_url = sienvy::environment::get_db_url().value;
|
||||||
println!("Database url: {database_url}");
|
println!("Database url: {database_url}");
|
||||||
|
|
||||||
PgPoolOptions::new()
|
PgPoolOptions::new()
|
||||||
|
|||||||
+4
-4
@@ -38,7 +38,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().value;
|
let tm_db_url = sienvy::environment::get_db_url().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
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,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().value;
|
let db_url = sienvy::environment::get_db_url().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
|
||||||
}
|
}
|
||||||
@@ -83,7 +83,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().value;
|
let database_url = sienvy::environment::get_db_url().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" {
|
||||||
@@ -157,7 +157,7 @@ mod tests {
|
|||||||
pub const TEST_USER_ID: uuid::Uuid = uuid::uuid!("cc938368-615a-4694-b2ca-6e122fa31c52");
|
pub const TEST_USER_ID: uuid::Uuid = uuid::uuid!("cc938368-615a-4694-b2ca-6e122fa31c52");
|
||||||
|
|
||||||
pub async fn test_token() -> Result<String, josekit::JoseError> {
|
pub async fn test_token() -> Result<String, josekit::JoseError> {
|
||||||
let key: String = icarus_envy::environment::get_secret_main_key().value;
|
let key: String = sienvy::environment::get_secret_main_key().value;
|
||||||
let (message, issuer, audience) = token_fields();
|
let (message, issuer, audience) = token_fields();
|
||||||
|
|
||||||
let token_resource = icarus_models::token::TokenResource {
|
let token_resource = icarus_models::token::TokenResource {
|
||||||
|
|||||||
Reference in New Issue
Block a user