Compare commits

...
5 Commits
Author SHA1 Message Date
phoenix 7ea6a341c5 icarus_envy -> sienvy
soaricarus_auth Build / Rustfmt (pull_request) Successful in 1m39s
soaricarus_auth Build / Test Suite (pull_request) Failing after 2m5s
soaricarus_auth Build / Check (pull_request) Successful in 3m11s
soaricarus_auth Build / build (pull_request) Successful in 2m13s
soaricarus_auth Build / Clippy (pull_request) Successful in 3m53s
2026-07-17 16:12:07 -04:00
phoenix e039828755 Updating docker compose 2026-07-17 16:05:32 -04:00
phoenix 09c56a69f6 bump: uuid
soaricarus_auth Build / Test Suite (pull_request) Successful in 1m55s
soaricarus_auth Build / Rustfmt (pull_request) Successful in 27s
soaricarus_auth Build / Clippy (pull_request) Successful in 1m58s
soaricarus_auth Build / Check (pull_request) Successful in 5m46s
soaricarus_auth Build / build (pull_request) Successful in 2m28s
2026-07-17 16:03:47 -04:00
phoenix bd03252b28 Updating sample env files and workflow 2026-07-17 16:02:59 -04:00
phoenix c3a3ce58ba Updating name
soaricarus_auth Build / Rustfmt (pull_request) Successful in 32s
soaricarus_auth Build / Clippy (pull_request) Successful in 1m28s
soaricarus_auth Build / Test Suite (pull_request) Successful in 2m57s
soaricarus_auth Build / Check (pull_request) Successful in 3m32s
soaricarus_auth Build / build (pull_request) Successful in 1m48s
2026-07-17 15:58:20 -04:00
12 changed files with 81 additions and 99 deletions
+2 -2
View File
@@ -5,9 +5,9 @@ RUST_LOG=debug
ALLOWED_ORIGINS=https://soaricarus.com,https://www.soaricarus.com ALLOWED_ORIGINS=https://soaricarus.com,https://www.soaricarus.com
SECRET_KEY=refero34o8rfhfjn983thf39fhc943rf923n3h SECRET_KEY=refero34o8rfhfjn983thf39fhc943rf923n3h
SERVICE_PASSPHRASE=iUOo1fxshf3y1tUGn1yU8l9raPApHCdinW0VdCHdRFEjqhR3Bf02aZzsKbLtaDFH SERVICE_PASSPHRASE=iUOo1fxshf3y1tUGn1yU8l9raPApHCdinW0VdCHdRFEjqhR3Bf02aZzsKbLtaDFH
POSTGRES_AUTH_USER=icarus_op POSTGRES_AUTH_USER=soaricarus_op
POSTGRES_AUTH_PASSWORD=password POSTGRES_AUTH_PASSWORD=password
POSTGRES_AUTH_DB=icarus_auth_db POSTGRES_AUTH_DB=soaricarus_auth_db
POSTGRES_AUTH_HOST=auth_db POSTGRES_AUTH_HOST=auth_db
DATABASE_URL=postgresql://${POSTGRES_AUTH_USER}:${POSTGRES_AUTH_PASSWORD}@${POSTGRES_AUTH_HOST}:5432/${POSTGRES_AUTH_DB} DATABASE_URL=postgresql://${POSTGRES_AUTH_USER}:${POSTGRES_AUTH_PASSWORD}@${POSTGRES_AUTH_HOST}:5432/${POSTGRES_AUTH_DB}
ENABLE_REGISTRATION=TRUE ENABLE_REGISTRATION=TRUE
+2 -2
View File
@@ -5,9 +5,9 @@ RUST_LOG=debug
ALLOWED_ORIGINS=https://soaricarus.com,https://www.soaricarus.com ALLOWED_ORIGINS=https://soaricarus.com,https://www.soaricarus.com
SECRET_KEY=refero34o8rfhfjn983thf39fhc943rf923n3h SECRET_KEY=refero34o8rfhfjn983thf39fhc943rf923n3h
SERVICE_PASSPHRASE=iUOo1fxshf3y1tUGn1yU8l9raPApHCdinW0VdCHdRFEjqhR3Bf02aZzsKbLtaDFH SERVICE_PASSPHRASE=iUOo1fxshf3y1tUGn1yU8l9raPApHCdinW0VdCHdRFEjqhR3Bf02aZzsKbLtaDFH
POSTGRES_AUTH_USER=icarus_op_test POSTGRES_AUTH_USER=soaricarus_op_test
POSTGRES_AUTH_PASSWORD=password POSTGRES_AUTH_PASSWORD=password
POSTGRES_AUTH_DB=icarus_auth_test_db POSTGRES_AUTH_DB=soaricarus_auth_test_db
POSTGRES_AUTH_HOST=localhost POSTGRES_AUTH_HOST=localhost
DATABASE_URL=postgresql://${POSTGRES_AUTH_USER}:${POSTGRES_AUTH_PASSWORD}@${POSTGRES_AUTH_HOST}:5432/${POSTGRES_AUTH_DB} DATABASE_URL=postgresql://${POSTGRES_AUTH_USER}:${POSTGRES_AUTH_PASSWORD}@${POSTGRES_AUTH_HOST}:5432/${POSTGRES_AUTH_DB}
ENABLE_REGISTRATION=TRUE ENABLE_REGISTRATION=TRUE
+16 -16
View File
@@ -1,4 +1,4 @@
name: icarus_auth Build name: soaricarus_auth Build
on: on:
push: push:
@@ -20,12 +20,12 @@ jobs:
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- run: | - run: |
mkdir -p ~/.ssh mkdir -p ~/.ssh
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/icarus_models_deploy_key echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/soaricarus_models_deploy_key
chmod 600 ~/.ssh/icarus_models_deploy_key chmod 600 ~/.ssh/soaricarus_models_deploy_key
ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts
eval $(ssh-agent -s) eval $(ssh-agent -s)
ssh-add -v ~/.ssh/icarus_models_deploy_key ssh-add -v ~/.ssh/soaricarus_models_deploy_key
cargo check cargo check
@@ -72,12 +72,12 @@ jobs:
ENABLE_REGISTRATION: 'TRUE' ENABLE_REGISTRATION: 'TRUE'
run: | run: |
mkdir -p ~/.ssh mkdir -p ~/.ssh
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/icarus_models_deploy_key echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/soaricarus_models_deploy_key
chmod 600 ~/.ssh/icarus_models_deploy_key chmod 600 ~/.ssh/soaricarus_models_deploy_key
ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts
eval $(ssh-agent -s) eval $(ssh-agent -s)
ssh-add -v ~/.ssh/icarus_models_deploy_key ssh-add -v ~/.ssh/soaricarus_models_deploy_key
cargo test cargo test
@@ -93,12 +93,12 @@ jobs:
- run: rustup component add rustfmt - run: rustup component add rustfmt
- run: | - run: |
mkdir -p ~/.ssh mkdir -p ~/.ssh
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/icarus_models_deploy_key echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/soaricarus_models_deploy_key
chmod 600 ~/.ssh/icarus_models_deploy_key chmod 600 ~/.ssh/soaricarus_models_deploy_key
ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts
eval $(ssh-agent -s) eval $(ssh-agent -s)
ssh-add -v ~/.ssh/icarus_models_deploy_key ssh-add -v ~/.ssh/soaricarus_models_deploy_key
cargo fmt --all -- --check cargo fmt --all -- --check
clippy: clippy:
@@ -113,12 +113,12 @@ jobs:
- run: rustup component add clippy - run: rustup component add clippy
- run: | - run: |
mkdir -p ~/.ssh mkdir -p ~/.ssh
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/icarus_models_deploy_key echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/soaricarus_models_deploy_key
chmod 600 ~/.ssh/icarus_models_deploy_key chmod 600 ~/.ssh/soaricarus_models_deploy_key
ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts
eval $(ssh-agent -s) eval $(ssh-agent -s)
ssh-add -v ~/.ssh/icarus_models_deploy_key ssh-add -v ~/.ssh/soaricarus_models_deploy_key
cargo clippy -- -D warnings cargo clippy -- -D warnings
build: build:
@@ -132,10 +132,10 @@ jobs:
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- run: | - run: |
mkdir -p ~/.ssh mkdir -p ~/.ssh
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/icarus_models_deploy_key echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/soaricarus_models_deploy_key
chmod 600 ~/.ssh/icarus_models_deploy_key chmod 600 ~/.ssh/soaricarus_models_deploy_key
ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts
eval $(ssh-agent -s) eval $(ssh-agent -s)
ssh-add -v ~/.ssh/icarus_models_deploy_key ssh-add -v ~/.ssh/soaricarus_models_deploy_key
cargo build --release cargo build --release
Generated
+36 -36
View File
@@ -781,40 +781,6 @@ dependencies = [
"tower-service", "tower-service",
] ]
[[package]]
name = "icarus_auth"
version = "0.8.1"
dependencies = [
"argon2",
"axum",
"http-body-util",
"icarus_envy",
"icarus_models",
"josekit",
"openssl",
"serde",
"serde_json",
"sqlx",
"time",
"tokio",
"tower",
"tower-http",
"tracing-subscriber",
"url",
"utoipa",
"utoipa-swagger-ui",
"uuid",
]
[[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_models" name = "icarus_models"
version = "0.11.3" version = "0.11.3"
@@ -1583,6 +1549,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 = "simd-adler32" name = "simd-adler32"
version = "0.3.9" version = "0.3.9"
@@ -1604,6 +1579,31 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "soaricarus_auth"
version = "0.8.1"
dependencies = [
"argon2",
"axum",
"http-body-util",
"icarus_models",
"josekit",
"openssl",
"serde",
"serde_json",
"sienvy",
"sqlx",
"time",
"tokio",
"tower",
"tower-http",
"tracing-subscriber",
"url",
"utoipa",
"utoipa-swagger-ui",
"uuid",
]
[[package]] [[package]]
name = "socket2" name = "socket2"
version = "0.6.4" version = "0.6.4"
@@ -2214,9 +2214,9 @@ dependencies = [
[[package]] [[package]]
name = "uuid" name = "uuid"
version = "1.23.4" version = "1.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf80a72845275afea99e7f2b434723d3bc7e38470fcd1c7ed39a599c73319a53" checksum = "bf3923a6f5c4c6382e0b653c4117f48d631ea17f38ed86e2a828e6f7412f5239"
dependencies = [ dependencies = [
"getrandom 0.4.3", "getrandom 0.4.3",
"js-sys", "js-sys",
+3 -3
View File
@@ -1,5 +1,5 @@
[package] [package]
name = "icarus_auth" name = "soaricarus_auth"
version = "0.8.1" version = "0.8.1"
edition = "2024" edition = "2024"
rust-version = "1.95" rust-version = "1.95"
@@ -14,14 +14,14 @@ tracing-subscriber = { version = "0.3.23" }
tower = { version = "0.5.3", features = ["full"] } tower = { version = "0.5.3", features = ["full"] }
tower-http = { version = "0.7.0", features = ["cors"] } tower-http = { version = "0.7.0", features = ["cors"] }
sqlx = { version = "0.9.0", features = ["postgres", "runtime-tokio", "tls-native-tls", "time", "uuid"] } sqlx = { version = "0.9.0", features = ["postgres", "runtime-tokio", "tls-native-tls", "time", "uuid"] }
uuid = { version = "1.23.4", features = ["v4", "serde"] } uuid = { version = "1.23.5", features = ["v4", "serde"] }
argon2 = { version = "0.5.3", features = ["std"] } argon2 = { version = "0.5.3", features = ["std"] }
time = { version = "0.3.53", features = ["macros", "serde"] } time = { version = "0.3.53", features = ["macros", "serde"] }
josekit = { version = "0.10.3" } josekit = { version = "0.10.3" }
utoipa = { version = "5.5.0", features = ["axum_extras"] } 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_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]
http-body-util = { version = "0.1.3" } http-body-util = { version = "0.1.3" }
+3 -22
View File
@@ -1,14 +1,8 @@
# Stage 1: Build the application
# Use a specific Rust version for reproducibility. Choose one that matches your development environment.
# Using slim variant for smaller base image
FROM rust:1.96.1 as builder FROM rust:1.96.1 as builder
# Set the working directory inside the container # Set the working directory inside the container
WORKDIR /usr/src/app WORKDIR /usr/src/app
# Install build dependencies if needed (e.g., for certain crates like sqlx with native TLS)
# RUN apt-get update && apt-get install -y pkg-config libssl-dev
# Install build dependencies if needed (e.g., git for cloning) # Install build dependencies if needed (e.g., git for cloning)
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config libssl3 \ pkg-config libssl3 \
@@ -16,36 +10,25 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
openssh-client git \ openssh-client git \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# << --- ADD HOST KEY HERE --- >>
# Replace 'yourgithost.com' with the actual hostname (e.g., github.com)
RUN mkdir -p -m 0700 ~/.ssh && \ RUN mkdir -p -m 0700 ~/.ssh && \
ssh-keyscan git.kundeng.us >> ~/.ssh/known_hosts ssh-keyscan git.kundeng.us >> ~/.ssh/known_hosts
# Copy Cargo manifests # Copy Cargo manifests
COPY Cargo.toml Cargo.lock ./ COPY Cargo.toml Cargo.lock ./
# Build *only* dependencies to leverage Docker cache
# This dummy build caches dependencies as a separate layer
RUN --mount=type=ssh mkdir src && \ RUN --mount=type=ssh mkdir src && \
echo "fn main() {println!(\"if you see this, the build broke\")}" > src/main.rs && \ echo "fn main() {println!(\"if you see this, the build broke\")}" > src/main.rs && \
cargo build --release --quiet && \ cargo build --release --quiet && \
rm -rf src target/release/deps/icarus_auth* # Clean up dummy build artifacts (replace icarus_auth) rm -rf src target/release/deps/soaricarus_auth*
# Copy the actual source code
COPY src ./src COPY src ./src
# If you have other directories like `templates` or `static`, copy them too # If you have other directories like `templates` or `static`, copy them too
COPY .env ./.env COPY .env ./.env
COPY migrations ./migrations COPY migrations ./migrations
# << --- SSH MOUNT ADDED HERE --- >>
# Build *only* dependencies to leverage Docker cache
# This dummy build caches dependencies as a separate layer
# Mount the SSH agent socket for this command
RUN --mount=type=ssh \ RUN --mount=type=ssh \
cargo build --release --quiet cargo build --release --quiet
# Stage 2: Create the final, smaller runtime image
# Use a minimal base image like debian-slim or even distroless for security/size
FROM debian:trixie-slim FROM debian:trixie-slim
# Install runtime dependencies if needed (e.g., SSL certificates) # Install runtime dependencies if needed (e.g., SSL certificates)
@@ -55,17 +38,15 @@ RUN apt-get update && apt-get install -y ca-certificates libssl-dev libssl3 && r
WORKDIR /usr/local/bin WORKDIR /usr/local/bin
# Copy the compiled binary from the builder stage # Copy the compiled binary from the builder stage
# Replace 'icarus_auth' with the actual name of your binary (usually the crate name) COPY --from=builder /usr/src/app/target/release/soaricarus_auth .
COPY --from=builder /usr/src/app/target/release/icarus_auth .
# Copy other necessary files like .env (if used for runtime config) or static assets # Copy other necessary files like .env (if used for runtime config) or static assets
# It's generally better to configure via environment variables in Docker though # It's generally better to configure via environment variables in Docker though
COPY --from=builder /usr/src/app/.env . COPY --from=builder /usr/src/app/.env .
COPY --from=builder /usr/src/app/migrations ./migrations COPY --from=builder /usr/src/app/migrations ./migrations
# Expose the port your Axum app listens on (e.g., 3000 or 8000)
EXPOSE 8001 EXPOSE 8001
# Set the command to run your application # Set the command to run your application
# Ensure this matches the binary name copied above # Ensure this matches the binary name copied above
CMD ["./icarus_auth"] CMD ["./soaricarus_auth"]
+2 -1
View File
@@ -1,4 +1,5 @@
A auth web API services for the Icarus project. # soaricarus_auth
A auth web API services for the soaricarus project.
# Getting Started # Getting Started
+4 -4
View File
@@ -5,7 +5,7 @@ services:
build: build:
context: . context: .
ssh: ["default"] ssh: ["default"]
container_name: icarus_auth container_name: soaricarus_auth
ports: ports:
- "8001:8001" - "8001:8001"
env_file: env_file:
@@ -17,11 +17,11 @@ services:
auth_db: auth_db:
image: postgres:18.4-alpine image: postgres:18.4-alpine
container_name: icarus_auth_db container_name: soaricarus_auth_db
environment: environment:
POSTGRES_USER: ${POSTGRES_AUTH_USER:-icarus_op} POSTGRES_USER: ${POSTGRES_AUTH_USER:-soaricarus_op}
POSTGRES_PASSWORD: ${POSTGRES_AUTH_PASSWORD:-password} POSTGRES_PASSWORD: ${POSTGRES_AUTH_PASSWORD:-password}
POSTGRES_DB: ${POSTGRES_AUTH_DB:-icarus_auth_db} POSTGRES_DB: ${POSTGRES_AUTH_DB:-soaricarus_auth_db}
volumes: volumes:
- postgres_data:/var/lib/postgresql - postgres_data:/var/lib/postgresql
ports: [] ports: []
+3 -3
View File
@@ -92,7 +92,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().value; let key = sienvy::environment::get_secret_key().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();
@@ -151,7 +151,7 @@ pub mod endpoint {
match repo::service::valid_passphrase(&pool, &payload.passphrase).await { match repo::service::valid_passphrase(&pool, &payload.passphrase).await {
Ok((id, username, _date_created)) => { Ok((id, username, _date_created)) => {
let key = icarus_envy::environment::get_secret_key().value; let key = sienvy::environment::get_secret_key().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();
@@ -203,7 +203,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().value; let key = sienvy::environment::get_secret_key().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();
+1 -1
View File
@@ -144,7 +144,7 @@ pub async fn register_user(
/// Checks to see if registration is enabled /// Checks to see if registration is enabled
async fn is_registration_enabled() -> Result<bool, std::io::Error> { async fn is_registration_enabled() -> Result<bool, std::io::Error> {
let key = String::from("ENABLE_REGISTRATION"); let key = String::from("ENABLE_REGISTRATION");
let var = icarus_envy::environment::get_env(&key); let var = sienvy::environment::get_env(&key);
let parsed_value = var.value.to_uppercase(); let parsed_value = var.value.to_uppercase();
if parsed_value == "TRUE" { if parsed_value == "TRUE" {
+1 -1
View File
@@ -1,7 +1,7 @@
use sqlx::postgres::PgPoolOptions; use sqlx::postgres::PgPoolOptions;
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()
+8 -8
View File
@@ -44,7 +44,7 @@ mod init {
register_responses::Response, register_responses::Response,
login_responses::Response, login_responses::service_login::Response, login_responses::refresh_token::Response)), login_responses::Response, login_responses::service_login::Response, login_responses::refresh_token::Response)),
tags( tags(
(name = "Icarus Auth API", description = "Auth API for Icarus API") (name = "soaricarus Auth API", description = "Auth API for soaricarus API")
) )
)] )]
struct ApiDoc; struct ApiDoc;
@@ -67,10 +67,10 @@ mod init {
.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 // Dynamically set the allowed origin based on the environment
match std::env::var(icarus_envy::keys::APP_ENV).as_deref() { match std::env::var(sienvy::keys::APP_ENV).as_deref() {
Ok("production") => { Ok("production") => {
let allowed_origins_env = icarus_envy::environment::get_allowed_origins(); let allowed_origins_env = sienvy::environment::get_allowed_origins();
match icarus_envy::utility::delimitize(&allowed_origins_env) { match sienvy::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()
@@ -162,7 +162,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
} }
@@ -175,7 +175,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
} }
@@ -207,7 +207,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" {
@@ -508,7 +508,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().value; let key = sienvy::environment::get_secret_key().value;
match token_stuff::create_service_token(&key, &id) { match token_stuff::create_service_token(&key, &id) {
Ok((token, _expire)) => { Ok((token, _expire)) => {