Compare commits

..

4 Commits

Author SHA1 Message Date
4d9e199c13 cargo update
All checks were successful
Rust Build / Rustfmt (pull_request) Successful in 32s
Rust Build / Clippy (pull_request) Successful in 1m38s
Rust Build / build (pull_request) Successful in 3m4s
Rust Build / Test Suite (pull_request) Successful in 2m36s
Rust Build / Check (pull_request) Successful in 47s
2025-10-19 22:25:48 -04:00
334c0bfc4a Updated icarus_models 2025-10-19 22:24:32 -04:00
44f9655ac7 icarus_models version bump
All checks were successful
Rust Build / Rustfmt (pull_request) Successful in 34s
Rust Build / Test Suite (pull_request) Successful in 1m29s
Rust Build / Clippy (pull_request) Successful in 47s
Rust Build / Check (pull_request) Successful in 41s
Rust Build / build (pull_request) Successful in 2m43s
2025-10-18 22:36:50 -04:00
0cf082996d icarus_models version bump
All checks were successful
Rust Build / Rustfmt (pull_request) Successful in 35s
Rust Build / Test Suite (pull_request) Successful in 2m8s
Rust Build / build (pull_request) Successful in 1m4s
Rust Build / Clippy (pull_request) Successful in 1m4s
Rust Build / Check (pull_request) Successful in 1m48s
2025-10-18 20:37:48 -04:00
9 changed files with 65 additions and 113 deletions

View File

@@ -10,4 +10,3 @@ POSTGRES_AUTH_PASSWORD=password
POSTGRES_AUTH_DB=icarus_auth_db
POSTGRES_AUTH_HOST=auth_db
DATABASE_URL=postgresql://${POSTGRES_AUTH_USER}:${POSTGRES_AUTH_PASSWORD}@${POSTGRES_AUTH_HOST}:5432/${POSTGRES_AUTH_DB}
ENABLE_REGISTRATION=TRUE

View File

@@ -10,4 +10,3 @@ POSTGRES_AUTH_PASSWORD=password
POSTGRES_AUTH_DB=icarus_auth_test_db
POSTGRES_AUTH_HOST=localhost
DATABASE_URL=postgresql://${POSTGRES_AUTH_USER}:${POSTGRES_AUTH_PASSWORD}@${POSTGRES_AUTH_HOST}:5432/${POSTGRES_AUTH_DB}
ENABLE_REGISTRATION=TRUE

View File

@@ -3,7 +3,7 @@ name: Release Tagging
on:
push:
branches:
- main
- devel
jobs:
release:
@@ -27,10 +27,8 @@ jobs:
PROJECT_COMMIT_HASH=$(git rev-parse HEAD | cut -c 1-10)
BRANCH_REF="${GITHUB_REF}"
BRANCH_NAME=$(echo "$BRANCH_REF" | cut -d '/' -f 3)
PROJECT_TAG_RELEASE="v$VERSION-$BRANCH_NAME-$PROJECT_COMMIT_HASH-950"
echo "::set-output name=project_tag_release::$PROJECT_TAG_RELEASE"
PROJECT_TAG_RELEASE="v$VERSION-$BRANCH_NAME-$PROJECT_COMMIT_HASH"
echo "::set-output name=project_tag_release::$PROJECT_TAG_RELEASE-950"
echo "Version: $VERSION"
echo "Hash: $PROJECT_COMMIT_HASH"
echo "Branch: $BRANCH_NAME"

View File

@@ -76,7 +76,6 @@ jobs:
SECRET_KEY: ${{ secrets.TOKEN_SECRET_KEY }}
# Make SSH agent available if tests fetch private dependencies
SSH_AUTH_SOCK: ${{ env.SSH_AUTH_SOCK }}
ENABLE_REGISTRATION: 'TRUE'
run: |
mkdir -p ~/.ssh
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/icarus_models_deploy_key

2
Cargo.lock generated
View File

