Update rust (#20)
Rust Build / Rustfmt (push) Successful in 48s
Rust Build / Check (push) Successful in 1m30s
Rust Build / Test Suite (push) Successful in 2m29s
Rust Build / Clippy (push) Successful in 1m47s
Rust Build / build (push) Successful in 2m13s
Rust Build / Rustfmt (pull_request) Successful in 36s
Rust Build / Clippy (pull_request) Successful in 38s
Rust Build / Check (pull_request) Successful in 3m34s
Rust Build / Rustfmt (push) Successful in 48s
Rust Build / Check (push) Successful in 1m30s
Rust Build / Test Suite (push) Successful in 2m29s
Rust Build / Clippy (push) Successful in 1m47s
Rust Build / build (push) Successful in 2m13s
Rust Build / Rustfmt (pull_request) Successful in 36s
Rust Build / Clippy (pull_request) Successful in 38s
Rust Build / Check (pull_request) Successful in 3m34s
Reviewed-on: phoenix/textsender_auth#20
This commit was merged in pull request #20.
This commit is contained in:
+2
-1
@@ -7,4 +7,5 @@ DB_AUTH_PORT=5432
|
||||
DB_AUTH_SSLMODE=disable
|
||||
DATABASE_URL=postgres://${DB_AUTH_USER}:${DB_AUTH_PASSWORD}@${DB_AUTH_HOST}:${DB_AUTH_PORT}/${DB_AUTH_NAME}
|
||||
ENABLE_REGISTRATION=true
|
||||
ALLOWED_ORIGINS="http://textsender.com"
|
||||
ALLOWED_ORIGINS="http://textsender.com,http://localhost:5173,http://localhost:9080"
|
||||
APP_ENV=production
|
||||
|
||||
+2
-1
@@ -7,4 +7,5 @@ DB_AUTH_PORT=5432
|
||||
DB_AUTH_SSLMODE=disable
|
||||
DATABASE_URL=postgres://${DB_AUTH_USER}:${DB_AUTH_PASSWORD}@${DB_AUTH_HOST}:${DB_AUTH_PORT}/${DB_AUTH_NAME}
|
||||
ENABLE_REGISTRATION=true
|
||||
ALLOWED_ORIGINS="http://textsender.com"
|
||||
ALLOWED_ORIGINS="http://textsender.com,http://localhost:5173,http://localhost:9080"
|
||||
APP_ENV=production
|
||||
|
||||
@@ -14,10 +14,10 @@ jobs:
|
||||
name: Check
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.96
|
||||
toolchain: 1.96.1
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: |
|
||||
mkdir -p ~/.ssh
|
||||
@@ -35,10 +35,10 @@ jobs:
|
||||
name: Rustfmt
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.96
|
||||
toolchain: 1.96.1
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: rustup component add rustfmt
|
||||
- run: |
|
||||
@@ -55,10 +55,10 @@ jobs:
|
||||
name: Clippy
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.96
|
||||
toolchain: 1.96.1
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: rustup component add clippy
|
||||
- run: |
|
||||
|
||||
@@ -14,10 +14,10 @@ jobs:
|
||||
name: Check
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.96
|
||||
toolchain: 1.96.1
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: |
|
||||
mkdir -p ~/.ssh
|
||||
@@ -51,10 +51,10 @@ jobs:
|
||||
--health-retries 5
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.96
|
||||
toolchain: 1.96.1
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
# --- Add this step for explicit verification ---
|
||||
- name: Verify Docker Environment
|
||||
@@ -94,10 +94,10 @@ jobs:
|
||||
name: Rustfmt
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.96
|
||||
toolchain: 1.96.1
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: rustup component add rustfmt
|
||||
- run: |
|
||||
@@ -114,10 +114,10 @@ jobs:
|
||||
name: Clippy
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.96
|
||||
toolchain: 1.96.1
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: rustup component add clippy
|
||||
- run: |
|
||||
@@ -134,10 +134,10 @@ jobs:
|
||||
name: build
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.96
|
||||
toolchain: 1.96.1
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: |
|
||||
mkdir -p ~/.ssh
|
||||
|
||||
Generated
+8
-8
@@ -191,9 +191,9 @@ checksum = "8ae3f5d315924270530207e2a68396c3cc547f6dca3fbdca317cfb1a51edb593"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.65"
|
||||
version = "1.2.66"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e228eec9be7c17ccb640b59b36a5cd805ea2a564a4c5e162c2f659fea30d3b96"
|
||||
checksum = "f5d6cac793997bd970000024b2934968efe83b382de4fdcf4fcb46b6ee4ad996"
|
||||
dependencies = [
|
||||
"find-msvc-tools",
|
||||
"shlex",
|
||||
@@ -312,18 +312,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-queue"
|
||||
version = "0.3.12"
|
||||
version = "0.3.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115"
|
||||
checksum = "803d13fb3b09d88be9f4dbc29062c66b19bf7170867ceb746d2a8689bf6c7a26"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.21"
|
||||
version = "0.8.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
||||
checksum = "61803da095bee82a81bb1a452ecc25d3b2f1416d1897eb86430c6159ef717c17"
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
@@ -1833,8 +1833,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "textsender_models"
|
||||
version = "0.5.0"
|
||||
source = "git+ssh://git@git.kundeng.us/phoenix/textsender_models.git?tag=v0.5.0#137398405fbc61acd352530f8cbfd4d98e648e95"
|
||||
version = "0.5.1"
|
||||
source = "git+ssh://git@git.kundeng.us/phoenix/textsender_models.git?tag=v0.5.1#151eeaacf64e255bde56a48df03f4c46ec77c235"
|
||||
dependencies = [
|
||||
"const_format",
|
||||
"dotenvy",
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@
|
||||
name = "textsender_auth"
|
||||
version = "0.2.2"
|
||||
edition = "2024"
|
||||
rust-version = "1.96"
|
||||
rust-version = "1.96.1"
|
||||
|
||||
[dependencies]
|
||||
axum = { version = "0.8.9" }
|
||||
@@ -13,12 +13,12 @@ tracing-subscriber = { version = "0.3.23" }
|
||||
tower-http = { version = "0.7.0", features = ["cors"] }
|
||||
sqlx = { version = "0.9.0", features = ["runtime-tokio", "tls-native-tls", "postgres", "time", "uuid"] }
|
||||
uuid = { version = "1.23.3", features = ["v4", "serde"] }
|
||||
argon2 = { version = "0.5.3", features = ["std"] } # Use the latest 0.5.x version
|
||||
argon2 = { version = "0.5.3", features = ["std"] }
|
||||
time = { version = "0.3.53", features = ["macros", "serde"] }
|
||||
josekit = { version = "0.10.3" }
|
||||
utoipa = { version = "5.5.0", features = ["axum_extras"] }
|
||||
utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] }
|
||||
textsender_models = { git = "ssh://git@git.kundeng.us/phoenix/textsender_models.git", tag = "v0.5.0", features = ["config", "user"] }
|
||||
textsender_models = { git = "ssh://git@git.kundeng.us/phoenix/textsender_models.git", tag = "v0.5.1", features = ["config", "user"] }
|
||||
|
||||
[dev-dependencies]
|
||||
tower = { version = "0.5.3", features = ["full"] }
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
# 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 as builder
|
||||
FROM rust:1.96.1 as builder
|
||||
|
||||
# Set the working directory inside the container
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
+25
-6
@@ -96,11 +96,19 @@ pub mod response {
|
||||
pub async fn extract(
|
||||
response: axum::response::Response,
|
||||
) -> Result<LoginResponse, std::io::Error> {
|
||||
let body = axum::body::to_bytes(response.into_body(), usize::MAX)
|
||||
.await
|
||||
.unwrap();
|
||||
let _parsed_body: LoginResponse = serde_json::from_slice(&body).unwrap();
|
||||
todo!("Add code to convert axum::Response to this type");
|
||||
let body = match axum::body::to_bytes(response.into_body(), usize::MAX).await {
|
||||
Ok(body) => body,
|
||||
Err(err) => {
|
||||
return Err(std::io::Error::other(err));
|
||||
}
|
||||
};
|
||||
let parsed_body: LoginResponse = match serde_json::from_slice(&body) {
|
||||
Ok(body) => body,
|
||||
Err(err) => {
|
||||
return Err(std::io::Error::other(err));
|
||||
}
|
||||
};
|
||||
Ok(parsed_body)
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, utoipa::ToSchema)]
|
||||
@@ -194,7 +202,18 @@ pub async fn user_login(
|
||||
// Create token
|
||||
let key =
|
||||
textsender_models::envy::environment::get_secret_key().value;
|
||||
let cst = token_stuff::create_token(&key, &user.id).unwrap();
|
||||
let cst = match token_stuff::create_token(&key, &user.id) {
|
||||
Ok(token) => token,
|
||||
Err(_err) => {
|
||||
return (
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response::LoginResponse {
|
||||
message: String::from("Error creating token"),
|
||||
data: Vec::new(),
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
if token_stuff::verify_token(&key, &cst.access_token) {
|
||||
let current_time = time::OffsetDateTime::now_utc();
|
||||
|
||||
@@ -80,7 +80,7 @@ pub fn generate_the_salt() -> (
|
||||
responses(
|
||||
(status = 201, description = "User created", body = response::Response),
|
||||
(status = 404, description = "User already exists", body = response::Response),
|
||||
(status = 400, description = "Issue creating user", body = response::Response)
|
||||
(status = 500, description = "Issue creating user", body = response::Response)
|
||||
)
|
||||
)]
|
||||
pub async fn register_user(
|
||||
@@ -105,9 +105,7 @@ pub async fn register_user(
|
||||
let mut user = textsender_models::user::User {
|
||||
username: payload.username.clone(),
|
||||
password: payload.password.clone(),
|
||||
// email: payload.email.clone(),
|
||||
phone_number: payload.phone_number.clone(),
|
||||
// email_verified: true,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
||||
+2
-4
@@ -38,7 +38,6 @@ pub mod init {
|
||||
|
||||
mod cors {
|
||||
pub async fn configure_cors() -> tower_http::cors::CorsLayer {
|
||||
// Start building the CORS layer with common settings
|
||||
let cors = tower_http::cors::CorsLayer::new()
|
||||
.allow_methods([
|
||||
axum::http::Method::GET,
|
||||
@@ -46,11 +45,11 @@ pub mod init {
|
||||
axum::http::Method::POST,
|
||||
axum::http::Method::PUT,
|
||||
axum::http::Method::DELETE,
|
||||
]) // Specify allowed methods:cite[2]
|
||||
])
|
||||
.allow_headers([
|
||||
axum::http::header::CONTENT_TYPE,
|
||||
axum::http::header::AUTHORIZATION,
|
||||
]) // Specify allowed headers:cite[2]
|
||||
])
|
||||
.allow_credentials(true) // If you need to send cookies or authentication headers:cite[2]
|
||||
.max_age(std::time::Duration::from_secs(3600)); // Cache the preflight response for 1 hour:cite[2]
|
||||
|
||||
@@ -93,7 +92,6 @@ pub mod init {
|
||||
}
|
||||
|
||||
pub async fn routes() -> Router {
|
||||
// build our application with a route
|
||||
Router::new()
|
||||
.route(
|
||||
callers::endpoints::DBTEST,
|
||||
|
||||
+10
-11
@@ -9,9 +9,7 @@ mod db_mgr {
|
||||
pub const LIMIT: usize = 6;
|
||||
|
||||
pub async fn get_pool() -> Result<sqlx::PgPool, sqlx::Error> {
|
||||
let tm_db_url = textsender_models::envy::environment::get_db_url()
|
||||
.await
|
||||
.value;
|
||||
let tm_db_url = textsender_models::envy::environment::get_db_url().value;
|
||||
let tm_options = sqlx::postgres::PgConnectOptions::from_str(&tm_db_url).unwrap();
|
||||
sqlx::PgPool::connect_with(tm_options).await
|
||||
}
|
||||
@@ -23,9 +21,7 @@ mod db_mgr {
|
||||
}
|
||||
|
||||
pub async fn connect_to_db(db_name: &str) -> Result<sqlx::PgPool, sqlx::Error> {
|
||||
let db_url = textsender_models::envy::environment::get_db_url()
|
||||
.await
|
||||
.value;
|
||||
let db_url = textsender_models::envy::environment::get_db_url().value;
|
||||
let options = sqlx::postgres::PgConnectOptions::from_str(&db_url)?.database(db_name);
|
||||
sqlx::PgPool::connect_with(options).await
|
||||
}
|
||||
@@ -35,7 +31,10 @@ mod db_mgr {
|
||||
db_name: &str,
|
||||
) -> Result<(), sqlx::Error> {
|
||||
let create_query = format!("CREATE DATABASE {}", db_name);
|
||||
match sqlx::query(&create_query).execute(template_pool).await {
|
||||
match sqlx::query(sqlx::AssertSqlSafe(create_query))
|
||||
.execute(template_pool)
|
||||
.await
|
||||
{
|
||||
Ok(_) => Ok(()),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
@@ -47,14 +46,14 @@ mod db_mgr {
|
||||
db_name: &str,
|
||||
) -> Result<(), sqlx::Error> {
|
||||
let drop_query = format!("DROP DATABASE IF EXISTS {} WITH (FORCE)", db_name);
|
||||
sqlx::query(&drop_query).execute(template_pool).await?;
|
||||
sqlx::query(sqlx::AssertSqlSafe(drop_query))
|
||||
.execute(template_pool)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn get_database_name() -> Result<String, Box<dyn std::error::Error>> {
|
||||
let database_url = textsender_models::envy::environment::get_db_url()
|
||||
.await
|
||||
.value;
|
||||
let database_url = textsender_models::envy::environment::get_db_url().value;
|
||||
|
||||
let parsed_url = url::Url::parse(&database_url)?;
|
||||
if parsed_url.scheme() == "postgres" || parsed_url.scheme() == "postgresql" {
|
||||
|
||||
Reference in New Issue
Block a user