Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
010ee6aef5 | ||
|
|
039609a99c | ||
|
|
b3899c1480 |
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
SECRET_KEY=NULqYIzgt28bTiyziCd7IOO7b6LnWDW!
|
SECRET_KEY=NULqYIzgt28bTiyziCd7IOO7b6LnWDW!
|
||||||
DB_AUTH_NAME=textsender_auth_db
|
DB_AUTH_NAME=schedtxt_auth_db
|
||||||
DB_AUTH_USER=textsender_auth
|
DB_AUTH_USER=schedtxt_auth
|
||||||
DB_AUTH_PASSWORD=password
|
DB_AUTH_PASSWORD=password
|
||||||
DB_AUTH_HOST=auth_db
|
DB_AUTH_HOST=auth_db
|
||||||
DB_AUTH_PORT=5432
|
DB_AUTH_PORT=5432
|
||||||
DB_AUTH_SSLMODE=disable
|
DB_AUTH_SSLMODE=disable
|
||||||
DATABASE_URL=postgres://${DB_AUTH_USER}:${DB_AUTH_PASSWORD}@${DB_AUTH_HOST}:${DB_AUTH_PORT}/${DB_AUTH_NAME}
|
DATABASE_URL=postgres://${DB_AUTH_USER}:${DB_AUTH_PASSWORD}@${DB_AUTH_HOST}:${DB_AUTH_PORT}/${DB_AUTH_NAME}
|
||||||
ENABLE_REGISTRATION=true
|
ENABLE_REGISTRATION=true
|
||||||
ALLOWED_ORIGINS="http://textsender.com,http://localhost:5173,http://localhost:9080"
|
ALLOWED_ORIGINS="http://schedtxt.com,http://localhost:5173,http://localhost:9080"
|
||||||
APP_ENV=production
|
APP_ENV=production
|
||||||
|
|||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
SECRET_KEY=NULqYIzgt28bTiyziCd7IOO7b6LnWDW!
|
SECRET_KEY=NULqYIzgt28bTiyziCd7IOO7b6LnWDW!
|
||||||
DB_AUTH_NAME=textsender_auth_db
|
DB_AUTH_NAME=schedtxt_auth_db
|
||||||
DB_AUTH_USER=textsender_auth
|
DB_AUTH_USER=schedtxt_auth
|
||||||
DB_AUTH_PASSWORD=password
|
DB_AUTH_PASSWORD=password
|
||||||
DB_AUTH_HOST=localhost
|
DB_AUTH_HOST=localhost
|
||||||
DB_AUTH_PORT=5432
|
DB_AUTH_PORT=5432
|
||||||
DB_AUTH_SSLMODE=disable
|
DB_AUTH_SSLMODE=disable
|
||||||
DATABASE_URL=postgres://${DB_AUTH_USER}:${DB_AUTH_PASSWORD}@${DB_AUTH_HOST}:${DB_AUTH_PORT}/${DB_AUTH_NAME}
|
DATABASE_URL=postgres://${DB_AUTH_USER}:${DB_AUTH_PASSWORD}@${DB_AUTH_HOST}:${DB_AUTH_PORT}/${DB_AUTH_NAME}
|
||||||
ENABLE_REGISTRATION=true
|
ENABLE_REGISTRATION=true
|
||||||
ALLOWED_ORIGINS="http://textsender.com,http://localhost:5173,http://localhost:9080"
|
ALLOWED_ORIGINS="http://schedtxt.com,http://localhost:5173,http://localhost:9080"
|
||||||
APP_ENV=production
|
APP_ENV=production
|
||||||
|
|||||||
+13
-13
@@ -1,4 +1,4 @@
|
|||||||
name: Rust Build
|
name: pr Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
@@ -17,16 +17,16 @@ jobs:
|
|||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.96.1
|
toolchain: 1.97
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/schedtxt-models_deploy_key
|
||||||
chmod 600 ~/.ssh/textsender-models_deploy_key
|
chmod 600 ~/.ssh/schedtxt-models_deploy_key
|
||||||
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
eval $(ssh-agent -s)
|
eval $(ssh-agent -s)
|
||||||
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
ssh-add -v ~/.ssh/schedtxt-models_deploy_key
|
||||||
|
|
||||||
cargo check
|
cargo check
|
||||||
|
|
||||||
@@ -38,17 +38,17 @@ jobs:
|
|||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.96.1
|
toolchain: 1.97
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: rustup component add rustfmt
|
- run: rustup component add rustfmt
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/schedtxt-models_deploy_key
|
||||||
chmod 600 ~/.ssh/textsender-models_deploy_key
|
chmod 600 ~/.ssh/schedtxt-models_deploy_key
|
||||||
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
eval $(ssh-agent -s)
|
eval $(ssh-agent -s)
|
||||||
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
ssh-add -v ~/.ssh/schedtxt-models_deploy_key
|
||||||
cargo fmt --all -- --check
|
cargo fmt --all -- --check
|
||||||
|
|
||||||
clippy:
|
clippy:
|
||||||
@@ -58,15 +58,15 @@ jobs:
|
|||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.96.1
|
toolchain: 1.97
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: rustup component add clippy
|
- run: rustup component add clippy
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/schedtxt-models_deploy_key
|
||||||
chmod 600 ~/.ssh/textsender-models_deploy_key
|
chmod 600 ~/.ssh/schedtxt-models_deploy_key
|
||||||
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
eval $(ssh-agent -s)
|
eval $(ssh-agent -s)
|
||||||
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
ssh-add -v ~/.ssh/schedtxt-models_deploy_key
|
||||||
cargo clippy -- -D warnings
|
cargo clippy -- -D warnings
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name: Rust Build
|
name: schedtxt_auth Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -17,16 +17,16 @@ jobs:
|
|||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.96.1
|
toolchain: 1.97
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/schedtxt-models_deploy_key
|
||||||
chmod 600 ~/.ssh/textsender-models_deploy_key
|
chmod 600 ~/.ssh/schedtxt-models_deploy_key
|
||||||
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
eval $(ssh-agent -s)
|
eval $(ssh-agent -s)
|
||||||
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
ssh-add -v ~/.ssh/schedtxt-models_deploy_key
|
||||||
|
|
||||||
cargo check
|
cargo check
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.96.1
|
toolchain: 1.97
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
# --- Add this step for explicit verification ---
|
# --- Add this step for explicit verification ---
|
||||||
- name: Verify Docker Environment
|
- name: Verify Docker Environment
|
||||||
@@ -81,12 +81,12 @@ jobs:
|
|||||||
ENABLE_REGISTRATION: 'TRUE'
|
ENABLE_REGISTRATION: 'TRUE'
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/schedtxt-models_deploy_key
|
||||||
chmod 600 ~/.ssh/textsender-models_deploy_key
|
chmod 600 ~/.ssh/schedtxt-models_deploy_key
|
||||||
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
eval $(ssh-agent -s)
|
eval $(ssh-agent -s)
|
||||||
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
ssh-add -v ~/.ssh/schedtxt-models_deploy_key
|
||||||
|
|
||||||
cargo test
|
cargo test
|
||||||
|
|
||||||
@@ -97,17 +97,17 @@ jobs:
|
|||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.96.1
|
toolchain: 1.97
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: rustup component add rustfmt
|
- run: rustup component add rustfmt
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/schedtxt-models_deploy_key
|
||||||
chmod 600 ~/.ssh/textsender-models_deploy_key
|
chmod 600 ~/.ssh/schedtxt-models_deploy_key
|
||||||
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
eval $(ssh-agent -s)
|
eval $(ssh-agent -s)
|
||||||
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
ssh-add -v ~/.ssh/schedtxt-models_deploy_key
|
||||||
cargo fmt --all -- --check
|
cargo fmt --all -- --check
|
||||||
|
|
||||||
clippy:
|
clippy:
|
||||||
@@ -117,17 +117,17 @@ jobs:
|
|||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.96.1
|
toolchain: 1.97
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: rustup component add clippy
|
- run: rustup component add clippy
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/schedtxt-models_deploy_key
|
||||||
chmod 600 ~/.ssh/textsender-models_deploy_key
|
chmod 600 ~/.ssh/schedtxt-models_deploy_key
|
||||||
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
eval $(ssh-agent -s)
|
eval $(ssh-agent -s)
|
||||||
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
ssh-add -v ~/.ssh/schedtxt-models_deploy_key
|
||||||
cargo clippy -- -D warnings
|
cargo clippy -- -D warnings
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@@ -137,14 +137,14 @@ jobs:
|
|||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.96.1
|
toolchain: 1.97
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender-models_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/schedtxt-models_deploy_key
|
||||||
chmod 600 ~/.ssh/textsender-models_deploy_key
|
chmod 600 ~/.ssh/schedtxt-models_deploy_key
|
||||||
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
eval $(ssh-agent -s)
|
eval $(ssh-agent -s)
|
||||||
ssh-add -v ~/.ssh/textsender-models_deploy_key
|
ssh-add -v ~/.ssh/schedtxt-models_deploy_key
|
||||||
cargo build --release
|
cargo build --release
|
||||||
|
|||||||
Generated
+85
-77
@@ -185,15 +185,15 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.12.0"
|
version = "1.12.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8ae3f5d315924270530207e2a68396c3cc547f6dca3fbdca317cfb1a51edb593"
|
checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.2.66"
|
version = "1.2.67"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f5d6cac793997bd970000024b2934968efe83b382de4fdcf4fcb46b6ee4ad996"
|
checksum = "e17dd265a7d0f31ef544e1b20e03add05d3b45b491b633b10d67145d2acc1a38"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"find-msvc-tools",
|
"find-msvc-tools",
|
||||||
"shlex",
|
"shlex",
|
||||||
@@ -231,6 +231,12 @@ dependencies = [
|
|||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "const-oid"
|
||||||
|
version = "0.10.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "const_format"
|
name = "const_format"
|
||||||
version = "0.2.36"
|
version = "0.2.36"
|
||||||
@@ -391,6 +397,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"
|
checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"block-buffer 0.12.1",
|
"block-buffer 0.12.1",
|
||||||
|
"const-oid",
|
||||||
"crypto-common 0.2.2",
|
"crypto-common 0.2.2",
|
||||||
"ctutils",
|
"ctutils",
|
||||||
]
|
]
|
||||||
@@ -704,9 +711,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "http-body"
|
name = "http-body"
|
||||||
version = "1.0.1"
|
version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184"
|
checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"http",
|
"http",
|
||||||
@@ -714,9 +721,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "http-body-util"
|
name = "http-body-util"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a"
|
checksum = "e9f41fd6a08e4d4ec69df65976da761afd5ad5e58a9d4acb46bd1c953a9e3ff2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
@@ -1012,9 +1019,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.8.2"
|
version = "2.8.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "88904434abc2901f197fe8cc55f0445e7ded921dba5911dad2e2b39b48e663c4"
|
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mime"
|
name = "mime"
|
||||||
@@ -1044,9 +1051,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mio"
|
name = "mio"
|
||||||
version = "1.2.1"
|
version = "1.2.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "02bd0af71c67b473010cbbc60715ee815645a4dc942899111f494b4b737d6fda"
|
checksum = "30d65c71f1ce40ab09135ce117d742b9f8a19ff91a41a8b57ed50bc2de59c427"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"wasi",
|
"wasi",
|
||||||
@@ -1277,9 +1284,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.12.4"
|
version = "1.13.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f1292b7759ae1cb9ec195452d1390a074f0cd8541ab7a5a8c31cd6db45d4a6ba"
|
checksum = "2a0e75113e14dc5acb068cd0786884f214f1312650a3d36d269f5c4f3cdee8a2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
@@ -1289,9 +1296,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-automata"
|
name = "regex-automata"
|
||||||
version = "0.4.14"
|
version = "0.4.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f"
|
checksum = "1f388202e4b80542a0921078cc23b6333bcf1409c1e3f86404cae4766a6131db"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
@@ -1306,9 +1313,9 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust-embed"
|
name = "rust-embed"
|
||||||
version = "8.11.0"
|
version = "8.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "04113cb9355a377d83f06ef1f0a45b8ab8cd7d8b1288160717d66df5c7988d27"
|
checksum = "e9e7760e252aaba7b09f4be00e36476cf585bdb68a53552ac954cdf504ab4bc9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rust-embed-impl",
|
"rust-embed-impl",
|
||||||
"rust-embed-utils",
|
"rust-embed-utils",
|
||||||
@@ -1317,10 +1324,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust-embed-impl"
|
name = "rust-embed-impl"
|
||||||
version = "8.11.0"
|
version = "8.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "da0902e4c7c8e997159ab384e6d0fc91c221375f6894346ae107f47dd0f3ccaa"
|
checksum = "3bcfc4d6f53af43755f7a723e4b6b8794fcce052a178dd8c6c1dadc5f5343097"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"mime_guess",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"rust-embed-utils",
|
"rust-embed-utils",
|
||||||
@@ -1330,11 +1338,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust-embed-utils"
|
name = "rust-embed-utils"
|
||||||
version = "8.11.0"
|
version = "8.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5bcdef0be6fe7f6fa333b1073c949729274b05f123a0ad7efcb8efd878e5c3b1"
|
checksum = "42ffa149f6aa81b58a5b3011d01a857c4ed12c7a732d2c51947a4c7c692185f0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"sha2 0.10.9",
|
"sha2 0.11.0",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1353,9 +1361,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustversion"
|
name = "rustversion"
|
||||||
version = "1.0.22"
|
version = "1.0.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
@@ -1381,6 +1389,44 @@ dependencies = [
|
|||||||
"windows-sys",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "schedtxt_auth"
|
||||||
|
version = "0.2.4"
|
||||||
|
dependencies = [
|
||||||
|
"argon2",
|
||||||
|
"axum",
|
||||||
|
"josekit",
|
||||||
|
"schedtxt_models",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"sqlx",
|
||||||
|
"time",
|
||||||
|
"tokio",
|
||||||
|
"tower",
|
||||||
|
"tower-http",
|
||||||
|
"tracing-subscriber",
|
||||||
|
"url",
|
||||||
|
"utoipa",
|
||||||
|
"utoipa-swagger-ui",
|
||||||
|
"uuid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "schedtxt_models"
|
||||||
|
version = "0.5.3"
|
||||||
|
source = "git+ssh://git@git.kundeng.us/phoenix/schedtxt_models.git?tag=v0.5.3#597af4e84c082bb437cc94817bb19592614681a5"
|
||||||
|
dependencies = [
|
||||||
|
"const_format",
|
||||||
|
"dotenvy",
|
||||||
|
"josekit",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"sqlx",
|
||||||
|
"time",
|
||||||
|
"utoipa",
|
||||||
|
"uuid",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scopeguard"
|
name = "scopeguard"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
@@ -1548,9 +1594,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "socket2"
|
name = "socket2"
|
||||||
version = "0.6.4"
|
version = "0.6.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "52d1cfed4120b4d927bf7c0f86d2087a4a7d6027c906d9f9d525a80573b9be51"
|
checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys",
|
"windows-sys",
|
||||||
@@ -1558,9 +1604,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "spin"
|
name = "spin"
|
||||||
version = "0.9.8"
|
version = "0.9.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lock_api",
|
"lock_api",
|
||||||
]
|
]
|
||||||
@@ -1809,44 +1855,6 @@ dependencies = [
|
|||||||
"windows-sys",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "textsender_auth"
|
|
||||||
version = "0.2.2"
|
|
||||||
dependencies = [
|
|
||||||
"argon2",
|
|
||||||
"axum",
|
|
||||||
"josekit",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"sqlx",
|
|
||||||
"textsender_models",
|
|
||||||
"time",
|
|
||||||
"tokio",
|
|
||||||
"tower",
|
|
||||||
"tower-http",
|
|
||||||
"tracing-subscriber",
|
|
||||||
"url",
|
|
||||||
"utoipa",
|
|
||||||
"utoipa-swagger-ui",
|
|
||||||
"uuid",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "textsender_models"
|
|
||||||
version = "0.5.1"
|
|
||||||
source = "git+ssh://git@git.kundeng.us/phoenix/textsender_models.git?tag=v0.5.1#151eeaacf64e255bde56a48df03f4c46ec77c235"
|
|
||||||
dependencies = [
|
|
||||||
"const_format",
|
|
||||||
"dotenvy",
|
|
||||||
"josekit",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"sqlx",
|
|
||||||
"time",
|
|
||||||
"utoipa",
|
|
||||||
"uuid",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "2.0.18"
|
version = "2.0.18"
|
||||||
@@ -1869,9 +1877,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thread_local"
|
name = "thread_local"
|
||||||
version = "1.1.9"
|
version = "1.1.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185"
|
checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
@@ -1918,9 +1926,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tinyvec"
|
name = "tinyvec"
|
||||||
version = "1.11.0"
|
version = "1.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3e61e67053d25a4e82c844e8424039d9745781b3fc4f32b8d55ed50f5f667ef3"
|
checksum = "bb4ebadaa0af04fab11ae01eb5f9fdb5f9c5b875506e210e71c07873528baa7f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tinyvec_macros",
|
"tinyvec_macros",
|
||||||
]
|
]
|
||||||
@@ -2194,9 +2202,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid"
|
name = "uuid"
|
||||||
version = "1.23.4"
|
version = "1.23.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bf80a72845275afea99e7f2b434723d3bc7e38470fcd1c7ed39a599c73319a53"
|
checksum = "ea5fab0d6c3c01ae70085a09cb03d4c7a1d6314e2b3e075392783396d724ca0a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom 0.4.3",
|
"getrandom 0.4.3",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
@@ -2412,15 +2420,15 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zlib-rs"
|
name = "zlib-rs"
|
||||||
version = "0.6.5"
|
version = "0.6.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5431d5661c32445236631278f27946e444ddafe4684cac70b185272d4f9c52d5"
|
checksum = "b142a20ec14a91d5bc708c1dc21b080c550113d8aa77afa29635673a65dd02c5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zmij"
|
name = "zmij"
|
||||||
version = "1.0.21"
|
version = "1.0.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
|
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zopfli"
|
name = "zopfli"
|
||||||
|
|||||||
+7
-5
@@ -1,8 +1,10 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "textsender_auth"
|
name = "schedtxt_auth"
|
||||||
version = "0.2.2"
|
version = "0.2.4"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.96.1"
|
license = "MIT"
|
||||||
|
description = "Auth API for sending text messages"
|
||||||
|
rust-version = "1.97"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
axum = { version = "0.8.9" }
|
axum = { version = "0.8.9" }
|
||||||
@@ -12,13 +14,13 @@ tokio = { version = "1.52.3", features = ["rt-multi-thread"] }
|
|||||||
tracing-subscriber = { version = "0.3.23" }
|
tracing-subscriber = { version = "0.3.23" }
|
||||||
tower-http = { version = "0.7.0", features = ["cors"] }
|
tower-http = { version = "0.7.0", features = ["cors"] }
|
||||||
sqlx = { version = "0.9.0", features = ["runtime-tokio", "tls-native-tls", "postgres", "time", "uuid"] }
|
sqlx = { version = "0.9.0", features = ["runtime-tokio", "tls-native-tls", "postgres", "time", "uuid"] }
|
||||||
uuid = { version = "1.23.3", 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"] }
|
||||||
textsender_models = { git = "ssh://git@git.kundeng.us/phoenix/textsender_models.git", tag = "v0.5.1", features = ["config", "user"] }
|
schedtxt_models = { git = "ssh://git@git.kundeng.us/phoenix/schedtxt_models.git", tag = "v0.5.3", features = ["config", "user"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tower = { version = "0.5.3", features = ["full"] }
|
tower = { version = "0.5.3", features = ["full"] }
|
||||||
|
|||||||
+4
-30
@@ -1,14 +1,7 @@
|
|||||||
# Stage 1: Build the application
|
FROM rust:1.97 as builder
|
||||||
# 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
|
|
||||||
|
|
||||||
# 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,55 +9,36 @@ 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.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/textsender_auth* # Clean up dummy build artifacts
|
rm -rf src target/release/deps/schedtxt_auth*
|
||||||
|
|
||||||
# Copy the actual source code
|
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
# 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)
|
||||||
RUN apt-get update && apt-get install -y ca-certificates libssl-dev libssl3 && rm -rf /var/lib/apt/lists/*
|
RUN apt-get update && apt-get install -y ca-certificates libssl-dev libssl3 && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Set the working directory
|
|
||||||
WORKDIR /usr/local/bin
|
WORKDIR /usr/local/bin
|
||||||
|
|
||||||
# Copy the compiled binary from the builder stage
|
COPY --from=builder /usr/src/app/target/release/schedtxt_auth .
|
||||||
COPY --from=builder /usr/src/app/target/release/textsender_auth .
|
|
||||||
|
|
||||||
# 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
|
|
||||||
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 9080
|
EXPOSE 9080
|
||||||
|
|
||||||
# Set the command to run your application
|
# Set the command to run your application
|
||||||
# Ensure this matches the binary name copied above
|
CMD ["./schedtxt_auth"]
|
||||||
CMD ["./textsender_auth"]
|
|
||||||
|
|||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
Copyright (c) 2026 Kun Deng.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person
|
||||||
|
obtaining a copy of this software and associated documentation
|
||||||
|
files (the "Software"), to deal in the Software without
|
||||||
|
restriction, including without limitation the rights to use,
|
||||||
|
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following
|
||||||
|
conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
||||||
@@ -1 +1,22 @@
|
|||||||
|
# schedtxt_auth
|
||||||
|
Auth API for `schedtxt` project.
|
||||||
|
|
||||||
|
|
||||||
|
## Getting started
|
||||||
|
Quickest way to get started is with docker, make sure that it is installed. Copy over
|
||||||
|
the `.env.docker.sample` file and name it `.env`.
|
||||||
|
|
||||||
|
For `SECRET_KEY` provide a key that is at least 32-characters. This is used for token
|
||||||
|
creation. Additionally, provide credentials for the database for the `DB_*` keys.
|
||||||
|
|
||||||
|
Make sure that `ENABLE_REGISTRATION` is set to true, otherwise registration will not work.
|
||||||
|
|
||||||
|
Build the container
|
||||||
|
```
|
||||||
|
docker compose build
|
||||||
|
```
|
||||||
|
|
||||||
|
Bring up the container
|
||||||
|
```
|
||||||
|
docker compose up
|
||||||
|
```
|
||||||
|
|||||||
+11
-15
@@ -1,31 +1,28 @@
|
|||||||
version: '3.8' # Use a recent version
|
version: '3.8' # Use a recent version
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# Your Rust Application Service
|
|
||||||
auth_api:
|
auth_api:
|
||||||
build: # Tells docker-compose to build the Dockerfile in the current directory
|
build:
|
||||||
context: .
|
context: .
|
||||||
ssh: ["default"] # Uses host's SSH agent
|
ssh: ["default"]
|
||||||
container_name: textsender_auth # Optional: Give the container a specific name
|
container_name: schedtxt_auth
|
||||||
ports:
|
ports:
|
||||||
# Map host port 8000 to container port 3000 (adjust as needed)
|
|
||||||
- "9080:9080"
|
- "9080:9080"
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
depends_on:
|
depends_on:
|
||||||
auth_db:
|
auth_db:
|
||||||
condition: service_healthy # Wait for the DB to be healthy before starting the app
|
condition: service_healthy
|
||||||
restart: unless-stopped # Optional: Restart policy
|
restart: unless-stopped
|
||||||
|
|
||||||
# PostgreSQL Database Service
|
# PostgreSQL Database Service
|
||||||
auth_db:
|
auth_db:
|
||||||
image: postgres:18.4-alpine # Use an official Postgres image (Alpine variant is smaller)
|
image: postgres:18.4-alpine
|
||||||
container_name: textsender_auth_db # Optional: Give the container a specific name
|
container_name: schedtxt_auth_db
|
||||||
environment:
|
environment:
|
||||||
# These MUST match the user, password, and database name in the DATABASE_URL above
|
POSTGRES_USER: ${DB_AUTH_USER:-schedtxt_op}
|
||||||
POSTGRES_USER: ${DB_AUTH_USER:-textsender_op}
|
|
||||||
POSTGRES_PASSWORD: ${DB_AUTH_PASSWORD:-password}
|
POSTGRES_PASSWORD: ${DB_AUTH_PASSWORD:-password}
|
||||||
POSTGRES_DB: ${DB_AUTH_NAME:-textsender_auth_db}
|
POSTGRES_DB: ${DB_AUTH_NAME:-schedtxt_auth_db}
|
||||||
volumes:
|
volumes:
|
||||||
# Persist database data using a named volume
|
# Persist database data using a named volume
|
||||||
- postgres_data:/var/lib/postgresql
|
- postgres_data:/var/lib/postgresql
|
||||||
@@ -38,9 +35,8 @@ services:
|
|||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
start_period: 10s
|
start_period: 10s
|
||||||
restart: always # Optional: Restart policy
|
restart: always
|
||||||
|
|
||||||
# Define the named volume for data persistence
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
driver: local # Use the default local driver
|
driver: local
|
||||||
|
|||||||
+19
-19
@@ -84,13 +84,13 @@ pub mod response {
|
|||||||
#[derive(Default, Deserialize, Serialize, utoipa::ToSchema)]
|
#[derive(Default, Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
pub struct LoginResponse {
|
pub struct LoginResponse {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub data: Vec<textsender_models::token::LoginResult>,
|
pub data: Vec<schedtxt_models::token::LoginResult>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Deserialize, Serialize, utoipa::ToSchema)]
|
#[derive(Default, Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
pub struct ServiceUserLoginResponse {
|
pub struct ServiceUserLoginResponse {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub data: Vec<textsender_models::token::LoginResult>,
|
pub data: Vec<schedtxt_models::token::LoginResult>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn extract(
|
pub async fn extract(
|
||||||
@@ -114,7 +114,7 @@ pub mod response {
|
|||||||
#[derive(Deserialize, Serialize, utoipa::ToSchema)]
|
#[derive(Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
pub struct RefreshTokenResponse {
|
pub struct RefreshTokenResponse {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub data: Vec<textsender_models::token::LoginResult>,
|
pub data: Vec<schedtxt_models::token::LoginResult>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, utoipa::ToSchema)]
|
#[derive(Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
@@ -126,13 +126,13 @@ pub mod response {
|
|||||||
#[derive(Deserialize, Serialize, utoipa::ToSchema)]
|
#[derive(Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
pub struct UserUpdateNameResponse {
|
pub struct UserUpdateNameResponse {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub data: Vec<textsender_models::user::User>,
|
pub data: Vec<schedtxt_models::user::User>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Deserialize, Serialize, utoipa::ToSchema)]
|
#[derive(Default, Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
pub struct GetUserProfileResponse {
|
pub struct GetUserProfileResponse {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub data: Vec<textsender_models::user::UserProfile>,
|
pub data: Vec<schedtxt_models::user::UserProfile>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ pub async fn user_login(
|
|||||||
if matches {
|
if matches {
|
||||||
// Create token
|
// Create token
|
||||||
let key =
|
let key =
|
||||||
textsender_models::envy::environment::get_secret_key().value;
|
schedtxt_models::envy::environment::get_secret_key().value;
|
||||||
let cst = match token_stuff::create_token(&key, &user.id) {
|
let cst = match token_stuff::create_token(&key, &user.id) {
|
||||||
Ok(token) => token,
|
Ok(token) => token,
|
||||||
Err(_err) => {
|
Err(_err) => {
|
||||||
@@ -225,11 +225,11 @@ pub async fn user_login(
|
|||||||
axum::http::StatusCode::OK,
|
axum::http::StatusCode::OK,
|
||||||
axum::Json(response::LoginResponse {
|
axum::Json(response::LoginResponse {
|
||||||
message: String::from("Successful"),
|
message: String::from("Successful"),
|
||||||
data: vec![textsender_models::token::LoginResult {
|
data: vec![schedtxt_models::token::LoginResult {
|
||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
access_token: cst.access_token,
|
access_token: cst.access_token,
|
||||||
token_type: String::from(
|
token_type: String::from(
|
||||||
textsender_models::token::TOKEN_TYPE,
|
schedtxt_models::token::TOKEN_TYPE,
|
||||||
),
|
),
|
||||||
issued_at: cst.issued,
|
issued_at: cst.issued,
|
||||||
expires_in: cst.expires_in,
|
expires_in: cst.expires_in,
|
||||||
@@ -351,7 +351,7 @@ pub async fn service_user_login(
|
|||||||
// Create token
|
// Create token
|
||||||
println!("Creating token");
|
println!("Creating token");
|
||||||
let key =
|
let key =
|
||||||
textsender_models::envy::environment::get_secret_key().value;
|
schedtxt_models::envy::environment::get_secret_key().value;
|
||||||
let cst =
|
let cst =
|
||||||
token_stuff::create_token(&key, &service_user.id).unwrap();
|
token_stuff::create_token(&key, &service_user.id).unwrap();
|
||||||
|
|
||||||
@@ -370,11 +370,11 @@ pub async fn service_user_login(
|
|||||||
message: String::from(
|
message: String::from(
|
||||||
super::messages::SUCCESSFUL_MESSAGE,
|
super::messages::SUCCESSFUL_MESSAGE,
|
||||||
),
|
),
|
||||||
data: vec![textsender_models::token::LoginResult {
|
data: vec![schedtxt_models::token::LoginResult {
|
||||||
user_id: service_user.id,
|
user_id: service_user.id,
|
||||||
access_token: cst.access_token,
|
access_token: cst.access_token,
|
||||||
token_type: String::from(
|
token_type: String::from(
|
||||||
textsender_models::token::TOKEN_TYPE,
|
schedtxt_models::token::TOKEN_TYPE,
|
||||||
),
|
),
|
||||||
issued_at: cst.issued,
|
issued_at: cst.issued,
|
||||||
expires_in: cst.expires_in,
|
expires_in: cst.expires_in,
|
||||||
@@ -456,12 +456,12 @@ pub async fn refresh_token(
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
let key = textsender_models::envy::environment::get_secret_key().value;
|
let key = schedtxt_models::envy::environment::get_secret_key().value;
|
||||||
if token_stuff::verify_token(&key, &payload.access_token) {
|
if token_stuff::verify_token(&key, &payload.access_token) {
|
||||||
match token_stuff::extract_id_from_token(&key, &payload.access_token) {
|
match token_stuff::extract_id_from_token(&key, &payload.access_token) {
|
||||||
Ok(id) => {
|
Ok(id) => {
|
||||||
let generate_service_token =
|
let generate_service_token =
|
||||||
|id, key| -> Option<textsender_models::token::CreateTokenResult> {
|
|id, key| -> Option<schedtxt_models::token::CreateTokenResult> {
|
||||||
token_stuff::create_service_refresh_token(key, id).ok()
|
token_stuff::create_service_refresh_token(key, id).ok()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -475,12 +475,12 @@ pub async fn refresh_token(
|
|||||||
Some(cst) => {
|
Some(cst) => {
|
||||||
response.message =
|
response.message =
|
||||||
String::from(super::messages::SUCCESSFUL_MESSAGE);
|
String::from(super::messages::SUCCESSFUL_MESSAGE);
|
||||||
let lr = textsender_models::token::LoginResult {
|
let lr = schedtxt_models::token::LoginResult {
|
||||||
user_id: id,
|
user_id: id,
|
||||||
access_token: cst.access_token,
|
access_token: cst.access_token,
|
||||||
issued_at: cst.issued,
|
issued_at: cst.issued,
|
||||||
expires_in: cst.expires_in,
|
expires_in: cst.expires_in,
|
||||||
token_type: String::from(textsender_models::token::TOKEN_TYPE),
|
token_type: String::from(schedtxt_models::token::TOKEN_TYPE),
|
||||||
};
|
};
|
||||||
response.data.push(lr);
|
response.data.push(lr);
|
||||||
(axum::http::StatusCode::OK, axum::Json(response))
|
(axum::http::StatusCode::OK, axum::Json(response))
|
||||||
@@ -500,13 +500,13 @@ pub async fn refresh_token(
|
|||||||
Some(cst) => {
|
Some(cst) => {
|
||||||
response.message =
|
response.message =
|
||||||
String::from(super::messages::SUCCESSFUL_MESSAGE);
|
String::from(super::messages::SUCCESSFUL_MESSAGE);
|
||||||
let lr = textsender_models::token::LoginResult {
|
let lr = schedtxt_models::token::LoginResult {
|
||||||
user_id: id,
|
user_id: id,
|
||||||
access_token: cst.access_token,
|
access_token: cst.access_token,
|
||||||
issued_at: cst.issued,
|
issued_at: cst.issued,
|
||||||
expires_in: cst.expires_in,
|
expires_in: cst.expires_in,
|
||||||
token_type: String::from(
|
token_type: String::from(
|
||||||
textsender_models::token::TOKEN_TYPE,
|
schedtxt_models::token::TOKEN_TYPE,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
response.data.push(lr);
|
response.data.push(lr);
|
||||||
@@ -785,7 +785,7 @@ pub async fn update_name_of_user(
|
|||||||
axum::http::StatusCode::OK,
|
axum::http::StatusCode::OK,
|
||||||
axum::Json(response::UserUpdateNameResponse {
|
axum::Json(response::UserUpdateNameResponse {
|
||||||
message: String::from(super::messages::SUCCESSFUL_MESSAGE),
|
message: String::from(super::messages::SUCCESSFUL_MESSAGE),
|
||||||
data: vec![textsender_models::user::User {
|
data: vec![schedtxt_models::user::User {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
phone_number: user.phone_number,
|
phone_number: user.phone_number,
|
||||||
firstname: payload.firstname,
|
firstname: payload.firstname,
|
||||||
@@ -844,7 +844,7 @@ pub async fn get_user_profile(
|
|||||||
|
|
||||||
match repo::user::get_with_id(&pool, &id).await {
|
match repo::user::get_with_id(&pool, &id).await {
|
||||||
Ok(user) => {
|
Ok(user) => {
|
||||||
let user_profile = textsender_models::user::UserProfile {
|
let user_profile = schedtxt_models::user::UserProfile {
|
||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
phone_number: user.phone_number,
|
phone_number: user.phone_number,
|
||||||
firstname: user.firstname,
|
firstname: user.firstname,
|
||||||
|
|||||||
@@ -49,22 +49,22 @@ pub mod response {
|
|||||||
#[derive(Deserialize, Serialize, utoipa::ToSchema)]
|
#[derive(Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
pub struct Response {
|
pub struct Response {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub data: Vec<textsender_models::user::User>,
|
pub data: Vec<schedtxt_models::user::User>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Deserialize, Serialize, utoipa::ToSchema)]
|
#[derive(Default, Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
pub struct RegisterServiceUserResponse {
|
pub struct RegisterServiceUserResponse {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub data: Vec<textsender_models::user::ServiceUser>,
|
pub data: Vec<schedtxt_models::user::ServiceUser>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn generate_the_salt() -> (
|
pub fn generate_the_salt() -> (
|
||||||
argon2::password_hash::SaltString,
|
argon2::password_hash::SaltString,
|
||||||
textsender_models::user::Salt,
|
schedtxt_models::user::Salt,
|
||||||
) {
|
) {
|
||||||
let salt_string = hashing::generate_salt().unwrap();
|
let salt_string = hashing::generate_salt().unwrap();
|
||||||
let salt = textsender_models::user::Salt::default();
|
let salt = schedtxt_models::user::Salt::default();
|
||||||
(salt_string, salt)
|
(salt_string, salt)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ pub async fn register_user(
|
|||||||
};
|
};
|
||||||
|
|
||||||
if registration_enabled {
|
if registration_enabled {
|
||||||
let mut user = textsender_models::user::User {
|
let mut user = schedtxt_models::user::User {
|
||||||
username: payload.username.clone(),
|
username: payload.username.clone(),
|
||||||
password: payload.password.clone(),
|
password: payload.password.clone(),
|
||||||
phone_number: payload.phone_number.clone(),
|
phone_number: payload.phone_number.clone(),
|
||||||
@@ -181,7 +181,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 = textsender_models::envy::environment::get_env(&key);
|
let var = schedtxt_models::envy::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" {
|
||||||
@@ -248,7 +248,7 @@ pub async fn register_service_user(
|
|||||||
} else {
|
} else {
|
||||||
let (generate_salt, mut salt) = generate_the_salt();
|
let (generate_salt, mut salt) = generate_the_salt();
|
||||||
salt.id = repo::salt::insert(&pool, &salt).await.unwrap();
|
salt.id = repo::salt::insert(&pool, &salt).await.unwrap();
|
||||||
let mut service_user = textsender_models::user::ServiceUser {
|
let mut service_user = schedtxt_models::user::ServiceUser {
|
||||||
username: payload.username.clone(),
|
username: payload.username.clone(),
|
||||||
passphrase: hashing::hash_password(&payload.passphrase, &generate_salt)
|
passphrase: hashing::hash_password(&payload.passphrase, &generate_salt)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
|||||||
+1
-1
@@ -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 = textsender_models::envy::environment::get_db_url().value;
|
let database_url = schedtxt_models::envy::environment::get_db_url().value;
|
||||||
println!("Database url: {database_url}");
|
println!("Database url: {database_url}");
|
||||||
|
|
||||||
PgPoolOptions::new()
|
PgPoolOptions::new()
|
||||||
|
|||||||
+3
-3
@@ -54,11 +54,11 @@ pub 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(textsender_models::envy::keys::APP_ENV).as_deref() {
|
match std::env::var(schedtxt_models::envy::keys::APP_ENV).as_deref() {
|
||||||
Ok("production") => {
|
Ok("production") => {
|
||||||
let allowed_origins_env =
|
let allowed_origins_env =
|
||||||
textsender_models::envy::environment::get_allowed_origins();
|
schedtxt_models::envy::environment::get_allowed_origins();
|
||||||
match textsender_models::envy::utility::delimitize(&allowed_origins_env) {
|
match schedtxt_models::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()
|
||||||
|
|||||||
+2
-2
@@ -3,10 +3,10 @@ async fn main() {
|
|||||||
// initialize tracing
|
// initialize tracing
|
||||||
tracing_subscriber::fmt::init();
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
let app = textsender_auth::init::app().await;
|
let app = schedtxt_auth::init::app().await;
|
||||||
|
|
||||||
// run our app with hyper, listening globally on port 9080
|
// run our app with hyper, listening globally on port 9080
|
||||||
let url = textsender_auth::config::get_full();
|
let url = schedtxt_auth::config::get_full();
|
||||||
let listener = tokio::net::TcpListener::bind(url).await.unwrap();
|
let listener = tokio::net::TcpListener::bind(url).await.unwrap();
|
||||||
axum::serve(listener, app).await.unwrap();
|
axum::serve(listener, app).await.unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-10
@@ -12,7 +12,7 @@ pub mod user {
|
|||||||
pub async fn get(
|
pub async fn get(
|
||||||
pool: &sqlx::PgPool,
|
pool: &sqlx::PgPool,
|
||||||
username: &String,
|
username: &String,
|
||||||
) -> Result<textsender_models::user::User, sqlx::Error> {
|
) -> Result<schedtxt_models::user::User, sqlx::Error> {
|
||||||
let result = sqlx::query(
|
let result = sqlx::query(
|
||||||
r#"
|
r#"
|
||||||
SELECT id, username, password, phone_number, salt_id, firstname, lastname, created, last_login FROM "user" WHERE username = $1
|
SELECT id, username, password, phone_number, salt_id, firstname, lastname, created, last_login FROM "user" WHERE username = $1
|
||||||
@@ -24,7 +24,7 @@ pub mod user {
|
|||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(r) => match r {
|
Ok(r) => match r {
|
||||||
Some(r) => Ok(textsender_models::user::User {
|
Some(r) => Ok(schedtxt_models::user::User {
|
||||||
id: r.try_get("id")?,
|
id: r.try_get("id")?,
|
||||||
username: r.try_get("username")?,
|
username: r.try_get("username")?,
|
||||||
password: r.try_get("password")?,
|
password: r.try_get("password")?,
|
||||||
@@ -44,7 +44,7 @@ pub mod user {
|
|||||||
pub async fn get_with_id(
|
pub async fn get_with_id(
|
||||||
pool: &sqlx::PgPool,
|
pool: &sqlx::PgPool,
|
||||||
id: &uuid::Uuid,
|
id: &uuid::Uuid,
|
||||||
) -> Result<textsender_models::user::User, sqlx::Error> {
|
) -> Result<schedtxt_models::user::User, sqlx::Error> {
|
||||||
match sqlx::query(
|
match sqlx::query(
|
||||||
r#"
|
r#"
|
||||||
SELECT id, username, password, phone_number, salt_id, firstname, lastname, created, last_login FROM "user" WHERE id = $1
|
SELECT id, username, password, phone_number, salt_id, firstname, lastname, created, last_login FROM "user" WHERE id = $1
|
||||||
@@ -54,7 +54,7 @@ pub mod user {
|
|||||||
.fetch_optional(pool)
|
.fetch_optional(pool)
|
||||||
.await {
|
.await {
|
||||||
Ok(r) => match r {
|
Ok(r) => match r {
|
||||||
Some(r) => Ok(textsender_models::user::User {
|
Some(r) => Ok(schedtxt_models::user::User {
|
||||||
id: r.try_get("id")?,
|
id: r.try_get("id")?,
|
||||||
username: r.try_get("username")?,
|
username: r.try_get("username")?,
|
||||||
password: r.try_get("password")?,
|
password: r.try_get("password")?,
|
||||||
@@ -73,7 +73,7 @@ pub mod user {
|
|||||||
|
|
||||||
pub async fn update_last_login(
|
pub async fn update_last_login(
|
||||||
pool: &sqlx::PgPool,
|
pool: &sqlx::PgPool,
|
||||||
user: &textsender_models::user::User,
|
user: &schedtxt_models::user::User,
|
||||||
time: &time::OffsetDateTime,
|
time: &time::OffsetDateTime,
|
||||||
) -> Result<time::OffsetDateTime, sqlx::Error> {
|
) -> Result<time::OffsetDateTime, sqlx::Error> {
|
||||||
let result = sqlx::query(
|
let result = sqlx::query(
|
||||||
@@ -106,7 +106,7 @@ pub mod user {
|
|||||||
|
|
||||||
pub async fn update_password(
|
pub async fn update_password(
|
||||||
pool: &sqlx::PgPool,
|
pool: &sqlx::PgPool,
|
||||||
user: &textsender_models::user::User,
|
user: &schedtxt_models::user::User,
|
||||||
updated_hashed_password: &String,
|
updated_hashed_password: &String,
|
||||||
) -> Result<(), sqlx::Error> {
|
) -> Result<(), sqlx::Error> {
|
||||||
match sqlx::query(
|
match sqlx::query(
|
||||||
@@ -189,7 +189,7 @@ pub mod user {
|
|||||||
|
|
||||||
pub async fn insert(
|
pub async fn insert(
|
||||||
pool: &sqlx::PgPool,
|
pool: &sqlx::PgPool,
|
||||||
user: &textsender_models::user::User,
|
user: &schedtxt_models::user::User,
|
||||||
) -> Result<(uuid::Uuid, std::option::Option<time::OffsetDateTime>), sqlx::Error> {
|
) -> Result<(uuid::Uuid, std::option::Option<time::OffsetDateTime>), sqlx::Error> {
|
||||||
let row = sqlx::query(
|
let row = sqlx::query(
|
||||||
r#"
|
r#"
|
||||||
@@ -237,7 +237,7 @@ pub mod salt {
|
|||||||
pub async fn get(
|
pub async fn get(
|
||||||
pool: &sqlx::PgPool,
|
pool: &sqlx::PgPool,
|
||||||
id: &uuid::Uuid,
|
id: &uuid::Uuid,
|
||||||
) -> Result<textsender_models::user::Salt, sqlx::Error> {
|
) -> Result<schedtxt_models::user::Salt, sqlx::Error> {
|
||||||
let result = sqlx::query(
|
let result = sqlx::query(
|
||||||
r#"
|
r#"
|
||||||
SELECT id, salt FROM "salt" WHERE id = $1
|
SELECT id, salt FROM "salt" WHERE id = $1
|
||||||
@@ -249,7 +249,7 @@ pub mod salt {
|
|||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(r) => match r {
|
Ok(r) => match r {
|
||||||
Some(r) => Ok(textsender_models::user::Salt {
|
Some(r) => Ok(schedtxt_models::user::Salt {
|
||||||
id: r.try_get("id")?,
|
id: r.try_get("id")?,
|
||||||
salt: r.try_get("salt")?,
|
salt: r.try_get("salt")?,
|
||||||
}),
|
}),
|
||||||
@@ -261,7 +261,7 @@ pub mod salt {
|
|||||||
|
|
||||||
pub async fn insert(
|
pub async fn insert(
|
||||||
pool: &sqlx::PgPool,
|
pool: &sqlx::PgPool,
|
||||||
salt: &textsender_models::user::Salt,
|
salt: &schedtxt_models::user::Salt,
|
||||||
) -> Result<uuid::Uuid, sqlx::Error> {
|
) -> Result<uuid::Uuid, sqlx::Error> {
|
||||||
let row = sqlx::query(
|
let row = sqlx::query(
|
||||||
r#"
|
r#"
|
||||||
|
|||||||
+7
-7
@@ -52,7 +52,7 @@ pub async fn get_passphrase(
|
|||||||
pub async fn get(
|
pub async fn get(
|
||||||
pool: &sqlx::PgPool,
|
pool: &sqlx::PgPool,
|
||||||
id: &uuid::Uuid,
|
id: &uuid::Uuid,
|
||||||
) -> Result<textsender_models::user::ServiceUser, sqlx::Error> {
|
) -> Result<schedtxt_models::user::ServiceUser, sqlx::Error> {
|
||||||
match sqlx::query(
|
match sqlx::query(
|
||||||
r#"SELECT id, username, passphrase, created, last_login, salt_id FROM "service_user" WHERE id = $1"#
|
r#"SELECT id, username, passphrase, created, last_login, salt_id FROM "service_user" WHERE id = $1"#
|
||||||
).bind(id)
|
).bind(id)
|
||||||
@@ -68,7 +68,7 @@ pub async fn get(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let service_user = textsender_models::user::ServiceUser {
|
let service_user = schedtxt_models::user::ServiceUser {
|
||||||
id: row.try_get("id")?,
|
id: row.try_get("id")?,
|
||||||
username: row.try_get("username")?,
|
username: row.try_get("username")?,
|
||||||
passphrase: row.try_get("passphrase")?,
|
passphrase: row.try_get("passphrase")?,
|
||||||
@@ -88,7 +88,7 @@ pub async fn get(
|
|||||||
pub async fn get_with_username(
|
pub async fn get_with_username(
|
||||||
pool: &sqlx::PgPool,
|
pool: &sqlx::PgPool,
|
||||||
username: &String,
|
username: &String,
|
||||||
) -> Result<textsender_models::user::ServiceUser, sqlx::Error> {
|
) -> Result<schedtxt_models::user::ServiceUser, sqlx::Error> {
|
||||||
match sqlx::query(
|
match sqlx::query(
|
||||||
r#"SELECT id, username, passphrase, created, last_login, salt_id FROM "service_user" WHERE username = $1"#
|
r#"SELECT id, username, passphrase, created, last_login, salt_id FROM "service_user" WHERE username = $1"#
|
||||||
).bind(username)
|
).bind(username)
|
||||||
@@ -104,7 +104,7 @@ pub async fn get_with_username(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let service_user = textsender_models::user::ServiceUser {
|
let service_user = schedtxt_models::user::ServiceUser {
|
||||||
id: row.try_get("id")?,
|
id: row.try_get("id")?,
|
||||||
username: row.try_get("username")?,
|
username: row.try_get("username")?,
|
||||||
passphrase: row.try_get("passphrase")?,
|
passphrase: row.try_get("passphrase")?,
|
||||||
@@ -123,7 +123,7 @@ pub async fn get_with_username(
|
|||||||
|
|
||||||
pub async fn update_last_login(
|
pub async fn update_last_login(
|
||||||
pool: &sqlx::PgPool,
|
pool: &sqlx::PgPool,
|
||||||
service_user: &textsender_models::user::ServiceUser,
|
service_user: &schedtxt_models::user::ServiceUser,
|
||||||
time: &time::OffsetDateTime,
|
time: &time::OffsetDateTime,
|
||||||
) -> Result<time::OffsetDateTime, sqlx::Error> {
|
) -> Result<time::OffsetDateTime, sqlx::Error> {
|
||||||
let result = sqlx::query(
|
let result = sqlx::query(
|
||||||
@@ -156,7 +156,7 @@ pub async fn update_last_login(
|
|||||||
|
|
||||||
pub async fn update_passphrase(
|
pub async fn update_passphrase(
|
||||||
pool: &sqlx::PgPool,
|
pool: &sqlx::PgPool,
|
||||||
user: &textsender_models::user::ServiceUser,
|
user: &schedtxt_models::user::ServiceUser,
|
||||||
updated_hashed_passphrase: &String,
|
updated_hashed_passphrase: &String,
|
||||||
) -> Result<(), sqlx::Error> {
|
) -> Result<(), sqlx::Error> {
|
||||||
match sqlx::query(
|
match sqlx::query(
|
||||||
@@ -182,7 +182,7 @@ pub async fn update_passphrase(
|
|||||||
|
|
||||||
pub async fn insert(
|
pub async fn insert(
|
||||||
pool: &sqlx::PgPool,
|
pool: &sqlx::PgPool,
|
||||||
service_user: &textsender_models::user::ServiceUser,
|
service_user: &schedtxt_models::user::ServiceUser,
|
||||||
) -> Result<(uuid::Uuid, time::OffsetDateTime), sqlx::Error> {
|
) -> Result<(uuid::Uuid, time::OffsetDateTime), sqlx::Error> {
|
||||||
match sqlx::query(
|
match sqlx::query(
|
||||||
r#"INSERT INTO "service_user" (username, passphrase, salt_id)
|
r#"INSERT INTO "service_user" (username, passphrase, salt_id)
|
||||||
|
|||||||
+14
-14
@@ -8,8 +8,8 @@ use time;
|
|||||||
|
|
||||||
pub const KEY_ENV: &str = "SECRET_KEY";
|
pub const KEY_ENV: &str = "SECRET_KEY";
|
||||||
pub const MESSAGE: &str = "Something random";
|
pub const MESSAGE: &str = "Something random";
|
||||||
pub const ISSUER: &str = "textsender_auth";
|
pub const ISSUER: &str = "schedtxt_auth";
|
||||||
pub const AUDIENCE: &str = "textsender";
|
pub const AUDIENCE: &str = "schedtxt";
|
||||||
|
|
||||||
pub fn get_expiration(issued: &time::OffsetDateTime) -> Result<time::OffsetDateTime, time::Error> {
|
pub fn get_expiration(issued: &time::OffsetDateTime) -> Result<time::OffsetDateTime, time::Error> {
|
||||||
let duration_expire = time::Duration::hours(4);
|
let duration_expire = time::Duration::hours(4);
|
||||||
@@ -19,40 +19,40 @@ pub fn get_expiration(issued: &time::OffsetDateTime) -> Result<time::OffsetDateT
|
|||||||
pub fn create_token(
|
pub fn create_token(
|
||||||
provided_key: &str,
|
provided_key: &str,
|
||||||
id: &uuid::Uuid,
|
id: &uuid::Uuid,
|
||||||
) -> Result<textsender_models::token::CreateTokenResult, josekit::JoseError> {
|
) -> Result<schedtxt_models::token::CreateTokenResult, josekit::JoseError> {
|
||||||
let resource = textsender_models::token::TokenResource {
|
let resource = schedtxt_models::token::TokenResource {
|
||||||
message: String::from(MESSAGE),
|
message: String::from(MESSAGE),
|
||||||
issuer: String::from(ISSUER),
|
issuer: String::from(ISSUER),
|
||||||
audiences: vec![String::from(AUDIENCE)],
|
audiences: vec![String::from(AUDIENCE)],
|
||||||
user_id: *id,
|
user_id: *id,
|
||||||
};
|
};
|
||||||
textsender_models::token::create_token(provided_key, resource, time::Duration::hours(4))
|
schedtxt_models::token::create_token(provided_key, resource, time::Duration::hours(4))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_service_token(
|
pub fn create_service_token(
|
||||||
provided: &str,
|
provided: &str,
|
||||||
id: &uuid::Uuid,
|
id: &uuid::Uuid,
|
||||||
) -> Result<textsender_models::token::CreateTokenResult, josekit::JoseError> {
|
) -> Result<schedtxt_models::token::CreateTokenResult, josekit::JoseError> {
|
||||||
let resource = textsender_models::token::TokenResource {
|
let resource = schedtxt_models::token::TokenResource {
|
||||||
message: String::from(SERVICE_SUBJECT),
|
message: String::from(SERVICE_SUBJECT),
|
||||||
issuer: String::from(ISSUER),
|
issuer: String::from(ISSUER),
|
||||||
audiences: vec![String::from(AUDIENCE)],
|
audiences: vec![String::from(AUDIENCE)],
|
||||||
user_id: *id,
|
user_id: *id,
|
||||||
};
|
};
|
||||||
textsender_models::token::create_token(provided, resource, time::Duration::hours(1))
|
schedtxt_models::token::create_token(provided, resource, time::Duration::hours(1))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_service_refresh_token(
|
pub fn create_service_refresh_token(
|
||||||
key: &str,
|
key: &str,
|
||||||
id: &uuid::Uuid,
|
id: &uuid::Uuid,
|
||||||
) -> Result<textsender_models::token::CreateTokenResult, josekit::JoseError> {
|
) -> Result<schedtxt_models::token::CreateTokenResult, josekit::JoseError> {
|
||||||
let resource = textsender_models::token::TokenResource {
|
let resource = schedtxt_models::token::TokenResource {
|
||||||
message: String::from(SERVICE_SUBJECT),
|
message: String::from(SERVICE_SUBJECT),
|
||||||
issuer: String::from(ISSUER),
|
issuer: String::from(ISSUER),
|
||||||
audiences: vec![String::from(AUDIENCE)],
|
audiences: vec![String::from(AUDIENCE)],
|
||||||
user_id: *id,
|
user_id: *id,
|
||||||
};
|
};
|
||||||
textsender_models::token::create_token(key, resource, time::Duration::hours(4))
|
schedtxt_models::token::create_token(key, resource, time::Duration::hours(4))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn verify_token(key: &str, token: &str) -> bool {
|
pub fn verify_token(key: &str, token: &str) -> bool {
|
||||||
@@ -78,9 +78,9 @@ pub fn extract_id_from_token(key: &str, token: &str) -> Result<uuid::Uuid, std::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const APP_TOKEN_TYPE: &str = "Textsender_App";
|
pub const APP_TOKEN_TYPE: &str = "Schedtxt_App";
|
||||||
pub const APP_SUBJECT: &str = "Something random";
|
pub const APP_SUBJECT: &str = "Something random";
|
||||||
pub const SERVICE_TOKEN_TYPE: &str = "Textsender_Service";
|
pub const SERVICE_TOKEN_TYPE: &str = "Schedtxt_Service";
|
||||||
pub const SERVICE_SUBJECT: &str = "Service random";
|
pub const SERVICE_SUBJECT: &str = "Service random";
|
||||||
|
|
||||||
pub fn get_token_type(key: &str, token: &str) -> Result<String, std::io::Error> {
|
pub fn get_token_type(key: &str, token: &str) -> Result<String, std::io::Error> {
|
||||||
@@ -119,7 +119,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_tokenize() {
|
fn test_tokenize() {
|
||||||
let special_key = textsender_models::envy::environment::get_secret_key();
|
let special_key = schedtxt_models::envy::environment::get_secret_key();
|
||||||
let id = uuid::Uuid::new_v4();
|
let id = uuid::Uuid::new_v4();
|
||||||
match create_token(&special_key.value, &id) {
|
match create_token(&special_key.value, &id) {
|
||||||
Ok(cst) => {
|
Ok(cst) => {
|
||||||
|
|||||||
+15
-15
@@ -1,7 +1,7 @@
|
|||||||
use textsender_auth;
|
use schedtxt_auth;
|
||||||
use textsender_auth::callers;
|
use schedtxt_auth::callers;
|
||||||
use textsender_auth::db;
|
use schedtxt_auth::db;
|
||||||
use textsender_auth::init;
|
use schedtxt_auth::init;
|
||||||
|
|
||||||
mod db_mgr {
|
mod db_mgr {
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
@@ -9,7 +9,7 @@ mod db_mgr {
|
|||||||
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 = textsender_models::envy::environment::get_db_url().value;
|
let tm_db_url = schedtxt_models::envy::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
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ mod db_mgr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 = textsender_models::envy::environment::get_db_url().value;
|
let db_url = schedtxt_models::envy::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
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ mod db_mgr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 = textsender_models::envy::environment::get_db_url().value;
|
let database_url = schedtxt_models::envy::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" {
|
||||||
@@ -231,7 +231,7 @@ pub mod requests {
|
|||||||
user_id: &uuid::Uuid,
|
user_id: &uuid::Uuid,
|
||||||
) -> Result<axum::response::Response, axum::http::Error> {
|
) -> Result<axum::response::Response, axum::http::Error> {
|
||||||
let url = super::util::format_url_with_value(
|
let url = super::util::format_url_with_value(
|
||||||
textsender_auth::callers::endpoints::GET_USER_PROFILE,
|
schedtxt_auth::callers::endpoints::GET_USER_PROFILE,
|
||||||
user_id,
|
user_id,
|
||||||
);
|
);
|
||||||
match axum::http::Request::builder()
|
match axum::http::Request::builder()
|
||||||
@@ -308,7 +308,7 @@ mod flow {
|
|||||||
|
|
||||||
pub async fn register_user(
|
pub async fn register_user(
|
||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
) -> Result<textsender_models::user::User, std::io::Error> {
|
) -> Result<schedtxt_models::user::User, std::io::Error> {
|
||||||
match requests::register_user(&app).await {
|
match requests::register_user(&app).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
if axum::http::StatusCode::CREATED != response.status() {
|
if axum::http::StatusCode::CREATED != response.status() {
|
||||||
@@ -340,7 +340,7 @@ mod flow {
|
|||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
username: &str,
|
username: &str,
|
||||||
password: &str,
|
password: &str,
|
||||||
) -> Result<textsender_models::token::LoginResult, std::io::Error> {
|
) -> Result<schedtxt_models::token::LoginResult, std::io::Error> {
|
||||||
match requests::login_user(&app, username, password).await {
|
match requests::login_user(&app, username, password).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
if axum::http::StatusCode::OK != response.status() {
|
if axum::http::StatusCode::OK != response.status() {
|
||||||
@@ -372,7 +372,7 @@ mod flow {
|
|||||||
|
|
||||||
pub async fn register_service_user(
|
pub async fn register_service_user(
|
||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
) -> Result<textsender_models::user::ServiceUser, std::io::Error> {
|
) -> Result<schedtxt_models::user::ServiceUser, std::io::Error> {
|
||||||
match requests::register_service_user(&app).await {
|
match requests::register_service_user(&app).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
if axum::http::StatusCode::CREATED != response.status() {
|
if axum::http::StatusCode::CREATED != response.status() {
|
||||||
@@ -406,7 +406,7 @@ mod flow {
|
|||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
username: &str,
|
username: &str,
|
||||||
passphrase: &str,
|
passphrase: &str,
|
||||||
) -> Result<textsender_models::token::LoginResult, std::io::Error> {
|
) -> Result<schedtxt_models::token::LoginResult, std::io::Error> {
|
||||||
match requests::login_service_user(&app, username, passphrase).await {
|
match requests::login_service_user(&app, username, passphrase).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
if axum::http::StatusCode::OK != response.status() {
|
if axum::http::StatusCode::OK != response.status() {
|
||||||
@@ -439,7 +439,7 @@ mod flow {
|
|||||||
pub async fn refresh_token(
|
pub async fn refresh_token(
|
||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
access_token: &str,
|
access_token: &str,
|
||||||
) -> Result<textsender_models::token::LoginResult, std::io::Error> {
|
) -> Result<schedtxt_models::token::LoginResult, std::io::Error> {
|
||||||
match requests::refresh_token(app, access_token).await {
|
match requests::refresh_token(app, access_token).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
if axum::http::StatusCode::OK != response.status() {
|
if axum::http::StatusCode::OK != response.status() {
|
||||||
@@ -518,7 +518,7 @@ mod flow {
|
|||||||
user_id: &uuid::Uuid,
|
user_id: &uuid::Uuid,
|
||||||
firstname: &str,
|
firstname: &str,
|
||||||
lastname: &str,
|
lastname: &str,
|
||||||
) -> Result<textsender_models::user::User, std::io::Error> {
|
) -> Result<schedtxt_models::user::User, std::io::Error> {
|
||||||
match requests::update_name_of_user(app, user_id, firstname, lastname).await {
|
match requests::update_name_of_user(app, user_id, firstname, lastname).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
if axum::http::StatusCode::OK != response.status() {
|
if axum::http::StatusCode::OK != response.status() {
|
||||||
@@ -1063,7 +1063,7 @@ async fn test_get_user_profile() {
|
|||||||
match requests::get_user_profile(&app, &user_id).await {
|
match requests::get_user_profile(&app, &user_id).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
match util::convert_response::<
|
match util::convert_response::<
|
||||||
textsender_auth::callers::login::response::GetUserProfileResponse,
|
schedtxt_auth::callers::login::response::GetUserProfileResponse,
|
||||||
>(response)
|
>(response)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user