@@ -748,7 +748,7 @@ dependencies = [
[[package]]
name = "icarus_auth"
version = "0.6.3"
version = "0.6.0"
dependencies = [
"argon2",
"axum",

View File

@@ -1,6 +1,6 @@
[package]
name = "icarus_auth"
version = "0.6.3"
version = "0.6.0"
edition = "2024"
rust-version = "1.90"

View File

@@ -8,26 +8,22 @@ need to be modified. The `SECRET_KEY` variable should be changed since it will b
generation. The `SECRET_PASSPHASE` should also be changed when in production mode, but make sure
the respective `passphrase` database table record exists.
To enable or disable registrations, use `TRUE` or `FALSE` for the `ENABLE_REGISTRATION` variable.
By default it is `TRUE`.
### Build image
Build image
```
docker compose build
```
### Start images
Start images
```
docker compose up -d --force-recreate
```
### Bring it down
Bring it down
```
docker compose down -v
```
### Pruning
Pruning
```
docker system prune -a
```

View File

@@ -52,22 +52,8 @@ pub async fn register_user(
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
Json(payload): Json<request::Request>,
) -> (StatusCode, Json<response::Response>) {
let registration_enabled = match is_registration_enabled().await {
Ok(value) => value,
Err(err) => {
eprintln!("Error: {err:?}");
return (
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
Json(response::Response {
message: String::from("Registration check failed"),
data: Vec::new(),
}),
);
}
};
if registration_enabled {
let mut user = icarus_models::user::User {
id: uuid::Uuid::nil(),
username: payload.username.clone(),
password: payload.password.clone(),
email: payload.email.clone(),
@@ -76,17 +62,19 @@ pub async fn register_user(
lastname: payload.lastname.clone(),
status: String::from("Active"),
email_verified: true,
..Default::default()
date_created: Some(time::OffsetDateTime::now_utc()),
last_login: None,
salt_id: uuid::Uuid::nil(),
};
match repo::user::exists(&pool, &user.username).await {
Ok(res) => {
if res {
(
StatusCode::BAD_REQUEST,
StatusCode::NOT_FOUND,
Json(response::Response {
message: String::from("Error"),
data: Vec::new(),
data: vec![user],
}),
)
} else {
@@ -101,9 +89,8 @@ pub async fn register_user(
user.password = hashed_password;
match repo::user::insert(&pool, &user).await {
Ok((id, date_created)) => {
Ok(id) => {
user.id = id;
user.date_created = date_created;
(
StatusCode::CREATED,
Json(response::Response {
@@ -130,30 +117,4 @@ pub async fn register_user(
}),
),
}
} else {
(
axum::http::StatusCode::NOT_ACCEPTABLE,
Json(response::Response {
message: String::from("Registration is not enabled"),
data: Vec::new(),
}),
)
}
}
/// Checks to see if registration is enabled
async fn is_registration_enabled() -> Result<bool, std::io::Error> {
let key = String::from("ENABLE_REGISTRATION");
let var = icarus_envy::environment::get_env(&key).await;
let parsed_value = var.value.to_uppercase();
if parsed_value == "TRUE" {
Ok(true)
} else if parsed_value == "FALSE" {
Ok(false)
} else {
Err(std::io::Error::other(
"Could not determine value of ENABLE_REGISTRATION",
))
}
}

View File

@@ -94,7 +94,7 @@ pub mod user {
pub async fn insert(
pool: &sqlx::PgPool,
user: &icarus_models::user::User,
) -> Result<(uuid::Uuid, std::option::Option<time::OffsetDateTime>), sqlx::Error> {
) -> Result<uuid::Uuid, sqlx::Error> {
let row = sqlx::query(
r#"
INSERT INTO "user" (username, password, email, phone, firstname, lastname, email_verified, status, salt_id)
@@ -124,10 +124,10 @@ pub mod user {
.map_err(|_e| sqlx::Error::RowNotFound)?,
};
if result.id.is_nil() && result.date_created.is_none() {
Err(sqlx::Error::RowNotFound)
if !result.id.is_nil() {
Ok(result.id)
} else {
Ok((result.id, result.date_created))
Err(sqlx::Error::RowNotFound)
}
}
}