Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
fd8a04b
chore: update image usernames in compose.yml for app-service and
traianistrati-dev Apr 27, 2026
d5945ab
chore: change hello message
traianistrati-dev Apr 27, 2026
2fdc251
chore: update Rust base image to 1.91-alpine
traianistrati-dev Apr 27, 2026
54c7291
[Sprint 1][Task 3] feat: add initial test structure
traianistrati-dev Apr 28, 2026
ad816ce
[Sprint 1][Task 3] refactor: move logic from main.rs to lib.rs
traianistrati-dev Apr 28, 2026
feb78d8
[Sprint 1][Task 4] feat: implement default endpoints and add tests
traianistrati-dev Apr 28, 2026
983c26d
[Sprint 1][Task 5] refactor: move endpoint logic from lib.rs to routes
traianistrati-dev Apr 29, 2026
8a44429
[Sprint 1][Task 5] refactor: finish moving endpoints to routes
traianistrati-dev Apr 29, 2026
a81b6c7
[Sprint 1][Task 5] refactor: move tests from routes.rs to separate files
traianistrati-dev Apr 29, 2026
06565e0
[Sprint 1][Task 6] feat: accept Json<SignupRequest> in signup and add
traianistrati-dev Apr 29, 2026
bf9ff7e
[Sprint 1][Task 7] ci: add DOCKER-Sprint1 environment to prod.yaml
traianistrati-dev Apr 29, 2026
ce47b50
[Sprint 1][Task 7] ci: add DOCKER-Sprint1 environment to prod.yaml for
traianistrati-dev Apr 29, 2026
4130db5
[Sprint 2][Task 1] feat: add User domain model with implementation and
traianistrati-dev May 1, 2026
f0f6bd3
[Sprint 2][Task 1] feat: add HashMapUserStore service with tests
traianistrati-dev May 1, 2026
a0dc7fb
[Sprint 2][Task 1]feat: refactor module visibility and add AppState f…
traianistrati-dev May 1, 2026
9938257
[Sprint 2][Task 2] feat: implement signup validation and error handling
traianistrati-dev May 3, 2026
3de98ad
[Sprint 2][Task 3] refactor: introduce async trait UserStore in
traianistrati-dev May 4, 2026
10f4950
[Sprint 2][Task 4] refactor: introduce Email and Password types and
traianistrati-dev May 5, 2026
dbceddd
[Sprint 3][Task 1] feat: add login validation logic and 422 test for
traianistrati-dev May 8, 2026
6ab1709
[Sprint 3][Task 1] feat: improve login validation with tests for 400 and
traianistrati-dev May 9, 2026
4a238ef
[Sprint 3][Task 2] feat: add utils/constants and incomplete 2FA login
traianistrati-dev May 9, 2026
55fa477
[Sprint 3][Task 2] feat: add utils/auth with login token generation and
traianistrati-dev May 9, 2026
3da4881
[Sprint 3][Task 3] fix: login result signature and axum dependencies
traianistrati-dev May 11, 2026
178ba2f
[Sprint 3][Task 3] feat: add docker.sh and docker.bat and update
traianistrati-dev May 11, 2026
ce7f9c7
[Sprint 3][Task 3]feat: update prod.yml add env:JWT_SECRET
traianistrati-dev May 11, 2026
0a82a6e
[Sprint 3][Task 3] feat: implement logout with cookie validation and
traianistrati-dev May 11, 2026
e2476d6
[Sprint 3][Test 3] feat: remove coockie at the end of logout
traianistrati-dev May 11, 2026
d464866
[Sprint 3][Task 3] feat: add cors allowed origins to route and update
traianistrati-dev May 11, 2026
34d771b
[Sprint 3][Task 4] feat: implement verify_token logic with tests for
traianistrati-dev May 11, 2026
f2f4bcb
[Sprint 3][Task 5] feat: add banned_token_store trait with impl & tests
traianistrati-dev May 12, 2026
97de63f
[Sprint 3][Test 5]feat:add BannedTokenStore as param to AppState
traianistrati-dev May 12, 2026
553361a
[Sprint 3][Task 5]feat:update add_banned_token to logout
traianistrati-dev May 12, 2026
a2cb6e1
[Sprint 3][Task 5]feat: add banned_tokens_store to validate_token
traianistrati-dev May 13, 2026
419933d
[Sprint4][Task1]feat: add basic handle 2fa to login
traianistrati-dev May 14, 2026
df24887
[Sprint4][Task1]feat: add 2fa code store and login update with tests
traianistrati-dev May 15, 2026
b8b8e28
[Sprint4][Task2]feat: add basic email client and send_email to login
traianistrati-dev May 16, 2026
4df03c8
[Sprint4][Task2]feat: update verify_2fa with test 422
traianistrati-dev May 16, 2026
d7bce43
[Sprint4][Task3]feat: add test cases 400,401 for verify_2fa
traianistrati-dev May 16, 2026
b0cc661
[Sprint5][Task1]feat: add connection to postgress with migrations
traianistrati-dev May 20, 2026
b820059
[Sprint5][Task2]refactor: moved all stores in data_stores folder
traianistrati-dev May 20, 2026
8b1cd76
[Sprint5][Task2]refactor: Pasword to HashedPassword with argon2 hashing
traianistrati-dev May 21, 2026
dbad3cf
[Sprint5][Task2]feat: add postgres_user_store with SQLX_OFFLINE=true
traianistrati-dev May 21, 2026
47392fb
[Sprint5][Task2]feat: replace user hashmap store with postgres store
traianistrati-dev May 21, 2026
f60ab18
[Sprint5][Task3]feat: add [#auto_db_cleanup] to tests and check on drop
traianistrati-dev May 24, 2026
cec6651
[Sprint 5][Task 3] chore: ignore /test_macros/target in gitignore
traianistrati-dev May 25, 2026
224bfbc
[Sprint5][Task4]feat: add redis banned token store and cleaup code
traianistrati-dev May 25, 2026
394e963
[Sprint5][Task5]feat: add redis 2fa store
traianistrati-dev May 27, 2026
a3e3bcb
[Sprint5][Task5]refactor: moved test_macros outside of auth-service
traianistrati-dev May 28, 2026
d68bd1f
[Sprint5][Task5]fix: docker config to use test_macros lib
traianistrati-dev May 30, 2026
37a4695
[Sprint 5][Task 6] feat: add PostgreSQL and Redis configs to prod.yml
traianistrati-dev May 30, 2026
6169264
[Sprint5][Task6]refactor: move test_macro isnide of auth-service
traianistrati-dev May 30, 2026
db853d3
[Srpint5][Task6]fix: Dockerfile
traianistrati-dev May 31, 2026
c747b5f
[Sprint6][Task1]feat: add basic tracing.rs with init_tracing()
traianistrati-dev Jun 6, 2026
5c512a3
[Sprint6][Task1]feat: add tracing::instrument to signup, password
traianistrati-dev Jun 6, 2026
e8e2d39
[Sprint6][Task2]feat: update all stores for tracing errors
traianistrati-dev Jun 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
JWT_SECRET=fUkwAovmPVsfEFx8Eu9rGRIawGPhdOSw2hsWohXW1Osxcy4in7Lad97CR08bA775XJ2Li+DD5xL09KaaA8cNuQ==
DATABASE_URL=postgres://postgres:123zxcQWE@localhost:5432
POSTGRES_PASSWORD=123zxcQWE
SQLX_OFFLINE=true
182 changes: 104 additions & 78 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,93 +6,119 @@ on:
branches:
- main
workflow_dispatch:
env:
SQLX_OFFLINE: true

jobs:
build:
runs-on: ubuntu-latest

environment: DOCKER-Sprint1

services:
postgres:
# Docker Hub image
image: postgres:15.2-alpine
# Environment variables scoped only for the `postgres` element
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: postgres
# Opens tcp port 5432 on the host and service container
ports:
- 5432:5432
redis:
image: redis:7.0-alpine
ports:
- 6379:6379
steps:
# Checkout code from the repository
- name: Checkout code
uses: actions/checkout@v2

# Cache dependencies to speed up build times
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
app-service/.cargo
app-service/target/
auth-service/.cargo
auth-service/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Install Rust
run: rustup update stable && rustup default stable

- name: Build and test app-service code
working-directory: ./app-service
run: |
cargo build --verbose
cargo test --verbose

- name: Build and test auth-service code
working-directory: ./auth-service
run: |
cargo build --verbose
cargo test --verbose

# Set up Docker Buildx for multi-platform builds
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker images
uses: docker/bake-action@v2.3.0
with:
push: true
files: |
compose.yml
compose.override.yml
set: |
*.cache-from=type=gha
*.cache-to=type=gha,mode=max
- name: Checkout code
uses: actions/checkout@v2

# Cache dependencies to speed up build times
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
app-service/.cargo
app-service/target/
auth-service/.cargo
auth-service/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Install Rust
run: rustup update stable && rustup default stable

- name: Build and test app-service code
working-directory: ./app-service
run: |
cargo build --verbose
cargo test --verbose

- name: Build and test auth-service code
working-directory: ./auth-service
env:
JWT_SECRET: ${{ secrets.JWT_SECRET }}
run: |
export JWT_SECRET=secret
export POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}
cargo build --verbose
cargo test --verbose

# Set up Docker Buildx for multi-platform builds
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker images
uses: docker/bake-action@v2.3.0
with:
push: true
files: |
compose.yml
compose.override.yml
set: |
*.cache-from=type=gha
*.cache-to=type=gha,mode=max

deploy:
needs: build
runs-on: ubuntu-latest
environment: DOCKER-Sprint1

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Install sshpass
run: sudo apt-get install sshpass

- name: Copy compose.yml to droplet
run: sshpass -v -p '${{ secrets.DROPLET_PASSWORD }}' scp -o StrictHostKeyChecking=no compose.yml root@${{ vars.DROPLET_IP }}:~

- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ vars.DROPLET_IP }}
username: root
password: ${{ secrets.DROPLET_PASSWORD }}
script: |
cd ~
export AUTH_SERVICE_IP=${{ vars.DROPLET_IP }}
docker compose down
docker compose pull
docker compose up -d
- name: Checkout code
uses: actions/checkout@v2

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Install sshpass
run: sudo apt-get install sshpass

- name: Copy compose.yml to droplet
run: sshpass -v -p '${{ secrets.DROPLET_PASSWORD }}' scp -o StrictHostKeyChecking=no compose.yml root@${{ vars.DROPLET_IP }}:~

- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ vars.DROPLET_IP }}
username: root
password: ${{ secrets.DROPLET_PASSWORD }}
script: |
cd ~
export JWT_SECRET=${{ secrets.JWT_SECRET }}
export AUTH_SERVICE_IP=${{ vars.DROPLET_IP }}
export POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}
docker compose down
docker compose pull
docker compose up -d
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/test_macros/target
.env
65 changes: 62 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,67 @@ visit http://localhost:3000

## Run servers locally (Docker)
```bash
docker compose build
docker compose up
./docker.sh
```
```CMD for Windows
.\docker.bat
```

visit http://localhost:8000 and http://localhost:3000



## Database Migrations
```bash
#more info about sqlx-cli
https://github.com/launchbadge/sqlx/blob/main/sqlx-cli/README.md#install

1. cargo install sqlx-cli --no-default-features --features native-tls,postgres


#NOTE: Make sure to execute this command in the auth-service directory!
# creates 2 new migration scripts named:
# "migrations/[TIMESTAMP]_create_users_table_down.sql" and "migrations/[TIMESTAMP]_create_users_table_up.sql"
2. sqlx migrate add -r create_users_table

#NOTE: Make sure to execute this command in the auth-service directory!
#Generates build.rs script, which is used to generate the database schema
3. sqlx migrate build-script

4.
a #SQLX_OFFLINE environment variable to avoid connecting to the database at runtime
#Add this line to Dockerfile
# # Build application
# COPY . .
ENV SQLX_OFFLINE=true
#RUN cargo build --release --bin auth-service

visit http://localhost:8000 and http://localhost:3000
b # Adn to .env file
SQLX_OFFLINE=true

c#And execute this
cargo sqlx prepare

d #Restart rust-analyzer sever
```

## Docker Postgres
```bash
# Pull the latest Postgres image from Docker Hub
1. docker pull postgres:15.2-alpine

# Run the Postgres container
2. docker run --name ps-db -e POSTGRES_PASSWORD=[YOUR_POSTGRES_PASSWORD] -p 5432:5432 -d postgres:15.2-alpine
```


## Drop Test Databases with Uiid as name
```sql
SELECT format(
'DROP DATABASE "%s";',
datname
)
FROM pg_database
WHERE datname ~
'^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$';
```
2 changes: 1 addition & 1 deletion app-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Start with image that has the Rust toolchain installed
FROM rust:1.90-alpine AS chef
FROM rust:1.91-alpine AS chef
USER root
# Add cargo-chef to cache dependencies
RUN apk add --no-cache musl-dev & cargo install cargo-chef
Expand Down
3 changes: 2 additions & 1 deletion auth-service/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
.env
/test_macros/target
.env

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading