diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..dc25ec7 --- /dev/null +++ b/.envrc @@ -0,0 +1,10 @@ +if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs=" +fi + +watch_file flake.nix +watch_file flake.lock +if ! use flake . --no-pure-eval +then + echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2 +fi diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 818a375..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Build - -on: - push: - branches: [ main ] - paths: - - '**.rs' - - '**.yml' - - '**.toml' - - '**.lock' - -jobs: - build: - name: Build - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - - uses: actions-rs/cargo@v1 - with: - command: build - args: --release - - uses: actions/upload-artifact@v2 - with: - name: build - path: target/release/testaustime-rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9bc35e2 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,160 @@ +name: CI/CD + +on: + push: + branches: [ main ] + tags: [ '*' ] + pull_request: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + check: + name: Nix CI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v24 + with: + nix_path: nixpkgs=channel:nixos-unstable + - uses: DeterminateSystems/magic-nix-cache-action@v2 + - run: nix flake check -L + - run: nix build -L + + build: + name: Build Binary + needs: check + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v24 + with: + nix_path: nixpkgs=channel:nixos-unstable + - uses: DeterminateSystems/magic-nix-cache-action@v2 + - run: nix build -L + - run: mkdir -p target/release && cp result/bin/testaustime target/release/testaustime-rs + - uses: actions/upload-artifact@v4 + with: + name: build + path: target/release/testaustime-rs + + build-image: + name: Build Docker image + needs: check + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) + strategy: + matrix: + runner: + - ubuntu-24.04 + - ubuntu-24.04-arm + runs-on: ${{ matrix.runner }} + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Nix + uses: cachix/install-nix-action@v24 + with: + nix_path: nixpkgs=channel:nixos-unstable + + - name: Set up Magic Nix Cache + uses: DeterminateSystems/magic-nix-cache-action@v2 + + - name: Build Docker image with Nix + run: | + nix build -L .#docker + IMAGE_PATH=$(readlink -f result) + echo "IMAGE_PATH=$IMAGE_PATH" >> $GITHUB_ENV + + - name: Load Docker image + run: | + docker load < ${{ env.IMAGE_PATH }} + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Determine architecture + id: arch + run: | + if [ "${{ matrix.runner }}" = "ubuntu-24.04" ]; then + echo "arch=amd64" >> $GITHUB_OUTPUT + echo "platform=linux/amd64" >> $GITHUB_OUTPUT + else + echo "arch=arm64" >> $GITHUB_OUTPUT + echo "platform=linux/arm64" >> $GITHUB_OUTPUT + fi + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value={{branch}}-${{ steps.arch.outputs.arch }} + type=raw,value=latest-${{ steps.arch.outputs.arch }},enable=${{ startsWith(github.ref, 'refs/tags/') }} + type=raw,value={{tag}}-${{ steps.arch.outputs.arch }},enable=${{ startsWith(github.ref, 'refs/tags/') }} + flavor: | + latest=false + + - name: Get image name from Nix build + id: image + run: | + IMAGE_NAME=$(docker images --format "{{.Repository}}:{{.Tag}}" | head -n 1) + echo "name=$IMAGE_NAME" >> $GITHUB_OUTPUT + + - name: Tag and push Docker image + run: | + for tag in ${{ steps.meta.outputs.tags }}; + do + docker tag ${{ steps.image.outputs.name }} $tag + docker push $tag + done + + create-manifest: + name: Create multi-arch manifest + needs: build-image + runs-on: ubuntu-24.04 + permissions: + contents: read + packages: write + steps: + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata for manifest + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value={{branch}} + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }} + type=raw,value={{tag}},enable=${{ startsWith(github.ref, 'refs/tags/') }} + type=match,pattern=\d+,group=0,enable=${{ startsWith(github.ref, 'refs/tags/') }} + flavor: | + latest=false + + - name: Create and push manifest + run: | + TAGS="${{ steps.meta.outputs.tags }}" + for tag in $TAGS; + do + docker manifest create $tag \ + ${tag}-amd64 \ + ${tag}-arm64 + docker manifest push $tag + done diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 4982eea..0000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: Docker - -on: - push: - branches: - - "main" - tags: - - "*" - workflow_dispatch: - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - -jobs: - build-and-push-image: - name: Build and publish - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to the Container registry - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=raw,value={{branch}} - type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }} - type=raw,value={{tag}},enable=${{ startsWith(github.ref, 'refs/tags/') }} - type=match,pattern=\d+,group=0,enable=${{ startsWith(github.ref, 'refs/tags/') }} - flavor: | - latest=false - - - name: Build and push Docker image - uses: docker/build-push-action@v3 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml deleted file mode 100644 index 08d72cd..0000000 --- a/.github/workflows/rust.yml +++ /dev/null @@ -1,88 +0,0 @@ -on: [push, pull_request] - -name: Continuous integration - -jobs: - check: - name: Check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - - uses: actions-rs/cargo@v1 - with: - command: check - - test: - name: Test Suite - runs-on: ubuntu-latest - - services: - postgres: - image: postgres - env: - POSTGRES_DB: testaustime - POSTGRES_PASSWORD: postgres - POSTGRES_USER: postgres - ports: - - 5432:5432 - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - - name: Install Diesel - run: cargo install diesel_cli --features=postgres - - name: Create Test DB - env: - DATABASE_URL: postgres://postgres:postgres@localhost/testaustime - run: diesel migration run - - - name: Run tests - env: - TEST_DATABASE: postgres://postgres:postgres@localhost/testaustime - run: cargo test - - fmt: - name: Rustfmt - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - - run: rustup component add rustfmt - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - clippy: - name: Clippy - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - - run: rustup component add clippy - - uses: actions-rs/cargo@v1 - with: - command: clippy - args: -- -D warnings diff --git a/.gitignore b/.gitignore index 3264e87..f386328 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ target */target .env settings.toml +result +.direnv +.devenv diff --git a/Cargo.lock b/Cargo.lock index 98ddf24..1cbaf9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,388 +1,245 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] -name = "actix-codec" -version = "0.5.2" +name = "adler2" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f7b0a21988c1bf877cf4759ef5ddaac04c1c9fe808c9142ecb78ba97d97a28a" -dependencies = [ - "bitflags 2.5.0", - "bytes", - "futures-core", - "futures-sink", - "memchr", - "pin-project-lite", - "tokio", - "tokio-util", - "tracing", -] +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] -name = "actix-cors" -version = "0.6.5" +name = "aead" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0346d8c1f762b41b458ed3145eea914966bb9ad20b9be0d6d463b20d45586370" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ - "actix-utils", - "actix-web", - "derive_more", - "futures-util", - "log", - "once_cell", - "smallvec", + "crypto-common", + "generic-array", ] [[package]] -name = "actix-http" -version = "3.7.0" +name = "aes" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb9843d84c775696c37d9a418bbb01b932629d01870722c0f13eb3f95e2536d" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" dependencies = [ - "actix-codec", - "actix-rt", - "actix-service", - "actix-tls", - "actix-utils", - "ahash", - "base64 0.22.1", - "bitflags 2.5.0", - "brotli", - "bytes", - "bytestring", - "derive_more", - "encoding_rs", - "flate2", - "futures-core", - "h2", - "http 0.2.12", - "httparse", - "httpdate", - "itoa", - "language-tags", - "local-channel", - "mime", - "percent-encoding", - "pin-project-lite", - "rand", - "sha1", - "smallvec", - "tokio", - "tokio-util", - "tracing", - "zstd", + "cfg-if", + "cipher", + "cpufeatures", ] [[package]] -name = "actix-macros" -version = "0.2.4" +name = "aes-gcm" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" dependencies = [ - "quote", - "syn 2.0.66", + "aead", + "aes", + "cipher", + "ctr", + "ghash", + "subtle", ] [[package]] -name = "actix-router" -version = "0.5.3" +name = "ahash" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13d324164c51f63867b57e73ba5936ea151b8a41a1d23d1031eeb9f70d0236f8" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ - "bytestring", "cfg-if", - "http 0.2.12", - "regex", - "regex-lite", - "serde", - "tracing", + "once_cell", + "version_check", + "zerocopy", ] [[package]] -name = "actix-rt" -version = "2.9.0" +name = "aho-corasick" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28f32d40287d3f402ae0028a9d54bef51af15c8769492826a69d28f81893151d" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" dependencies = [ - "futures-core", - "tokio", + "memchr", ] [[package]] -name = "actix-server" -version = "2.3.0" +name = "allocator-api2" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eb13e7eef0423ea6eab0e59f6c72e7cb46d33691ad56a726b3cd07ddec2c2d4" -dependencies = [ - "actix-rt", - "actix-service", - "actix-utils", - "futures-core", - "futures-util", - "mio", - "socket2", - "tokio", - "tracing", -] +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] -name = "actix-service" -version = "2.0.2" +name = "android_system_properties" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b894941f818cfdc7ccc4b9e60fa7e53b5042a2e8567270f9147d5591893373a" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" dependencies = [ - "futures-core", - "paste", - "pin-project-lite", + "libc", ] [[package]] -name = "actix-tls" -version = "3.4.0" +name = "ar_archive_writer" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac453898d866cdbecdbc2334fe1738c747b4eba14a677261f2b768ba05329389" +checksum = "f0c269894b6fe5e9d7ada0cf69b5bf847ff35bc25fc271f08e1d080fce80339a" dependencies = [ - "actix-rt", - "actix-service", - "actix-utils", - "futures-core", - "http 0.2.12", - "http 1.1.0", - "impl-more", - "pin-project-lite", - "tokio", - "tokio-rustls", - "tokio-util", - "tracing", - "webpki-roots", + "object", ] [[package]] -name = "actix-utils" -version = "3.0.1" +name = "arbitrary" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a1dcdff1466e3c2488e1cb5c36a71822750ad43839937f85d2f4d9f8b705d8" +checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" dependencies = [ - "local-waker", - "pin-project-lite", + "derive_arbitrary", ] [[package]] -name = "actix-web" -version = "4.6.0" +name = "argon2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1cf67dadb19d7c95e5a299e2dda24193b89d5d4f33a3b9800888ede9e19aa32" +checksum = "3c3610892ee6e0cbce8ae2700349fcf8f98adb0dbfbee85aec3c9179d29cc072" dependencies = [ - "actix-codec", - "actix-http", - "actix-macros", - "actix-router", - "actix-rt", - "actix-server", - "actix-service", - "actix-tls", - "actix-utils", - "actix-web-codegen", - "ahash", - "bytes", - "bytestring", - "cfg-if", - "cookie", - "derive_more", - "encoding_rs", - "futures-core", - "futures-util", - "itoa", - "language-tags", - "log", - "mime", - "once_cell", - "pin-project-lite", - "regex", - "regex-lite", - "serde", - "serde_json", - "serde_urlencoded", - "smallvec", - "socket2", - "time", - "url", + "base64ct", + "blake2", + "cpufeatures", + "password-hash", ] [[package]] -name = "actix-web-codegen" -version = "4.2.2" +name = "async-trait" +version = "0.1.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1f50ebbb30eca122b188319a4398b3f7bb4a8cdf50ecfb73bfc6a3c3ce54f5" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ - "actix-router", "proc-macro2", "quote", - "syn 2.0.66", -] - -[[package]] -name = "addr2line" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "getrandom", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", + "syn", ] [[package]] -name = "alloc-no-stdlib" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" - -[[package]] -name = "alloc-stdlib" -version = "0.2.2" +name = "atomic-waker" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" -dependencies = [ - "alloc-no-stdlib", -] +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] -name = "android-tzdata" -version = "0.1.1" +name = "autocfg" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] -name = "android_system_properties" -version = "0.1.5" +name = "aws-lc-rs" +version = "1.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +checksum = "6a88aab2464f1f25453baa7a07c84c5b7684e274054ba06817f382357f77a288" dependencies = [ - "libc", + "aws-lc-sys", + "zeroize", ] [[package]] -name = "argon2" -version = "0.4.1" +name = "aws-lc-sys" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db4ce4441f99dbd377ca8a8f57b698c44d0d6e712d8329b5040da5a64aa1ce73" +checksum = "b45afffdee1e7c9126814751f88dddc747f41d91da16c9551a0f1e8a11e788a1" dependencies = [ - "base64ct", - "blake2", - "password-hash", + "cc", + "cmake", + "dunce", + "fs_extra", ] [[package]] -name = "async-trait" -version = "0.1.80" +name = "axum" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +checksum = "8b52af3cb4058c895d37317bb27508dccc8e5f2d39454016b297bf4a400597b8" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", + "axum-core", + "axum-macros", + "bytes", + "form_urlencoded", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "serde_core", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-layer", + "tower-service", + "tracing", ] [[package]] -name = "atty" -version = "0.2.14" +name = "axum-core" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +checksum = "08c78f31d7b1291f7ee735c1c6780ccde7785daae9a9206026862dab7d8792d1" dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "sync_wrapper", + "tower-layer", + "tower-service", + "tracing", ] [[package]] -name = "autocfg" -version = "1.3.0" +name = "axum-extra" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "awc" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe6b67e44fb95d1dc9467e3930383e115f9b4ed60ca689db41409284e967a12d" +checksum = "fef252edff26ddba56bbcdf2ee3307b8129acb86f5749b68990c168a6fcc9c76" dependencies = [ - "actix-codec", - "actix-http", - "actix-rt", - "actix-service", - "actix-tls", - "actix-utils", - "base64 0.22.1", + "axum", + "axum-core", "bytes", - "cfg-if", "cookie", - "derive_more", "futures-core", "futures-util", - "h2", - "http 0.2.12", - "itoa", - "log", + "http", + "http-body", + "http-body-util", "mime", - "percent-encoding", "pin-project-lite", - "rand", - "rustls", - "serde", - "serde_json", - "serde_urlencoded", - "tokio", + "tower-layer", + "tower-service", + "tracing", ] [[package]] -name = "backtrace" -version = "0.3.71" +name = "axum-macros" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +checksum = "604fde5e028fea851ce1d8570bbdc034bec850d157f7569d10f347d06808c05c" dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", + "proc-macro2", + "quote", + "syn", ] -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - [[package]] name = "base64" version = "0.22.1" @@ -391,21 +248,15 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - -[[package]] -name = "bitflags" -version = "1.3.2" +version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" [[package]] name = "blake2" @@ -425,32 +276,11 @@ dependencies = [ "generic-array", ] -[[package]] -name = "brotli" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74f7971dbd9326d58187408ab83117d8ac1bb9c17b085fdacd1cf2f598719b6b" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", - "brotli-decompressor", -] - -[[package]] -name = "brotli-decompressor" -version = "4.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a45bd2e4095a8b518033b128020dd4a55aab1c0a381ba4404a472630f4bc362" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", -] - [[package]] name = "bumpalo" -version = "3.16.0" +version = "3.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" [[package]] name = "byteorder" @@ -460,116 +290,212 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" - -[[package]] -name = "bytestring" -version = "1.3.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d80203ea6b29df88012294f62733de21cfeab47f17b41af3a38bc30a03ee72" -dependencies = [ - "bytes", -] +checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" [[package]] name = "cc" -version = "1.0.98" +version = "1.2.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +checksum = "cd4932aefd12402b36c60956a4fe0035421f544799057659ff86f923657aada3" dependencies = [ + "find-msvc-tools", "jobserver", "libc", - "once_cell", + "shlex", ] +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cfg_aliases" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" dependencies = [ - "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "serde", "wasm-bindgen", - "windows-targets 0.52.5", + "windows-link", ] [[package]] -name = "convert_case" -version = "0.4.0" +name = "chumsky" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eebd66744a15ded14960ab4ccdbfb51ad3b81f51f3f04a80adac98c985396c9" +dependencies = [ + "hashbrown 0.14.5", + "stacker", +] + +[[package]] +name = "cipher" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + +[[package]] +name = "cmake" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75443c44cd6b379beb8c5b45d85d0773baf31cce901fe7bb252f4eff3008ef7d" +dependencies = [ + "cc", +] + +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes", + "memchr", +] [[package]] name = "cookie" -version = "0.16.2" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" +checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747" dependencies = [ + "aes-gcm", + "base64", "percent-encoding", + "rand 0.8.5", + "subtle", "time", "version_check", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" dependencies = [ "libc", ] [[package]] name = "crc32fast" -version = "1.4.2" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" dependencies = [ "cfg-if", ] [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", + "rand_core 0.6.4", "typenum", ] +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher", +] + +[[package]] +name = "darling" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" +dependencies = [ + "darling_core", + "quote", + "syn", +] + [[package]] name = "dashmap" -version = "5.5.3" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" dependencies = [ "cfg-if", - "hashbrown", + "crossbeam-utils", + "hashbrown 0.14.5", "lock_api", "once_cell", "parking_lot_core", @@ -577,14 +503,13 @@ dependencies = [ [[package]] name = "deadpool" -version = "0.9.5" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "421fe0f90f2ab22016f32a9881be5134fdd71c65298917084b0c7477cbc3856e" +checksum = "0be2b1d1d6ec8d846f05e137292d0b89133caf95ef33695424c09568bdd39b1b" dependencies = [ - "async-trait", "deadpool-runtime", + "lazy_static", "num_cpus", - "retain_mut", "tokio", ] @@ -596,49 +521,48 @@ checksum = "092966b41edc516079bdf31ec78a2e0588d1d0c08f78b91d8307215928642b2b" [[package]] name = "deranged" -version = "0.3.11" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587" dependencies = [ "powerfmt", ] [[package]] -name = "derive_more" -version = "0.99.17" +name = "derive_arbitrary" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "1e567bd82dcff979e4b03460c307b3cdc9e96fde3d73bed1496d2bc75d9dd62a" dependencies = [ - "convert_case", "proc-macro2", "quote", - "rustc_version", - "syn 1.0.109", + "syn", ] [[package]] name = "diesel" -version = "2.1.6" +version = "2.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff236accb9a5069572099f0b350a92e9560e8e63a9b8d546162f4a5e03026bb2" +checksum = "e130c806dccc85428c564f2dc5a96e05b6615a27c9a28776bd7761a9af4bb552" dependencies = [ - "bitflags 2.5.0", + "bitflags", "byteorder", "chrono", "diesel_derives", + "downcast-rs", "itoa", "serde_json", ] [[package]] name = "diesel-async" -version = "0.4.1" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acada1517534c92d3f382217b485db8a8638f111b0e3f2a2a8e26165050f77be" +checksum = "13096fb8dae53f2d411c4b523bec85f45552ed3044a2ab4d85fb2092d9cb4f34" dependencies = [ - "async-trait", "deadpool", "diesel", + "futures-core", "futures-util", "scoped-futures", "tokio", @@ -647,23 +571,24 @@ dependencies = [ [[package]] name = "diesel_derives" -version = "2.1.4" +version = "2.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14701062d6bed917b5c7103bdffaee1e4609279e240488ad24e7bd979ca6866c" +checksum = "c30b2969f923fa1f73744b92bb7df60b858df8832742d9a3aceb79236c0be1d2" dependencies = [ "diesel_table_macro_syntax", + "dsl_auto_type", "proc-macro2", "quote", - "syn 2.0.66", + "syn", ] [[package]] name = "diesel_table_macro_syntax" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc5557efc453706fed5e4fa85006fe9817c224c3f480a34c7e5959fd700921c5" +checksum = "fe2444076b48641147115697648dc743c2c00b61adade0f01ce67133c7babe8c" dependencies = [ - "syn 2.0.66", + "syn", ] [[package]] @@ -677,45 +602,85 @@ dependencies = [ "subtle", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "dotenv" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" +[[package]] +name = "downcast-rs" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "117240f60069e65410b3ae1bb213295bd828f707b5bec6596a1afc8793ce0cbc" + +[[package]] +name = "dsl_auto_type" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd122633e4bef06db27737f21d3738fb89c8f6d5360d6d9d7635dda142a7757e" +dependencies = [ + "darling", + "either", + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + [[package]] name = "either" -version = "1.12.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] -name = "encoding_rs" -version = "0.8.34" +name = "email-encoding" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +checksum = "9298e6504d9b9e780ed3f7dfd43a61be8cd0e09eb07f7706a945b0072b6670b6" dependencies = [ - "cfg-if", + "base64", + "memchr", ] [[package]] -name = "env_logger" -version = "0.9.3" +name = "email_address" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e079f19b08ca6239f47f8ba8509c11cf3ea30095831f7fed61441475edd8c449" + +[[package]] +name = "encoding_rs" +version = "0.8.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", + "cfg-if", ] [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "fallible-iterator" @@ -723,14 +688,27 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "find-msvc-tools" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f449e6c6c08c865631d4890cfacf252b3d396c9bcc83adb6623cdb02a8336c41" + [[package]] name = "flate2" -version = "1.0.30" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +checksum = "b375d6465b98090a5f25b1c7703f3859783755aa9a80433b36e0379a3ec2f369" dependencies = [ "crc32fast", "miniz_oxide", + "zlib-rs", ] [[package]] @@ -739,20 +717,32 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + [[package]] name = "form_urlencoded" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" dependencies = [ "percent-encoding", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -765,9 +755,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -775,15 +765,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -792,32 +782,32 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn", ] [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-timer" @@ -827,9 +817,9 @@ checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -855,53 +845,76 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] -name = "gimli" -version = "0.28.1" +name = "getrandom" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi", + "wasip2", + "wasm-bindgen", +] + +[[package]] +name = "ghash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" +dependencies = [ + "opaque-debug", + "polyval", +] [[package]] name = "governor" -version = "0.6.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a7f542ee6b35af73b06abc0dad1c1bae89964e4e253bc4b587b91c9637867b" +checksum = "9efcab3c1958580ff1f25a2a41be1668f7603d849bb63af523b208a3cc1223b8" dependencies = [ "cfg-if", "dashmap", - "futures", + "futures-sink", "futures-timer", - "no-std-compat", + "futures-util", + "getrandom 0.3.4", + "hashbrown 0.16.1", "nonzero_ext", "parking_lot", "portable-atomic", "quanta", - "rand", + "rand 0.9.2", "smallvec", "spinning_top", + "web-time", ] [[package]] name = "h2" -version = "0.3.26" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +checksum = "2f44da3a8150a6703ed5d34e164b875fd14c2cdab9af1252a9a1020bde2bdc54" dependencies = [ + "atomic-waker", "bytes", "fnv", "futures-core", "futures-sink", - "futures-util", - "http 0.2.12", + "http", "indexmap", "slab", "tokio", @@ -914,21 +927,33 @@ name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] [[package]] -name = "hermit-abi" -version = "0.1.19" +name = "hashbrown" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ - "libc", + "allocator-api2", + "equivalent", + "foldhash", ] +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" -version = "0.3.9" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" [[package]] name = "hmac" @@ -939,33 +964,55 @@ dependencies = [ "digest", ] +[[package]] +name = "hostname" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617aaa3557aef3810a6369d0a99fac8a080891b68bd9f9812a1eeda0c0730cbd" +dependencies = [ + "cfg-if", + "libc", + "windows-link", +] + [[package]] name = "http" -version = "0.2.12" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" dependencies = [ "bytes", - "fnv", "itoa", ] [[package]] -name = "http" -version = "1.1.0" +name = "http-body" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "fnv", - "itoa", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", ] [[package]] name = "httparse" -version = "1.8.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" [[package]] name = "httpdate" @@ -974,21 +1021,79 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] -name = "humantime" -version = "2.1.0" +name = "hyper" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "pin-utils", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "727805d60e7938b76b826a6ef209eb70eaa1812794f9424d4a4e2d740662df5f" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] [[package]] name = "iana-time-zone" -version = "0.1.60" +version = "0.1.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", + "log", "wasm-bindgen", "windows-core", ] @@ -999,112 +1104,305 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ - "cc", + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +dependencies = [ + "equivalent", + "hashbrown 0.16.1", + "serde", + "serde_core", ] [[package]] -name = "idna" -version = "0.5.0" +name = "inout" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "generic-array", ] [[package]] -name = "impl-more" -version = "0.1.6" +name = "ipnet" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206ca75c9c03ba3d4ace2460e57b189f39f43de612c2f85836e65c929701bb2d" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] -name = "indexmap" -version = "2.2.6" +name = "iri-string" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "c91338f0783edbd6195decb37bae672fd3b165faffb89bf7b9e6942f8b1a731a" dependencies = [ - "equivalent", - "hashbrown", + "memchr", + "serde", ] [[package]] name = "itertools" -version = "0.10.5" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" dependencies = [ "either", ] [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys", + "log", + "thiserror 1.0.69", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "jobserver" -version = "0.1.31" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" dependencies = [ + "getrandom 0.3.4", "libc", ] [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8" dependencies = [ + "once_cell", "wasm-bindgen", ] [[package]] -name = "language-tags" -version = "0.3.2" +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "lettre" +version = "0.11.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" +checksum = "9e13e10e8818f8b2a60f52cb127041d388b89f3a96a62be9ceaffa22262fef7f" +dependencies = [ + "async-trait", + "base64", + "chumsky", + "email-encoding", + "email_address", + "fastrand", + "futures-io", + "futures-util", + "hostname", + "httpdate", + "idna", + "mime", + "nom", + "percent-encoding", + "quoted_printable", + "rustls", + "socket2", + "tokio", + "tokio-rustls", + "tracing", + "url", + "webpki-roots", +] [[package]] name = "libc" -version = "0.2.155" +version = "0.2.180" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" [[package]] -name = "local-channel" -version = "0.1.5" +name = "libredox" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6cbc85e69b8df4b8bb8b89ec634e7189099cea8927a276b7384ce5488e53ec8" +checksum = "3d0b95e02c851351f877147b7deea7b1afb1df71b63aa5f8270716e0c5720616" dependencies = [ - "futures-core", - "futures-sink", - "local-waker", + "bitflags", + "libc", + "redox_syscall 0.7.0", ] [[package]] -name = "local-waker" -version = "0.1.4" +name = "litemap" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d873d7c67ce09b42110d801813efbc9364414e356be9935700d368351657487" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" [[package]] name = "lock_api" -version = "0.4.12" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" dependencies = [ - "autocfg", "scopeguard", ] [[package]] name = "log" -version = "0.4.21" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "lru-slab" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" + +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "matchit" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" [[package]] name = "md-5" @@ -1118,9 +1416,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" [[package]] name = "mime" @@ -1128,32 +1426,45 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "miniz_oxide" -version = "0.7.3" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ - "adler", + "adler2", + "simd-adler32", ] [[package]] name = "mio" -version = "0.8.11" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" dependencies = [ "libc", - "log", "wasi", - "windows-sys 0.48.0", + "windows-sys 0.61.2", ] [[package]] -name = "no-std-compat" -version = "0.4.1" +name = "nom" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c" +checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" +dependencies = [ + "memchr", +] [[package]] name = "nonzero_ext" @@ -1161,6 +1472,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38bf9645c8b145698bb0b18a4637dcacbc421ea49bef2317e4fd8065a387cf21" +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys 0.61.2", +] + [[package]] name = "num-conv" version = "0.1.0" @@ -1178,11 +1498,11 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", ] @@ -1197,15 +1517,27 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "openssl-probe" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "9f50d9b3dabb09ecd771ad0aa242ca6894994c130308ca3d7684634df8037391" [[package]] name = "parking_lot" -version = "0.12.3" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" dependencies = [ "lock_api", "parking_lot_core", @@ -1213,25 +1545,25 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.10" +version = "0.9.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.1", + "redox_syscall 0.5.18", "smallvec", - "windows-targets 0.52.5", + "windows-link", ] [[package]] name = "password-hash" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" +checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" dependencies = [ "base64ct", - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -1243,53 +1575,54 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "percent-encoding" -version = "2.3.1" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "phf" -version = "0.11.2" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf" dependencies = [ "phf_shared", + "serde", ] [[package]] name = "phf_shared" -version = "0.11.2" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +checksum = "e57fef6bc5981e38c2ce2d63bfa546861309f875b8a75f092d1d54ae2d64f266" dependencies = [ "siphasher", ] [[package]] name = "pin-project" -version = "1.1.5" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.5" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn", ] [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -1298,46 +1631,61 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "pkg-config" -version = "0.3.30" +name = "polyval" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" +dependencies = [ + "cfg-if", + "cpufeatures", + "opaque-debug", + "universal-hash", +] [[package]] name = "portable-atomic" -version = "1.6.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" +checksum = "f89776e4d69bb58bc6993e99ffa1d11f228b839984854c7daeb5d37f87cbe950" [[package]] name = "postgres-protocol" -version = "0.6.6" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b6c5ef183cd3ab4ba005f1ca64c21e8bd97ce4699cfea9e8d9a2c4958ca520" +checksum = "fbef655056b916eb868048276cfd5d6a7dea4f81560dfd047f97c8c6fe3fcfd4" dependencies = [ - "base64 0.21.7", + "base64", "byteorder", "bytes", "fallible-iterator", "hmac", "md-5", "memchr", - "rand", + "rand 0.9.2", "sha2", "stringprep", ] [[package]] name = "postgres-types" -version = "0.2.6" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d2234cdee9408b523530a9b6d2d6b373d1db34f6a8e51dc03ded1828d7fb67c" +checksum = "ef4605b7c057056dd35baeb6ac0c0338e4975b1f2bef0f65da953285eb007095" dependencies = [ "bytes", "fallible-iterator", "postgres-protocol", ] +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -1346,24 +1694,37 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] [[package]] name = "proc-macro2" -version = "1.0.84" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" +checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7" dependencies = [ "unicode-ident", ] +[[package]] +name = "psm" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d11f2fedc3b7dafdc2851bc52f277377c5473d378859be234bc7ebb593144d01" +dependencies = [ + "ar_archive_writer", + "cc", +] + [[package]] name = "quanta" -version = "0.12.3" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5167a477619228a0b284fac2674e3c388cba90631d7b7de620e6f1fcd08da5" +checksum = "f3ab5a9d756f0d97bdc89019bd2e4ea098cf9cde50ee7564dde6b81ccc8f06c7" dependencies = [ "crossbeam-utils", "libc", @@ -1374,15 +1735,83 @@ dependencies = [ "winapi", ] +[[package]] +name = "quinn" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e20a958963c291dc322d98411f541009df2ced7b5a4f2bd52337638cfccf20" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror 2.0.17", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1906b49b0c3bc04b5fe5d86a77925ae6524a19b816ae38ce1e426255f1d8a31" +dependencies = [ + "aws-lc-rs", + "bytes", + "getrandom 0.3.4", + "lru-slab", + "rand 0.9.2", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror 2.0.17", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "addec6a0dcad8a8d96a771f815f0eaf55f9d1805756410b39f5fa81332574cbd" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.60.2", +] + [[package]] name = "quote" -version = "1.0.36" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" dependencies = [ "proc-macro2", ] +[[package]] +name = "quoted_printable" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "640c9bd8497b02465aeef5375144c26062e0dcd5939dfcbb0f5db76cb8c17c73" + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + [[package]] name = "rand" version = "0.8.5" @@ -1390,8 +1819,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.5", ] [[package]] @@ -1401,7 +1840,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.5", ] [[package]] @@ -1410,148 +1859,283 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.17", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "raw-cpuid" +version = "11.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "498cd0dc59d73224351ee52a95fee0f1a617a2eae0e7d9d720cc622c73a54186" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_syscall" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f3fe0889e69e2ae9e41f4d6c4c0181701d00e4697b356fb1f74173a5e0ee27" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" + +[[package]] +name = "reqwest" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04e9018c9d814e5f30cc16a0f03271aeab3571e609612d9fe78c1aa8d11c2f62" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "js-sys", + "log", + "mime", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls", + "rustls-pki-types", + "rustls-platform-verifier", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", ] [[package]] -name = "raw-cpuid" -version = "11.0.2" +name = "rust-embed" +version = "8.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e29830cbb1290e404f24c73af91c5d8d631ce7e128691e9477556b540cd01ecd" +checksum = "947d7f3fad52b283d261c4c99a084937e2fe492248cb9a68a8435a861b8798ca" dependencies = [ - "bitflags 2.5.0", + "rust-embed-impl", + "rust-embed-utils", + "walkdir", ] [[package]] -name = "redox_syscall" -version = "0.4.1" +name = "rust-embed-impl" +version = "8.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "5fa2c8c9e8711e10f9c4fd2d64317ef13feaab820a4c51541f1a8c8e2e851ab2" dependencies = [ - "bitflags 1.3.2", + "proc-macro2", + "quote", + "rust-embed-utils", + "syn", + "walkdir", ] [[package]] -name = "redox_syscall" -version = "0.5.1" +name = "rust-embed-utils" +version = "8.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "60b161f275cb337fe0a44d924a5f4df0ed69c2c39519858f931ce61c779d3475" dependencies = [ - "bitflags 2.5.0", + "sha2", + "walkdir", ] [[package]] -name = "regex" -version = "1.10.4" +name = "rustc-hash" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] -name = "regex-automata" -version = "0.4.6" +name = "rustls" +version = "0.23.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "c665f33d38cea657d9614f766881e4d510e0eda4239891eea56b4cadcf01801b" dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", + "aws-lc-rs", + "log", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", ] [[package]] -name = "regex-lite" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b661b2f27137bdbc16f00eda72866a92bb28af1753ffbd56744fb6e2e9cd8e" - -[[package]] -name = "regex-syntax" +name = "rustls-native-certs" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "612460d5f7bea540c490b2b6395d8e34a953e52b491accd6c86c8164c5932a63" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] [[package]] -name = "retain_mut" -version = "0.1.9" +name = "rustls-pki-types" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4389f1d5789befaf6029ebd9f7dac4af7f7e3d61b69d4f30e2ac02b57e7712b0" +checksum = "21e6f2ab2928ca4291b86736a8bd920a277a399bba1589409d72154ff87c1282" +dependencies = [ + "web-time", + "zeroize", +] [[package]] -name = "ring" -version = "0.16.20" +name = "rustls-platform-verifier" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +checksum = "1d99feebc72bae7ab76ba994bb5e121b8d83d910ca40b36e0921f53becc41784" dependencies = [ - "cc", - "libc", + "core-foundation", + "core-foundation-sys", + "jni", + "log", "once_cell", - "spin 0.5.2", - "untrusted 0.7.1", - "web-sys", - "winapi", + "rustls", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki", + "security-framework", + "security-framework-sys", + "webpki-root-certs", + "windows-sys 0.61.2", ] [[package]] -name = "ring" -version = "0.17.8" +name = "rustls-platform-verifier-android" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" + +[[package]] +name = "rustls-webpki" +version = "0.103.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +checksum = "2ffdfa2f5286e2247234e03f680868ac2815974dc39e00ea15adc445d0aafe52" dependencies = [ - "cc", - "cfg-if", - "getrandom", - "libc", - "spin 0.9.8", - "untrusted 0.9.0", - "windows-sys 0.52.0", + "aws-lc-rs", + "ring", + "rustls-pki-types", + "untrusted", ] [[package]] -name = "rustc-demangle" -version = "0.1.24" +name = "rustversion" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] -name = "rustc_version" -version = "0.4.0" +name = "ryu" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] +checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" [[package]] -name = "rustls" -version = "0.20.9" +name = "same-file" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" dependencies = [ - "log", - "ring 0.16.20", - "sct", - "webpki", + "winapi-util", ] [[package]] -name = "ryu" -version = "1.0.18" +name = "schannel" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" +dependencies = [ + "windows-sys 0.61.2", +] [[package]] name = "scoped-futures" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1473e24c637950c9bd38763220bea91ec3e095a89f672bbd7a10d03e77ba467" +checksum = "1b24aae2d0636530f359e9d5ef0c04669d11c5e756699b27a6a6d845d8329091" dependencies = [ - "cfg-if", - "pin-utils", + "pin-project-lite", ] [[package]] @@ -1561,50 +2145,89 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] -name = "sct" -version = "0.7.1" +name = "security-framework" +version = "3.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +checksum = "b3297343eaf830f66ede390ea39da1d462b6b0c1b000f420d0a83f898bbbe6ef" dependencies = [ - "ring 0.17.8", - "untrusted 0.9.0", + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", ] [[package]] -name = "semver" -version = "1.0.23" +name = "security-framework-sys" +version = "2.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0" +dependencies = [ + "core-foundation-sys", + "libc", +] [[package]] name = "serde" -version = "1.0.203" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn", ] [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" dependencies = [ "itoa", - "ryu", "serde", + "serde_core", +] + +[[package]] +name = "serde_spanned" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8bbf91e5a4d6315eee45e704372590b30e260ee83af6639d64557f51b067776" +dependencies = [ + "serde_core", ] [[package]] @@ -1620,10 +2243,10 @@ dependencies = [ ] [[package]] -name = "sha1" -version = "0.10.6" +name = "sha2" +version = "0.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ "cfg-if", "cpufeatures", @@ -1631,75 +2254,80 @@ dependencies = [ ] [[package]] -name = "sha2" -version = "0.10.8" +name = "sharded-slab" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ - "cfg-if", - "cpufeatures", - "digest", + "lazy_static", ] [[package]] -name = "signal-hook-registry" -version = "1.4.2" +name = "shlex" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" -dependencies = [ - "libc", -] +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "simd-adler32" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" [[package]] name = "siphasher" -version = "0.3.11" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" [[package]] name = "slab" -version = "0.4.9" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] +checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" [[package]] name = "smallvec" -version = "1.13.2" +version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "socket2" -version = "0.5.7" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.60.2", ] [[package]] -name = "spin" -version = "0.5.2" +name = "spinning_top" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +checksum = "d96d2d1d716fb500937168cc09353ffdc7a012be8475ac7308e1bdf0e3923300" +dependencies = [ + "lock_api", +] [[package]] -name = "spin" -version = "0.9.8" +name = "stable_deref_trait" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] -name = "spinning_top" -version = "0.3.0" +name = "stacker" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96d2d1d716fb500937168cc09353ffdc7a012be8475ac7308e1bdf0e3923300" +checksum = "e1f8b29fb42aafcea4edeeb6b2f2d7ecd0d969c48b4cf0d2e64aafc471dd6e59" dependencies = [ - "lock_api", + "cc", + "cfg-if", + "libc", + "psm", + "windows-sys 0.59.0", ] [[package]] @@ -1713,17 +2341,23 @@ dependencies = [ "unicode-properties", ] +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "1.0.109" +version = "2.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" dependencies = [ "proc-macro2", "quote", @@ -1731,113 +2365,160 @@ dependencies = [ ] [[package]] -name = "syn" -version = "2.0.66" +name = "sync_wrapper" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "futures-core", ] [[package]] -name = "termcolor" -version = "1.4.1" +name = "synstructure" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ - "winapi-util", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "testaustime-rs" +name = "testaustime" version = "0.3.1" dependencies = [ - "actix-cors", - "actix-web", "argon2", - "awc", + "axum", + "axum-extra", "chrono", "dashmap", "diesel", "diesel-async", "dotenv", - "env_logger", "futures", "futures-util", "governor", - "http 0.2.12", + "http", + "http-body-util", "itertools", - "log", - "rand", + "lettre", + "mime", + "rand 0.9.2", "regex", + "reqwest", "serde", "serde_derive", "serde_json", - "thiserror", + "thiserror 2.0.17", + "tokio", "toml", + "tower", + "tower-http", "tracing", - "tracing-actix-web", + "tracing-futures", + "tracing-subscriber", "url", + "utoipa", + "utoipa-axum", + "utoipa-swagger-ui", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", ] [[package]] name = "thiserror" -version = "1.0.61" +version = "2.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" +dependencies = [ + "thiserror-impl 2.0.17", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ - "thiserror-impl", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" +dependencies = [ + "cfg-if", ] [[package]] name = "time" -version = "0.3.36" +version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +checksum = "f9e442fc33d7fdb45aa9bfeb312c095964abdf596f7567261062b2a7107aaabd" dependencies = [ "deranged", "itoa", "num-conv", "powerfmt", - "serde", + "serde_core", "time-core", "time-macros", ] [[package]] name = "time-core" -version = "0.1.2" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" +checksum = "8b36ee98fd31ec7426d599183e8fe26932a8dc1fb76ddb6214d05493377d34ca" [[package]] name = "time-macros" -version = "0.2.18" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +checksum = "71e552d1249bf61ac2a52db88179fd0673def1e1ad8243a00d9ec9ed71fee3dd" dependencies = [ "num-conv", "time-core", ] +[[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" dependencies = [ "tinyvec_macros", ] @@ -1850,26 +2531,35 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.37.0" +version = "1.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" dependencies = [ - "backtrace", "bytes", "libc", "mio", - "parking_lot", "pin-project-lite", - "signal-hook-registry", "socket2", - "windows-sys 0.48.0", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] name = "tokio-postgres" -version = "0.7.10" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d340244b32d920260ae7448cb72b6e238bddc3d4f7603394e7dd46ed8e48f5b8" +checksum = "2b40d66d9b2cfe04b628173409368e58247e8eddbbd3b0e6c6ba1d09f20f6c9e" dependencies = [ "async-trait", "byteorder", @@ -1884,7 +2574,7 @@ dependencies = [ "pin-project-lite", "postgres-protocol", "postgres-types", - "rand", + "rand 0.9.2", "socket2", "tokio", "tokio-util", @@ -1893,20 +2583,19 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.23.4" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" dependencies = [ "rustls", "tokio", - "webpki", ] [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" dependencies = [ "bytes", "futures-core", @@ -1917,18 +2606,95 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.11" +version = "0.9.11+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +checksum = "f3afc9a848309fe1aaffaed6e1546a7a14de1f935dc9d89d32afd9a44bab7c46" dependencies = [ - "serde", + "indexmap", + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "toml_writer", + "winnow", +] + +[[package]] +name = "toml_datetime" +version = "0.7.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92e1cfed4a3038bc5a127e35a2d360f145e1f4b971b551a2ba5fd7aedf7e1347" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_parser" +version = "1.0.6+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3198b4b0a8e11f09dd03e133c0280504d0801269e9afa46362ffde1cbeebf44" +dependencies = [ + "winnow", +] + +[[package]] +name = "toml_writer" +version = "1.0.6+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab16f14aed21ee8bfd8ec22513f7287cd4a91aa92e44edfe2c17ddd004e92607" + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" +dependencies = [ + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "iri-string", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", + "tracing", ] +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" dependencies = [ "log", "pin-project-lite", @@ -1937,75 +2703,119 @@ dependencies = [ ] [[package]] -name = "tracing-actix-web" -version = "0.6.2" +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-futures" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d725b8fa6ef307b3f4856913523337de45c47cc79271bafd7acfb39559e3a2da" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" dependencies = [ - "actix-web", "pin-project", "tracing", - "uuid", ] [[package]] -name = "tracing-attributes" -version = "0.1.27" +name = "tracing-log" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex-automata", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", ] [[package]] -name = "tracing-core" -version = "0.1.32" +name = "try-lock" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", -] +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "typenum" -version = "1.17.0" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" + +[[package]] +name = "unicase" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142" [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8" dependencies = [ "tinyvec", ] [[package]] name = "unicode-properties" -version = "0.1.1" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4259d9d4425d9f0661581b804cb85fe66a4c631cadd8f490d1c13a35d5d9291" +checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d" [[package]] -name = "untrusted" -version = "0.7.1" +name = "universal-hash" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common", + "subtle", +] [[package]] name = "untrusted" @@ -2015,35 +2825,129 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.0" +version = "2.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" dependencies = [ "form_urlencoded", "idna", "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utoipa" +version = "5.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fcc29c80c21c31608227e0912b2d7fddba57ad76b606890627ba8ee7964e993" +dependencies = [ + "indexmap", + "serde", + "serde_json", + "utoipa-gen", ] [[package]] -name = "uuid" -version = "1.8.0" +name = "utoipa-axum" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c25bae5bccc842449ec0c5ddc5cbb6a3a1eaeac4503895dc105a1138f8234a0" +dependencies = [ + "axum", + "paste", + "tower-layer", + "tower-service", + "utoipa", +] + +[[package]] +name = "utoipa-gen" +version = "5.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d79d08d92ab8af4c5e8a6da20c47ae3f61a0f1dabc1997cdf2d082b757ca08b" +dependencies = [ + "proc-macro2", + "quote", + "regex", + "syn", +] + +[[package]] +name = "utoipa-swagger-ui" +version = "9.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +checksum = "d047458f1b5b65237c2f6dc6db136945667f40a7668627b3490b9513a3d43a55" dependencies = [ - "getrandom", + "axum", + "base64", + "mime_guess", + "regex", + "rust-embed", + "serde", + "serde_json", + "url", + "utoipa", + "utoipa-swagger-ui-vendored", + "zip", ] +[[package]] +name = "utoipa-swagger-ui-vendored" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2eebbbfe4093922c2b6734d7c679ebfebd704a0d7e56dfcb0d05818ce28977d" + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "walkdir" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.1+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +dependencies = [ + "wit-bindgen", +] [[package]] name = "wasite" @@ -2053,34 +2957,35 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd" dependencies = [ "cfg-if", + "once_cell", + "rustversion", "wasm-bindgen-macro", + "wasm-bindgen-shared", ] [[package]] -name = "wasm-bindgen-backend" -version = "0.2.92" +name = "wasm-bindgen-futures" +version = "0.4.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "836d9622d604feee9e5de25ac10e3ea5f2d65b41eac0d9ce72eb5deae707ce7c" dependencies = [ - "bumpalo", - "log", + "cfg-if", + "js-sys", "once_cell", - "proc-macro2", - "quote", - "syn 2.0.66", - "wasm-bindgen-shared", + "wasm-bindgen", + "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2088,59 +2993,71 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40" dependencies = [ + "bumpalo", "proc-macro2", "quote", - "syn 2.0.66", - "wasm-bindgen-backend", + "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4" +dependencies = [ + "unicode-ident", +] [[package]] name = "web-sys" -version = "0.3.69" +version = "0.3.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b32828d774c412041098d182a8b38b16ea816958e07cf40eec2bc080ae137ac" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" dependencies = [ "js-sys", "wasm-bindgen", ] [[package]] -name = "webpki" -version = "0.22.4" +name = "webpki-root-certs" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" +checksum = "36a29fc0408b113f68cf32637857ab740edfafdf460c326cd2afaa2d84cc05dc" dependencies = [ - "ring 0.17.8", - "untrusted 0.9.0", + "rustls-pki-types", ] [[package]] name = "webpki-roots" -version = "0.22.6" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" +checksum = "12bed680863276c63889429bfd6cab3b99943659923822de1c8a39c49e4d722c" dependencies = [ - "webpki", + "rustls-pki-types", ] [[package]] name = "whoami" -version = "1.5.1" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9" +checksum = "5d4a4db5077702ca3015d3d02d74974948aba2ad9e12ab7df718ee64ccd7e97d" dependencies = [ - "redox_syscall 0.4.1", + "libredox", "wasite", "web-sys", ] @@ -2163,11 +3080,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -2178,20 +3095,70 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-core" -version = "0.52.0" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" dependencies = [ - "windows-targets 0.52.5", + "windows-link", ] [[package]] name = "windows-sys" -version = "0.48.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets 0.48.5", + "windows-targets 0.42.2", ] [[package]] @@ -2200,174 +3167,377 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] name = "windows-targets" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.53.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", - "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.5" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" [[package]] name = "windows_aarch64_msvc" -version = "0.48.5" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" [[package]] name = "windows_x86_64_gnu" -version = "0.48.5" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" [[package]] name = "windows_x86_64_msvc" -version = "0.48.5" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" + +[[package]] +name = "winnow" +version = "0.7.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829" + +[[package]] +name = "wit-bindgen" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" + +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "668f5168d10b9ee831de31933dc111a459c97ec93225beb307aed970d1372dfd" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" +version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +checksum = "2c7962b26b0a8685668b671ee4b54d007a67d4eaf05fda79ac0ecf41e32270f1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn", ] [[package]] -name = "zstd" -version = "0.13.1" +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ - "zstd-safe", + "proc-macro2", + "quote", + "syn", + "synstructure", ] [[package]] -name = "zstd-safe" -version = "7.1.0" +name = "zeroize" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd99b45c6bc03a018c8b8a86025678c87e55526064e38f9df301989dce7ec0a" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" dependencies = [ - "zstd-sys", + "displaydoc", + "yoke", + "zerofrom", ] [[package]] -name = "zstd-sys" -version = "2.0.10+zstd.1.5.6" +name = "zerovec" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" dependencies = [ - "cc", - "pkg-config", + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zip" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12598812502ed0105f607f941c386f43d441e00148fce9dec3ca5ffb0bde9308" +dependencies = [ + "arbitrary", + "crc32fast", + "flate2", + "indexmap", + "memchr", + "zopfli", +] + +[[package]] +name = "zlib-rs" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40990edd51aae2c2b6907af74ffb635029d5788228222c4bb811e9351c0caad3" + +[[package]] +name = "zmij" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd8f3f50b848df28f887acb68e41201b5aea6bc8a8dacc00fb40635ff9a72fea" + +[[package]] +name = "zopfli" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f05cd8797d63865425ff89b5c4a48804f35ba0ce8d125800027ad6017d2b5249" +dependencies = [ + "bumpalo", + "crc32fast", + "log", + "simd-adler32", ] diff --git a/Cargo.toml b/Cargo.toml index 4d14f8f..fa483e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,46 +1,74 @@ [package] -name = "testaustime-rs" +name = "testaustime" version = "0.3.1" edition = "2021" -authors = ["Ville Järvinen ", "Luukas Pörtfors "] +authors = [ + "Ville Järvinen ", + "Luukas Pörtfors ", +] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] default = ["testausid"] -testausid = ["dep:awc"] +testausid = ["dep:reqwest"] [profile.release] lto = true [dependencies] -actix-web = { version = "4.5.1", features = ["macros", "rustls"] } -awc = { version = "3.0.0", features = ["rustls"], optional = true } -actix-cors = "0.6" -http = "0.2" +axum = { version = "0.8", features = ["macros", "tokio"] } +axum-extra = { version = "0.12", features = ["cookie", "cookie-private"] } +tokio = { version = "1.35", features = ["macros", "rt-multi-thread"] } +reqwest = { version = "0.13", optional = true, default-features = false, features = [ + "json", + "rustls", + "charset", + "http2", + "form" +] } +http = "1.0" +http-body-util = "0.1" regex = "1.5" -tracing = "0.1.37" -tracing-actix-web = "0.6.2" +tower = "0.5" +tower-http = { version = "0.6", features = ["trace"] } -log = "0.4" -env_logger = "0.9" -thiserror = "1.0" +tracing = "0.1.40" +tracing-subscriber = { version = "0.3", features = [ + "env-filter", + "tracing-log", +] } +tracing-futures = "0.2" + +thiserror = "2.0" serde = { version = "1.0.164", features = ["derive"] } serde_json = "1.0" serde_derive = "1.0" -toml = "0.5" +toml = "0.9" futures = "0.3" futures-util = "0.3" chrono = { version = "0.4", features = ["serde"] } -dashmap = "5.2" -argon2 = "0.4" -rand = "0.8" +dashmap = "6.1" +argon2 = { version = "0.5", features = ["std"] } +rand = "0.9" dotenv = "0.15" url = "2.2" -itertools = "0.10.3" -governor = "0.6.0" -diesel = { version = "2.1.0", features = ["chrono", "serde_json", "postgres_backend"] } -diesel-async = { version = "0.4.1", features = ["postgres", "deadpool"] } +itertools = "0.14" +governor = "0.10.0" +diesel = { version = "2.1.0", features = ["chrono", "serde_json"] } +diesel-async = { version = "0.7", features = ["postgres", "deadpool"] } +lettre = { version = "0.11.14", default-features = false, features = [ + "tokio1-rustls-tls", + "tracing", + "pool", + "smtp-transport", + "hostname", + "builder", +] } +mime = "0.3.17" +utoipa = { version = "5.4.0", features = ["axum_extras", "chrono"] } +utoipa-axum = "0.2.0" +utoipa-swagger-ui = { version = "9.0.2", features = ["axum", "vendored"] } diff --git a/docs/APISPEC.md b/docs/APISPEC.md deleted file mode 100644 index 1a15340..0000000 --- a/docs/APISPEC.md +++ /dev/null @@ -1,1680 +0,0 @@ -# Testaustime-rs api documentation - -## General info - -Testaustime API gives 5 different routes: - -- [/auth/](#auth) -- [/users/](#users) -- [/activity/](#activity) -- [/friends/](#friends) -- [/leaderboards/](#leaderboards) - -Basic path: `https://api.testaustime.fi` - -Limits: - -- Usual Ratelimit: 10 req/m. - -## Auth - -Contains various user authorization operations - -### Endpoints - -| Endpoint | Method | Description | -| --------------------------------------- | ------ | -------------------------------------------------------------------------------------- | -| [/auth/register](#register) | POST | Creating a new user and returns the user auth token, friend code and registration time | -| [/auth/login](#login) | POST | Loging user to system and returns the user auth token and friend code | -| [/auth/securedaccess](#securedaccess) | POST | Generating secured access token | -| [/auth/changeusername](#changeusername) | POST | Changing user username | -| [/auth/changepassword](#changepassword) | POST | Changing user password | -| [/auth/regenerate](#regenerate) | POST | Regenerating user auth token | - -#### [1. POST /auth/register](#auth) - -Creating a new user and returns the user auth token, friend code and registration time. Ratelimit: 1 req/24h - -
- Header params - -| Name | Value | -| ------------ | ---------------- | -| Content-Type | application/json | - -
- -
- Body params - -| Param | Type | Required | Description | -| -------- | ------ | -------- | ---------------------------------------------------- | -| username | string | Yes | Usename has to be between 2 and 32 characters long | -| password | string | Yes | Password has to be between 8 and 128 characters long | - -
- -**Sample request** - -```curl -curl --request POST https://api.testaustime.fi/auth/register' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "username": "username", - "password": "password" -} -``` - -**Sample response** - -```JSON -{ - "auth_token": "", - "username": "username", - "friend_code": "friend_code", - "registration_time": "YYYY-MM-DDTHH:MM:SS.sssssssssZ" -} -``` - -
- Response definitions - -| Response Item | Type | Description | -| ----------------- | ------ | ---------------------------------------------------------- | -| auth_token | string | Authentication token for identifying the user | -| username | string | Username | -| friend_code | string | With this code other users can add user to the friend list | -| registration_time | string | Time of registration in ISO 8601 format | - -
- -#### [2. POST /auth/login](#auth) - -Logins to a users account and returning the authentication token - -
- Header params - -| Name | Value | -| ------------ | ---------------- | -| Content-Type | application/json | - -
- -
- Body params - -| Param | Type | Required | Description | -| -------- | ------ | -------- | ---------------------------------------------------- | -| username | string | Yes | Usename has to be between 2 and 32 characters long | -| password | string | Yes | Password has to be between 8 and 128 characters long | - -
- -**Sample request** - -```curl -curl --request POST 'https://api.testaustime.fi/auth/login' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "username": "username", - "password": "password" -}' - -``` - -**Sample response** - -```JSON -{ - "id": 0, - "auth_token": "", - "friend_code": "friend_code", - "username": "username", - "registration_time": "YYYY-MM-DDTHH:MM:SS.ssssssZ" -} -``` - -
- Response definitions - -| Response Item | Type | Description | -| ----------------- | ------ | ---------------------------------------------------------- | -| id | int | User id | -| auth_token | string | Authentication token for identifying the user | -| username | string | Username | -| friend_code | string | With this code other users can add user to the friend list | -| registration_time | string | Time of registration in ISO 8601 format | - -
- -#### [3. POST /auth/securedaccess](#auth) - -Generates new secured access token, each token is valid for 1 hour. Used for confirming user identity when doing critical changes. - -
- Header params - -| Name | Value | -| ------------ | ---------------- | -| Content-Type | application/json | - -
- -
- Body params - -| Param | Type | Required | Description | -| -------- | ------ | -------- | ---------------------------------------------------- | -| username | string | Yes | Usename has to be between 2 and 32 characters long | -| password | string | Yes | Password has to be between 8 and 128 characters long | - -
- -**Sample request** - -```curl -curl --request POST 'https://api.testaustime.fi/auth/securedaccess' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "username": "username", - "password": "password" -}' - -``` - -**Sample response** - -```JSON -{ - "token": "" -} -``` - -
- Response definitions - -| Response Item | Type | Description | -| ------------- | ------ | -------------------- | -| token | string | Secured access token | - -
- -#### [4. POST /auth/changeusername](#auth) - -Changes username, requires secured access token - -
- Header params: - -| Name | Value | -| ------------- | -------------------- | -| Content-Type | application/json | -| Authorization | Bearer `` | - -
- -
- Body params: - -| Param | Type | Required | Description | -| ----- | ------ | -------- | ---------------------------------------------------------------- | -| new | string | Yes | New username. Usename has to be between 2 and 32 characters long | - -
- -**Sample request** - -```curl -curl --request POST 'https://api.testaustime.fi/auth/changeusername' \ ---header 'Content-Type: application/json' \ ---header 'Authorization: Bearer '{ - "new": "new_username" -}' -``` - -**Sample response** - -```http -200 OK -``` - -
- Error examples: - -| Error | Error code | Body | -| -------------------------------- | --------------- | ------------------------------------------------------ | -| "new" has <2 or >32 symbols | 400 Bad Request | `{"error" : "Username is not between 2 and 32 chars"}` | -| "new" is using existing username | 403 Forbidden | `"error"» : "User exists"` | - -
- -#### [5. POST /auth/changepassword](#auth) - -Changes users password, requires secured access token - -
- Header params: - -| Name | Value | -| ------------- | -------------------- | -| Content-Type | application/json | -| Authorization | Bearer `` | - -
- -
- Body params: - -| Param | Type | Required | Description | -| ----- | ------ | -------- | ------------------------------------------------------------------ | -| old | string | Yes | Current password | -| new | string | Yes | New password. Password has to be between 8 and 128 characters long | - -
- -**Sample request** - -```curl -curl --request POST 'https://api.testaustime.fi/auth/changepassword' \ ---header 'Content-Type: application/json' \ ---header 'Authorization: Bearer ' \ ---data-raw '{ - "old": "old_password", - "new": "new_password" -}' -``` - -**Sample response** - -```http -200 OK -``` - -
- Error examples: - -| Error | Error code | Body | -| ----------------------------- | --------------- | ------------------------------------------------------ | -| "new" has < 8 or >132 symbols | 400 Bad Request | `{"error": "Password is not between 8 and 132 chars"}` | -| "old" is incorrect | 401 Unathorized | `{"error": "You are not authorized"}` | - -
- -#### [6. POST /auth/regenerate](#auth) - -Regenerates users authentication token, requires secured access token - -
- Header params: - -| Name | Value | -| ------------- | -------------------- | -| Authorization | Bearer `` | - -
- -**Sample request** - -```curl -curl --request POST 'https://api.testaustime.fi/auth/regenerate' \ ---header 'Content-Type: application/json' ---header 'Authorization: Bearer ' -``` - -**Sample response** - -```JSON -{ - "token": "" -} -``` - -
- Response definitions: - -| Response Item | Type | Description | -| ------------- | ------ | -------------------------------------------------- | -| token | string | New Authentication token used for identifying user | - -
- -## Users - -Contains various mostly read-operations with user data - -### Endpoints - -| Endpoint | Method | Description | -| ------------------------------------------------------- | ------ | ----------------------------------------------- | -| [/users/@me](#me) | GET | Geting data about authorized user | -| [/users/@me/leaderboards](#my_leaderboards) | GET | Geting list of user leaderboards | -| [/users/{username}/activity/data](#activity_data) | GET | Geting user or user friend coding activity data | -| [/users/{username}/activity/summary](#activity_summary) | GET | Get a summary of a users activity | -| [/users/{username}/activity/current](#activity_cur) | GET | Get a users current coding session | -| [/users/@me/delete](#delete_myself) | DELETE | Deleting user account | - -#### [1. GET /users/@me](#users) - -Gets data about authorized user - -
- Header params: - -| Name | Value | -| ------------- | --------------------- | -| Authorization | Bearer `` | - -
- -**Sample request** - -```curl -curl --location --request GET 'https://api.testaustime.fi/users/@me' \ ---header 'Authorization: Bearer ``' -``` - -**Sample response** - -```JSON -{ - "id": 0, - "friend_code": "friend_code", - "username": "username", - "registration_time": "YYYY-MM-DDTHH:MM:SS.ssssssZ" -} -``` - -
- Response definitions: - -| Response Item | Type | Description | -| ----------------- | ------ | ---------------------------------------------------------- | -| id | int | User id | -| friend_code | string | With this code other users can add user to the friend list | -| username | string | Username | -| registration_time | string | Time of registration in ISO 8601 format | - -
- -#### [2. GET /users/@me/leaderboards](#users) - -Gets list of user leaderboards - -
- Header params: - -| Name | Value | -| ------------- | --------------------- | -| Authorization | Bearer `` | - -
- -**Sample request** - -```curl -curl --location --request GET 'https://api.testaustime.fi/users/@me/leaderboards' \ ---header 'Authorization: Bearer ' -``` - -**Sample response** - -```JSON -[ - { - "name": "Leaderboard name", - "member_count": 2 - } -] -``` - -
- Response definitions: - -| Response Item | Type | Description | -| ------------- | ------ | ------------------------------------------------- | -| name | string | Name of leaderboard in which the user is a member | -| member_count | int | Number of users in the leaderboard | - -
- -Required headers: - -``` -Authorization: Bearer -``` - -#### [3. GET /users/{username}/activity/data](#users) - -Geting user or user friend coding activity data - -
- Header params: - -| Name | Value | -| ------------- | --------------------- | -| Authorization | Bearer `` | - -
- -
- Path params: - -| Path param | Description | -| ---------- | ------------------------------------------------------------------ | -| Username | Own or friend username. Also own username can be replaced on `@me` | - -
- -**Sample request** - -```curl -curl --location --request GET 'https://api.testaustime.fi/users/@me/activity/data' \ ---header 'Authorization: Bearer ' -``` - -**Sample response** - -```JSON -[ - { - "id": 0, - "start_time": "YYYY-MM-DDTHH:MM:SS.ssssssZ", - "duration": 0, - "project_name": "project_name", - "language": "language", - "editor_name": "editor_name", - "hostname": "hostname", - "hidden": false - } -] -``` - -
- Response definitions: - -| Response Item | Type | Description | -| ------------- | ------- | ------------------------------------------------------------------------------------ | -| id | int | ID of user code session | -| start_time | string | Start time (time of sending first heartbeat) of user code session in ISO 8601 format | -| duration | int | Duration of user code session in seconds | -| project_name | string | Name of the project in which user have a code session. Empty string if hidden. | -| language | string | Code language of the code session | -| editor_name | string | Name of IDE (Visual Studio Code, IntelliJ, Neovim, etc.) in which user is coding | -| hostname | string | User hostname | -| hidden | boolean | Is this project hidden? | - -
- -#### [4. GET /users/{username}/activity/summary](#users) - -Get a summary of a users activity - -
- Header params: - -| Name | Value | -| ------------- | --------------------- | -| Authorization | Bearer `` | - -
- -
- Path params: - -| Path param | Description | -| ---------- | --------------------------------------------------------------------- | -| Username | Own or a friends username. Own username can be substituted with `@me` | - -
- -**Sample request** - -```curl -curl --location --request GET 'https://api.testaustime.fi/users/@me/activity/summary' \ ---header 'Authorization: Bearer ' -``` - -**Sample response** - -```JSON -{ - "all_time": { - "languages": { - "c": 1000, - "rust": 2000 - }, - "total": 3000 - }, - "last_month": { - "languages": { - "c": 100, - "rust": 200, - } - "total": 300 - }, - "last_week": { - "languages": { - "c": 10, - "rust": 20 - }, - "total": 30 - } -} -``` - -
- Response definitions: - -| Response Item | Type | Description | -| ------------- | ------ | ------------------------------------------------------------------------------ | -| all_time | Object | All time coding activity summary for the user | -| languages | Object | Contains fields named after languages that have the coding time as their value | -| total | int | The total coding time of the given period | -| last_month | Object | Similar to `all_time` | -| last_week | Object | Similar to `all_time` and `last_month` | - -
- -#### [5. GET /users/{username}/activity/current](#users) - -Gets details of the ongoing coding session if there is one. - -
- Header params: - -| Name | Value | -| ------------- | --------------------- | -| Authorization | Bearer `` | - -
- -
- Path params: - -| Path param | Description | -| ---------- | ----------------------------------------------------------------------- | -| Username | Own or a friends username. Own username can also be replaced with `@me` | - -
- -**Sample request** - -```curl -curl --request GET 'https://api.testaustime.fi/users/@me/activity/current' \ ---header 'Authorization: Bearer ' -``` - -**Sample response** - -```JSON -{ - "started": "YYYY-MM-DDTHH:MM:SS.ssssssZ", - "duration": "10", - "heartbeat": { - "language": "c", - "hostname": "hostname1", - "editor_name": "Neovim", - "project_name": "cool_project22", - "hidden": false - } -} -``` - -
- Response definitions: - -| Response Item | Type | Description | -| ------------- | ------ | ------------------------------------------------------------------------------------ | -| started | string | Start time (time of sending first heartbeat) of user code session in ISO 8601 format | -| duration | int | Duration of user code session in seconds | -| heartbeat | Object | The HeartBeat object described [here](#activity_up) | - -
- -#### [6. DELETE /users/@me/delete](#users) - -Deletes user account - -
- Header params: - -| Name | Value | -| ------------ | ---------------- | -| Content-Type | application/json | - -
- -
- Body params: - -| Param | Type | Required | Description | -| -------- | ------ | -------- | ------------- | -| username | string | Yes | Username | -| password | string | Yes | User password | - -
- -**Sample request** - -```curl -curl --request DELETE 'https://api.testaustime.fi/users/@me/delete' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "username": "username", - "password": "password" -}' -``` - -**Sample response** - -```http -200 OK -``` - -## Activity - -Contains main operations with activity heartbeats on which this service is based on - -### Endpoints - -| Endpoint | Method | Description | -| ------------------------------------ | ------ | ------------------------------------------------------------ | -| [/activity/update](#activity_up) | POST | Creating code session and logs current activity in that | -| [/activity/flush](#activity_fl) | POST | Flushing any currently active coding session | -| [/activity/rename](#activity_rename) | POST | Rename all activities with matching `project_name` | -| [/activity/delete](#activity_del) | DELETE | Deleting selected code session | -| [/activity/hide](#activity_hide) | POST | Hides or reveals all activities with matching `project_name` | - -#### [1. POST /activity/update](#activity) - -Main endpoint of the service. Creates code session and logs current activity in that. - -> _The desired interval at which to send heartbeats is immediately when editing a file, and after that at max every 30 seconds, and only when the user does something actively in the editor_ - -
- Header params: - -| Name | Value | -| ------------- | --------------------- | -| Authorization | Bearer `` | -| Content-Type | application/json | - -
- -
- Body params: - -| Param | Type | Description | -| ------------ | ------- | -------------------------------------------------------------------------------- | -| language | string | Code language of the code session | -| hostname | string | User hostname | -| editor_name | string | Name of IDE (Visual Studio Code, IntelliJ, Neovim, etc.) in which user is coding | -| project_name | string | Name of the project in which user have a code session. | -| hidden | boolean | Should this project be hidden? | - -
- -**Sample first request** - -If the user doesn't have any active code session with this set of body params, then first request `POST /activity/update` creates new code session. Any other code session automatically stops/flushes after starting new one, so the user can't have >1 active code sessions in one time - -```curl -curl --request POST 'https://api.testaustime.fi/activity/update' \ ---header 'Authorization: Bearer ' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "language": "Python", - "hostname": "Hostname1", - "editor_name": "IntelliJ", - "project_name": "example_project", - "hidden": false -}' -``` - -**Sample first response** - -```HTTP -200 OK -``` - -**Sample next request** - -```curl -curl --request POST 'https://api.testaustime.fi/activity/update' \ ---header 'Authorization: Bearer ' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "language": "Python", - "hostname": "Hostname1", - "editor_name": "IntelliJ", - "project_name": "example_project", - "hidden": false -}' -``` - -**Sample next response** - -```HTTP -200 OK -Body: PT7.420699439S //duration of the user code session in seconds to nanoseconds -``` - -#### [2. POST /activity/flush](#activity) - -Flushes/stops any currently active coding session - -> _Active coding session can be flushed/stoped automatically without any activity updates for a long time. Also can be flushed automatically in case of starting new code session_ - -
- Header params: - -| Name | Value | -| ------------- | --------------------- | -| Authorization | Bearer `` | - -
- -**Sample request** - -```curl -curl --request POST 'https://api.testaustime.fi/activity/flush' \ ---header 'Authorization: Bearer ' -``` - -**Sample response** - -```HTTP -200 OK -``` - -#### [3. POST /activity/rename](#activity) - -Rename all activities that have a matching `project_name` - -
- Header params: - -| Name | Value | -| ------------- | --------------------- | -| Content-Type | application/json | -| Authorization | Bearer `` | - -
- -
- Body params: -| Param | Type | Required | Description | -| --- | --- | --- | --- | -| from | string | Yes | old name | -| to | string | Yes | new name | -
- -**Sample request** - -```curl -curl --request POST 'https://api.testaustime.fi/activity/rename' \ ---header 'Content-Type: application/json' \ ---header 'Authorization: Bearer ' \ ---data-raw '{ - "from": "old_name", - "to": "new_name" -}' -``` - -**Sample response** - -```JSON -{ - "affected_activities": 20 -} -``` - -
- Response definitions: -| Response Item | Type | Description | -| --- | --- | --- | -| affected_activities | int | Number of activities renamed | -
- -#### [4. POST /activity/delete](#activity) - -Deletes selected code session, requires secured access token - -
- Header params: - -| Name | Value | -| ------------- | -------------------- | -| Authorization | Bearer `` | - -
- -
- Body params: - -| Param | Type | Description | -| -------- | ------ | --------------------------------------------------------------------------------- | -| raw text | string | Activity id from response [`GET /users/{username}/activity/data`](#activity_data) | - -
- -**Sample request** - -```curl -curl --request DELETE 'https://api.testaustime.fi/activity/delete' \ ---header 'Authorization: Bearer ' \ ---data-raw 'activity_id' -``` - -**Sample response** - -```HTTP -200 OK -``` - -#### [5. POST /activity/hide](#activity) - -Hide or reveal all activities that have a matching `project_name` - -
- Header params: - -| Name | Value | -| ------------- | --------------------- | -| Content-Type | application/json | -| Authorization | Bearer `` | - -
- -
- Body params: -| Param | Type | Required | Description | -| --- | --- | --- | --- | -| target_project | string | Yes | Project name | -| hidden | boolean | Yes | Should the project be hidden? | -
- -**Sample request** - -```curl -curl --request POST 'https://api.testaustime.fi/activity/hide' \ ---header 'Content-Type: application/json' \ ---header 'Authorization: Bearer ' \ ---data-raw '{ - "project_name": "super_secret_project", - "hidden": true -}' -``` - -**Sample response** - -```JSON -{ - "affected_activities": 100 -} -``` - -
- Response definitions: -| Response Item | Type | Description | -| --- | --- | --- | -| affected_activities | int | Number of activities hidden/revealed | -
- -## Friends - -Containts CRUD-operations with user friends - -### Endpoints - -| Endpoint | Method | Description | -| ------------------------------------- | ------ | -------------------------------------------------------------------- | -| [/friends/add](#add_friend) | POST | Adding the holder of the friend_token as a friend of authorized user | -| [/friends/list](#list_friends) | GET | Geting a list of added user friends | -| [/friends/regenerate](#regenerate_fc) | POST | Regenerateing the authorized user's friend code | -| [/friends/remove](#remove_friend) | DELETE | Removing another user from user friend list | - -#### [1. POST /friends/add](#friends) - -Adds the holder of the friend token as a friend of the authenticating user - -
- Header params: - -| Name | Value | -| ------------- | --------------------- | -| Authorization | Bearer `` | - -
- -
- Body params: - -| Param | Type | Description | -| -------- | ------ | ----------------------------------------------- | -| raw text | string | Should contain friend code without any prefixes | - -
- -**Sample request** - -```curl -curl --request POST 'https://api.testaustime.fi/friends/add' \ ---header 'Authorization: Bearer ' \ ---data-raw 'friend_code' -``` - -**Sample response** - -```JSON -{ - "username": "Username", - "coding_time": { - "all_time": 0, - "past_month": 0, - "past_week": 0 - }, - "status": { - "started": "2023-03-02T12:13:53.121240868", - "duration": 5, - "heartbeat": { - "project_name": "My Project", - "language": "javascript", - "editor_name": "vscode", - "hostname": "mylaptop", - "hidden": false - } - } -} -``` - -
- Error examples: - -| Error | Error code | Body | -| -------------------------------------------------------------- | ------------- | ------------------------------------- | -| Friendcode is already used for adding a friend | 403 Forbidden | { "error": "Already friends"} | -| Friendcode from body request is not found | 404 Not Found | { "error": "User not found"} | -| Friendcode matches with friendcode of authorized user themself | 403 Forbidden | { "error": "You cannot add yourself"} | - -
- -#### [2. GET friends/list](#friends) - -Gets a list of added user friends - -
- Header params: - -| Name | Value | -| ------------- | --------------------- | -| Authorization | Bearer `` | - -
- -**Sample request** - -```curl -curl --request GET ''https://api.testaustime.fi/friends/list' \ ---header 'Authorization: Bearer ' -``` - -**Sample response** - -```JSON -[ - { - "username": "username", - "coding_time": { - "all_time": 0, - "past_month": 0, - "past_week": 0 - }, - "status": { - "started": "2023-03-02T12:13:53.121240868", - "duration": 5, - "heartbeat": { - "project_name": "My Project", - "language": "javascript", - "editor_name": "vscode", - "hostname": "mylaptop", - "hidden": true - } - } - } -] -``` - -
- Response definitions: - -| Response Item | Type | Description | -| ------------- | ------- | -------------------------------------------------------------------------------- | -| username | string | Friend's username | -| coding_time | Object | Coding friend's time by total, past month and past week | -| all_time | int | Total duration of user code sessions in seconds | -| past_month | int | Total duration of user code sessions in seconds for past month | -| past_week | int | Total duration of user code sessions in seconds for past week | -| status | Object | Information about the user's current activity | -| started | string | Timestamp of when the session start | -| duration | int | Duration of user code session in seconds | -| heartbeat | Object | Information about the latest heartbeat | -| project_name | string | Name of the project in which user have a code session. Empty string if hidden. | -| language | string | Code language of the code session | -| editor_name | string | Name of IDE (Visual Studio Code, IntelliJ, Neovim, etc.) in which user is coding | -| hostname | string | User hostname | -| hidden | boolean | Is the project hidden? | - -
- -#### [3. POST /friends/regenerate](#friends) - -Regenerates the authorized user's friend code, requires secured access token - -
- Header params: - -| Name | Value | -| ------------- | -------------------- | -| Authorization | Bearer `` | - -
- -**Sample request** - -```curl -curl --request POST 'https://api.testaustime.fi/friends/regenerate' \ ---header 'Authorization: Bearer ' -``` - -**Sample response** - -```JSON -{ - "friend_code": "friend_code" -} -``` - -
- Response definitions: - -| Response Item | Type | Description | -| ------------- | ------ | ----------------------------------------------------------------------- | -| friend_code | string | New friend code. Using for the all next create friends paire operations | - -
- -#### [4. DELETE /friends/remove](#friends) - -Removes another user from your friend list, requires secured access token - -
- Header params: - -| Name | Value | -| ------------- | -------------------- | -| Authorization | Bearer `` | - -
- -
- Body: - -| Param | Type | Description | -| -------- | ------ | -------------------------------------------- | -| raw text | string | Should contain username without any prefixes | - -
- -**Sample request** - -```curl -curl --request DELETE 'https://api.testaustime.fi/friends/remove' \ ---header 'Authorization: Bearer ' \ ---data-raw 'username' -``` - -**Sample response** - -```HTTP -200 OK -``` - -## Leaderboards - -Containts CRUD-operations with leaderboards consisting of other Testaustime users - -### Endpoints - -| Endpoint | Method | Description | -| ------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------ | -| [/leaderboards/create](#create_lb) | POST | Adding new leaderboard | -| [/leaderboard/join](#join_lb) | POST | Joining leaderboard by it's invite code | -| [/leaderboards/{name}](#read_lb) | GET | Getting info about leaderboard if authorized user is a member | -| [/leaderboard/{name}](#delete_lb) | DELETE | Deleting leaderboard if authorized user has admin rights | -| [/leaderboards/{name}/leave](#leave_lb) | POST | Leaving the leaderboard | -| [/leaderboards/{name}/regenerate](#regenerate_lb) | POST | Regenerating invite code of the leaderboard if authorized user has admin rights | -| [/leaderboards/{name}/promote](#promote_lb) | POST | Promoting member of a leaderboard to admin if authorized user has admin rights | -| [/leaderboards/{name}/demote](#demote_lb) | POST | Demoting promoted admin to regular member of the leaderboard if authorized user has admin rights | -| [/leaderboards/{name}/kick](#kick_lb) | POST | Kicking user from leaderboard if authorized user has root admin rights | - -#### [1. POST /leaderboards/create](#leaderboards) - -Adds new leaderboard - -
- Header params: - -| Name | Value | -| ------------- | --------------------- | -| Authorization | Bearer `` | -| Content-Type | application/json | - -
- -
- Body params: - -| Param | Type | Description | -| ----- | ------ | ---------------------------- | -| name | string | Name of creating leaderboard | - -
- -**Sample request** - -```curl -curl --request POST 'https://api.testaustime.fi/leaderboards/create' \ ---header 'Authorization: Bearer ' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "name": "" -}' -``` - -**Sample response** - -```JSON -{ - "invite_code": "invite_code" -} -``` - -
- Response definitions: - -| Response Item | Type | Description | -| ------------- | ------ | ----------------------------------- | -| invite_code | string | Invite code for joining leaderboard | - -
- -
- Error examples: - -| Error | Error code | Body | -| ----------------------------------------- | ------------- | -------------------------------- | -| "Name" of the leaderboard is already used | 403 Forbidden | { "error": "Leaderboard exists"} | - -
- -#### [2. POST /leaderboard/join](#leaderboards) - -Joins leaderboard by it's invite code - -
- Header params: - -| Name | Value | -| ------------- | --------------------- | -| Authorization | Bearer `` | -| Content-Type | application/json | - -
- -
- Body params: - -| Param | Type | Description | -| ------ | ------ | ----------------------------------- | -| invite | string | Invite code for joining leaderboard | - -
- -**Sample request** - -```curl -curl --request POST 'https://api.testaustime.fi/leaderboards/join' \ ---header 'Authorization: Bearer ' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "invite": "invite_code" -}' -``` - -**Sample response** - -```JSON -{ - "member_count": 0, - "name": "name" -} - -``` - -
- Response definitions: - -| Response Item | Type | Description | -| ------------- | ------ | ----------------------------- | -| member_count | int | Number of leaderboard members | -| name | string | Leaderboard name | - -
- -
- Error examples: - -| Error | Error code | Body | -| -------------------------------------------------- | ------------- | ------------------------------------- | -| Authorized user is already part of the leaderboard | 403 Forbidden | { "error": "You're already a member"} | -| Leaderboard not found by invite code | 404 Not Found | { "error": "Leaderboard not found"} | - -
- -#### [3. GET /leaderboards/{name}](#leaderboards) - -Gets info about leaderboard if authorized user is a member - -
- Header params: - -| Name | Value | -| ------------- | --------------------- | -| Authorization | Bearer `` | - -
- -
- Path params: - -| Path param | Description | -| ---------- | ---------------- | -| {name} | Leaderboard name | - -
- -**Sample request** - -```curl -curl --request GET 'https://api.testaustime.fi/leaderboards/{name}' \ ---header 'Authorization: Bearer ' -``` - -**Sample response** - -```JSON -{ - "name": "name", - "invite": "invite_code", - "creation_time": "YYYY-MM-DDTHH:MM:SS.ssssssZ", - "members": [ - { - "username": "username", - "admin": true, - "time_coded": 0 - } - ] -} -``` - -
- Response definitions: - -| Response Item | Type | Description | -| ------------- | ------------------------ | ---------------------------------------------- | -| name | int | Leaderboard name | -| invite | int | Invite code for joining leaderboard | -| creation_time | string (ISO 8601 format) | Time of leaderboard creation to microsends | -| members | array object | Information about leaderboard members | -| username | string | Member username | -| admin | boolean | Rights of leaderboard member: admin or regular | -| time_coded | int | Total duration of user code sessions in second | - -
- -
- Error examples: - -| Error | Error code | Body | -| ----------------------------------------------- | ---------------- | ------------------------------------ | -| Authorized user is not part of this leaderboard | 401 Unauthorized | { "error": "You are not authorized"} | -| Leaderboard not found by name | 404 Not Found | { "error": "Leaderboard not found"} | - -
- -#### [4. DELETE /leaderboard/{name}](#leaderboards) - -Deletes leaderboard if authorized user has admin rights, requires secured access token - -> _Note: Leaderboard can be deleted either by root administrator or by promoted one_ - -
- Header params: - -| Name | Value | -| ------------- | -------------------- | -| Authorization | Bearer `` | - -
- -
- Path params: - -| Path param | Description | -| ---------- | ---------------- | -| {name} | Leaderboard name | - -
- -**Sample request** - -```curl -curl --request DELETE 'https://api.testaustime.fi/leaderboards/{name}' \ ---header 'Authorization: Bearer ' -``` - -**Sample response** - -```HTTP -200 OK -``` - -
- Error examples: - -| Error | Error code | Body | -| ----------------------------------------------- | ---------------- | ------------------------------------ | -| Authorized user is not part of this leaderboard | 401 Unauthorized | { "error": "You are not authorized"} | -| Leaderboard not found by name | 404 Not Found | { "error": "Leaderboard not found"} | - -
- -#### [5. POST /leaderboards/{name}/leave](#leaderboards) - -Leaves the leaderboard, requires secured access token - -
- Header params: - -| Name | Value | -| ------------- | -------------------- | -| Authorization | Bearer `` | - -
- -
- Path params: - -| Path param | Description | -| ---------- | ---------------- | -| {name} | Leaderboard name | - -
- -**Sample request** - -```curl -curl --request POST 'https://api.testaustime.fi/leaderboards/{name}/leave' \ ---header 'Authorization: Bearer ' -``` - -**Sample response** - -```HTTP -200 OK -``` - -
- Error examples: - -| Error | Error code | Body | -| ------------------------------------------------ | ------------- | ------------------------------------------------------------- | -| Authorized user is the last admin in leaderboard | 403 Forbidden | { "error": "There are no more admins left, you cannot leave"} | -| User is not the part of the leaderboard | 403 Frobidden | { "error": "You're not a member"} | -| Leaderboard not found by name | 404 Not Found | { "error": "Leaderboard not found"} | - -
- -#### [6. POST /leaderboards/{name}/regenerate](#leaderboards) - -Regenerates invite code of the leaderboard if authorized user has admin rights, requires secured access token - -
- Header params: - -| Name | Value | -| ------------- | -------------------- | -| Authorization | Bearer `` | - -
- -
- Path params: - -| Path param | Description | -| ---------- | ---------------- | -| {name} | Leaderboard name | - -
- -**Sample request** - -```curl -curl --request POST 'https://api.testaustime.fi/leaderboards/{name}/regenerate' \ ---header 'Authorization: Bearer ' -``` - -**Sample response** - -```JSON -{ - "invite_code": "" -} -``` - -
- Error examples: - -| Error | Error code | Body | -| ------------------------------------------------------------------------ | ---------------- | ------------------------------------ | -| Authorized user is not part of found leaderboard or user is not an admin | 401 Unauthorized | { "error": "You are not authorized"} | -| Leaderboard not found by name | 404 Not Found | { "error": "Leaderboard not found"} | - -
- -#### [7. POST /leaderboards/{name}/promote](#leaderboards) - -Promotes member of a leaderboard to admin if authorized user has admin rights. Be careful of promoting users, root admin (creator of the leaderboard) can be demoted/kicked by a promoted one. Requires secured access token. - -> \*This request is idempotent, it means that you can: -> -> 1. _Promote user that is already admin and have in response 200 OK_ -> 2. _Promote yourself to admin being already admin and have in response 200 OK_ - -
- Header params: - -| Name | Value | -| ------------- | -------------------- | -| Content-Type | application/json | -| Authorization | Bearer `` | - -
- -
- Path params: - -| Path param | Description | -| ---------- | ---------------- | -| {name} | Leaderboard name | - -
- -
- Body params: - -| Param | Type | Description | -| ----- | ------ | ---------------------------------------------------- | -| user | string | Username of a leaderboard member you want to promote | - -
- -**Sample request** - -```curl -curl --request POST 'https://api.testaustime.fi/leaderboards/{name}/promote' \ ---header 'Content-Type: application/json' \ ---header 'Authorization: Bearer ' \ ---data-raw '{ - "user": "" -}' -``` - -**Sample response** - -```HTTP -200 OK - -``` - -
- Error examples: - -| Error | Error code | Body | -| ------------------------------------------------------------------------ | ---------------- | ------------------------------------ | -| Authorized user is not part of found leaderboard or user is not an admin | 401 Unauthorized | { "error": "You are not authorized"} | -| Promoting user is not the leaderboard member | 403 Forbidden | { "error": "You're not a member"} | - -
- -#### [8. POST /leaderboards/{name}/demote](#leaderboards) - -Demotes admin to regular member in the leaderboard if authorized user has admin rights. Be careful of promoting users, root admin (creator of the leaderboard) can be demoted by a promoted one. Requires secured access token. - -
- Header params: - -| Name | Value | -| ------------- | -------------------- | -| Content-Type | application/json | -| Authorization | Bearer `` | - -
- -
- Path params: - -| Path param | Description | -| ---------- | ---------------- | -| {name} | Leaderboard name | - -
- -
- Body params: - -| Param | Type | Description | -| ----- | ------ | -------------------------------------------------- | -| user | string | Username of a leaderboard admin you want to demote | - -
- -**Sample request** - -```curl -curl --request POST 'https://api.testaustime.fi/leaderboards/{name}/demote' \ ---header 'Content-Type: application/json' \ ---header 'Authorization: Bearer ' \ ---data-raw '{ - "user": "" -}' -``` - -**Sample response** - -```HTTP -200 OK - -``` - -
- Error examples: - -| Error | Error code | Body | -| ------------------------------------------------------------------------ | ---------------- | ------------------------------------ | -| Authorized user is not part of found leaderboard or user is not an admin | 401 Unauthorized | { "error": "You are not authorized"} | -| Demoting user is not the leaderboard member | 403 Forbidden | { "error": "You're not a member"} | - -
- -#### [9. POST /leaderboards/{name}/kick](#leaderboards) - -Kicks user from leaderboard if authorized user has admin rights, requires secured access token - -
- Header params: - -| Name | Value | -| ------------- | -------------------- | -| Content-Type | application/json | -| Authorization | Bearer `` | - -
- -
- Path params: - -| Path param | Description | -| ---------- | ---------------- | -| {name} | Leaderboard name | - -
- -
- Body params: - -| Param | Type | Description | -| ----- | ------ | ------------------------------------------------- | -| user | string | Username of a leaderboard member you want to kick | - -
- -**Sample request** - -```curl -curl --request POST 'https://api.testaustime.fi/leaderboards/{name}/kick' \ ---header 'Content-Type: application/json' \ ---header 'Authorization: Bearer ' \ ---data-raw '{ - "user": "" -}' -``` - -**Sample response** - -```HTTP -200 OK - -``` - -
- Error examples: - -| Error | Error code | Body | -| ------------------------------------------------------------------------ | ---------------- | ------------------------------------ | -| Authorized user is not part of found leaderboard or user is not an admin | 401 Unauthorized | { "error": "You are not authorized"} | -| Kicking user is not the leaderboard member | 403 Forbidden | { "error": "You're not a member"} | - -
diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..bbe5ac6 --- /dev/null +++ b/flake.lock @@ -0,0 +1,119 @@ +{ + "nodes": { + "crane": { + "locked": { + "lastModified": 1746291859, + "narHash": "sha256-DdWJLA+D5tcmrRSg5Y7tp/qWaD05ATI4Z7h22gd1h7Q=", + "owner": "ipetkov", + "repo": "crane", + "rev": "dfd9a8dfd09db9aad544c4d3b6c47b12562544a5", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1746772806, + "narHash": "sha256-5/Nq62wjkZrOhUULTFjgi4Dsc7T8kIluUPkoLsyAeUA=", + "owner": "nix-community", + "repo": "fenix", + "rev": "505bf684711e964c8f84d4c804e38f62b24accec", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1746663147, + "narHash": "sha256-Ua0drDHawlzNqJnclTJGf87dBmaO/tn7iZ+TCkTRpRc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "dda3dcd3fe03e991015e9a74b22d35950f264a54", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "fenix": "fenix", + "nixpkgs": "nixpkgs", + "systems": "systems", + "treefmt-nix": "treefmt-nix" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1746722075, + "narHash": "sha256-t4ZntWiW4C3lE621lV3XyK3KltC5/SW1V9G+CSz70rQ=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "8b624868e4ce2cb5b39559175f0978bee86bdeea", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1762938485, + "narHash": "sha256-AlEObg0syDl+Spi4LsZIBrjw+snSVU4T8MOeuZJUJjM=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "5b4ee75aeefd1e2d5a1cc43cf6ba65eba75e83e4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..451fc54 --- /dev/null +++ b/flake.nix @@ -0,0 +1,176 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + systems.url = "github:nix-systems/default"; + + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + crane.url = "github:ipetkov/crane"; + treefmt-nix.url = "github:numtide/treefmt-nix"; + treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = + { + self, + nixpkgs, + systems, + fenix, + crane, + treefmt-nix, + ... + }@inputs: + let + forEachSystem = nixpkgs.lib.genAttrs (import systems); + + perSystem = + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + + # Use default toolchain to include clippy and rustfmt + toolchain = fenix.packages.${system}.default.toolchain; + + craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; + + commonArgs = { + src = craneLib.cleanCargoSource ./.; + }; + + cargoArtifacts = craneLib.buildDepsOnly ( + commonArgs + // { + doCheck = false; + } + ); + + treefmtEval = treefmt-nix.lib.evalModule pkgs { + projectRootFile = "flake.nix"; + programs.nixfmt.enable = true; + programs.nixfmt.package = pkgs.nixfmt-rfc-style; + programs.taplo.enable = true; + programs.rustfmt.enable = true; + programs.rustfmt.package = toolchain; + }; + in + { + inherit + pkgs + toolchain + craneLib + commonArgs + cargoArtifacts + treefmtEval + ; + }; + in + { + packages = forEachSystem ( + system: + let + inherit (perSystem system) + pkgs + craneLib + commonArgs + cargoArtifacts + ; + in + rec { + testaustime-backend = craneLib.buildPackage ( + commonArgs + // { + inherit cargoArtifacts; + + nativeBuildInputs = [ + pkgs.postgresql + pkgs.diesel-cli + ]; + + checkInputs = [ + pkgs.postgresql + pkgs.diesel-cli + ]; + + preCheck = '' + # Set up a temporary PostgreSQL database + export PGDATA=$(mktemp -d) + export PGHOST=$PGDATA + + initdb -U postgres + pg_ctl start -o "-k $PGDATA -h \"\"" + + # Create your test database + createdb -U postgres test_db + + # Set environment variables your tests expect + export TEST_DATABASE="postgresql://postgres@localhost/test_db?host=$PGDATA" + + diesel database setup --database-url "$TEST_DATABASE" --migration-dir ${./migrations} + ''; + } + ); + + default = testaustime-backend; + + docker = pkgs.dockerTools.buildLayeredImage { + name = "ghcr.io/testaustime/testaustime-backend"; + tag = "nix"; + config.Cmd = + let + entrypoint = pkgs.writeShellScriptBin "entrypoint.sh" '' + while [ 1 ]; + do + ${pkgs.diesel-cli}/bin/diesel database setup --migration-dir ${./migrations} && break; + done + ${testaustime-backend}/bin/testaustime + ''; + in + [ "./${entrypoint}/bin/entrypoint.sh" ]; + }; + } + ); + + checks = forEachSystem ( + system: + let + inherit (perSystem system) + craneLib + commonArgs + cargoArtifacts + treefmtEval + ; + in + { + testaustime-backend-clippy = craneLib.cargoClippy ( + commonArgs + // { + inherit cargoArtifacts; + cargoClippyExtraArgs = "--all-targets -- --deny warnings"; + } + ); + + formatting = treefmtEval.config.build.check self; + } + ); + + formatter = forEachSystem (system: (perSystem system).treefmtEval.config.build.wrapper); + + devShells = forEachSystem ( + system: + let + inherit (perSystem system) pkgs toolchain treefmtEval; + in + { + default = pkgs.mkShell { + packages = [ + toolchain + pkgs.diesel-cli + treefmtEval.config.build.wrapper + ]; + }; + } + ); + }; +} diff --git a/migrations/2025-02-28-071855_add_email/down.sql b/migrations/2025-02-28-071855_add_email/down.sql new file mode 100644 index 0000000..fd4d217 --- /dev/null +++ b/migrations/2025-02-28-071855_add_email/down.sql @@ -0,0 +1,3 @@ +-- This file should undo anything in `up.sql` +ALTER TABLE user_identities +DROP COLUMN email VARCHAR UNIQUE; diff --git a/migrations/2025-02-28-071855_add_email/up.sql b/migrations/2025-02-28-071855_add_email/up.sql new file mode 100644 index 0000000..dbbae87 --- /dev/null +++ b/migrations/2025-02-28-071855_add_email/up.sql @@ -0,0 +1,3 @@ +-- Your SQL goes here +ALTER TABLE user_identities +ADD COLUMN email VARCHAR; diff --git a/migrations/2026-01-13-101356-0000_increase_heartbeat_limits/down.sql b/migrations/2026-01-13-101356-0000_increase_heartbeat_limits/down.sql new file mode 100644 index 0000000..3e96a2d --- /dev/null +++ b/migrations/2026-01-13-101356-0000_increase_heartbeat_limits/down.sql @@ -0,0 +1,5 @@ +-- This file should undo anything in `up.sql` +ALTER TABLE coding_activities + ALTER COLUMN language TYPE VARCHAR(32), + ALTER COLUMN editor_name TYPE VARCHAR(32), + ALTER COLUMN hostname TYPE VARCHAR(32); diff --git a/migrations/2026-01-13-101356-0000_increase_heartbeat_limits/up.sql b/migrations/2026-01-13-101356-0000_increase_heartbeat_limits/up.sql new file mode 100644 index 0000000..0fc8773 --- /dev/null +++ b/migrations/2026-01-13-101356-0000_increase_heartbeat_limits/up.sql @@ -0,0 +1,5 @@ +-- Your SQL goes here +ALTER TABLE coding_activities + ALTER COLUMN language TYPE VARCHAR(64), + ALTER COLUMN editor_name TYPE VARCHAR(64), + ALTER COLUMN hostname TYPE VARCHAR(64); diff --git a/settings.toml.example b/settings.toml.example index 0f29a80..3982f05 100644 --- a/settings.toml.example +++ b/settings.toml.example @@ -6,3 +6,7 @@ max_requests_per_min=30 max_heartbeats_per_min=8 max_registers_per_day=3 bypass_token="5woKC8Z3pqLqhDTX/zY1j1JxMozglIukNsr3YMMLBOk=" +max_registers_per_hour=5 +mail_server="mail.testaustime.fi" +mail_user="noreply@testaustime.fi" +mail_password="password" diff --git a/src/api/account.rs b/src/api/account.rs index 73a680b..dfb644f 100644 --- a/src/api/account.rs +++ b/src/api/account.rs @@ -1,23 +1,33 @@ -use actix_web::{web, HttpResponse, Responder}; +use axum::Json; +use http::StatusCode; use serde_derive::Deserialize; +use utoipa::ToSchema; -use crate::{api::auth::SecuredUserIdentity, database::DatabaseWrapper, error::TimeError}; +use crate::{database::DatabaseWrapper, error::TimeError, models::UserIdentity}; -#[derive(Deserialize)] +#[derive(Deserialize, ToSchema)] pub struct Settings { public_profile: Option, } -#[post("/account/settings")] +#[utoipa::path( + post, + path = "/account/settings", + security( + ("api_key" = []) + ), + responses( + (status = OK) + ) +)] pub async fn change_settings( - settings: web::Json, - userid: SecuredUserIdentity, + user: UserIdentity, db: DatabaseWrapper, -) -> Result { + settings: Json, +) -> Result { if let Some(public_profile) = settings.public_profile { - db.change_visibility(userid.identity.id, public_profile) - .await?; + db.change_visibility(user.id, public_profile).await?; }; - Ok(HttpResponse::Ok()) + Ok(StatusCode::OK) } diff --git a/src/api/activity.rs b/src/api/activity.rs index 779217b..8ef8f99 100644 --- a/src/api/activity.rs +++ b/src/api/activity.rs @@ -1,38 +1,41 @@ -use actix_web::{ - error::*, - web::{self, Data, Json}, - HttpResponse, Responder, -}; +use std::sync::Arc; + +use axum::{extract::State, Json}; use chrono::{Duration, Local}; use dashmap::DashMap; -use serde_derive::Deserialize; +use http::StatusCode; +use serde::{Deserialize, Serialize}; +use utoipa::ToSchema; use crate::{ - api::auth::SecuredUserIdentity, database::DatabaseWrapper, error::TimeError, models::UserId, - requests::*, + database::DatabaseWrapper, + error::TimeError, + models::{HeartBeat, UserId, UserIdentity}, }; pub type HeartBeatMemoryStore = DashMap; -#[derive(Deserialize)] -pub struct RenameRequest { - from: String, - to: String, +#[derive(Serialize, ToSchema)] +pub struct UpdateResponse { + duration: i64, } -#[derive(Deserialize)] -pub struct HideRequest { - target_project: String, - hidden: bool, -} - -#[post("/update")] +#[utoipa::path( + post, + path = "/activity/update", + security( + ("api_key" = []) + ), + responses( + (status = OK, body = UpdateResponse) + ) +)] pub async fn update( user: UserId, - heartbeat: Json, db: DatabaseWrapper, - heartbeats: Data, -) -> Result { + heartbeats: State>, + Json(heartbeat): Json, +) -> Result, TimeError> { if let Some(project) = &heartbeat.project_name { if project.len() > 64 { return Err(TimeError::InvalidLength( @@ -41,23 +44,23 @@ pub async fn update( } } if let Some(language) = &heartbeat.language { - if language.len() > 32 { + if language.len() > 64 { return Err(TimeError::InvalidLength( - "Language is over 32 chars".to_string(), + "Language is over 64 chars".to_string(), )); } } if let Some(editor) = &heartbeat.editor_name { - if editor.len() > 32 { + if editor.len() > 64 { return Err(TimeError::InvalidLength( - "Editor name is over 32 chars".to_string(), + "Editor name is over 64 chars".to_string(), )); } } if let Some(hostname) = &heartbeat.hostname { - if hostname.len() > 32 { + if hostname.len() > 64 { return Err(TimeError::InvalidLength( - "Hostname is over 32 chars".to_string(), + "Hostname is over 64 chars".to_string(), )); } } @@ -71,30 +74,25 @@ pub async fn update( if curtime.signed_duration_since(start + duration) > Duration::seconds(900) { // If the user sends a heartbeat but maximum activity duration has been exceeded, // end session and start new - db.add_activity(user.id, current_heartbeat, start, duration) - .await - .map_err(ErrorInternalServerError)?; + if duration > Duration::zero() { + db.add_activity(user.id, current_heartbeat, start, duration) + .await?; + } heartbeats.insert( user.id, - ( - heartbeat.into_inner(), - Local::now().naive_local(), - Duration::seconds(0), - ), + (heartbeat, Local::now().naive_local(), Duration::seconds(0)), ); - Ok(HttpResponse::Ok().body(0i32.to_string())) + Ok(Json(UpdateResponse { duration: 0 })) } else { // Extend current coding session if heartbeat matches and it has been under the maximum duration of a break heartbeats.insert( user.id, - ( - heartbeat.into_inner(), - start, - curtime.signed_duration_since(start), - ), + (heartbeat, start, curtime.signed_duration_since(start)), ); - Ok(HttpResponse::Ok().body(curtime.signed_duration_since(start).to_string())) + Ok(Json(UpdateResponse { + duration: curtime.signed_duration_since(start).num_seconds(), + })) } } else { // Flush current session and start new session if heartbeat changes @@ -102,91 +100,149 @@ pub async fn update( duration = curtime.signed_duration_since(start); } - db.add_activity(user.id, current_heartbeat, start, duration) - .await - .map_err(ErrorInternalServerError)?; + if duration > Duration::zero() { + db.add_activity(user.id, current_heartbeat, start, duration) + .await?; + } heartbeats.insert( user.id, - ( - heartbeat.into_inner(), - Local::now().naive_local(), - Duration::seconds(0), - ), + (heartbeat, Local::now().naive_local(), Duration::seconds(0)), ); - Ok(HttpResponse::Ok().body(0i32.to_string())) + + Ok(Json(UpdateResponse { duration: 0 })) } } None => { // If the user has not sent a heartbeat during this session heartbeats.insert( user.id, - ( - heartbeat.into_inner(), - Local::now().naive_local(), - Duration::seconds(0), - ), + (heartbeat, Local::now().naive_local(), Duration::seconds(0)), ); - Ok(HttpResponse::Ok().body(0.to_string())) + Ok(Json(UpdateResponse { duration: 0 })) } } } -#[post("/flush")] +#[utoipa::path( + post, + path = "/activity/flush", + security( + ("api_key" = []) + ), + responses( + (status = OK) + ) +)] pub async fn flush( user: UserId, db: DatabaseWrapper, - heartbeats: Data, -) -> Result { + heartbeats: State>, +) -> Result { if let Some(heartbeat) = heartbeats.get(&user.id) { let (inner_heartbeat, start, duration) = heartbeat.to_owned(); drop(heartbeat); heartbeats.remove(&user.id); - db.add_activity(user.id, inner_heartbeat, start, duration) - .await?; + if duration > Duration::zero() { + db.add_activity(user.id, inner_heartbeat, start, duration) + .await?; + } } - Ok(HttpResponse::Ok().finish()) + Ok(StatusCode::OK) +} + +#[derive(Deserialize, ToSchema)] +pub struct ActivityDeleteRequest { + id: i32, } -#[delete("/delete")] +#[utoipa::path( + delete, + path = "/activity/delete", + security( + ("api_key" = []) + ), + responses( + (status = OK) + ) +)] pub async fn delete( - user: SecuredUserIdentity, + user: UserIdentity, db: DatabaseWrapper, - body: String, -) -> Result { - let deleted = db - .delete_activity( - user.identity.id, - body.parse::().map_err(ErrorBadRequest)?, - ) - .await?; + Json(body): Json, +) -> Result { + let deleted = db.delete_activity(user.id, body.id).await?; if deleted { - Ok(HttpResponse::Ok().finish()) + Ok(StatusCode::OK) } else { Err(TimeError::BadId) } } -#[post("/rename")] +#[derive(Deserialize, ToSchema)] +pub struct ActivityRenameRequest { + from: String, + to: String, +} + +#[derive(Serialize, ToSchema)] +pub struct ActivityRenameResponse { + affected_activities: usize, +} + +#[utoipa::path( + post, + path = "/activity/rename", + security( + ("api_key" = []) + ), + responses( + (status = OK, body = ActivityRenameResponse) + ) +)] pub async fn rename_project( user: UserId, db: DatabaseWrapper, - body: Json, -) -> Result { + body: Json, +) -> Result, TimeError> { let renamed = db.rename_project(user.id, &body.from, &body.to).await?; - Ok(web::Json(json!({ "affected_activities": renamed }))) + Ok(Json(ActivityRenameResponse { + affected_activities: renamed, + })) +} + +#[derive(Deserialize, ToSchema)] +pub struct HideRequest { + target_project: String, + hidden: bool, +} + +#[derive(Serialize, ToSchema)] +pub struct HideResponse { + affected_activities: usize, } -#[post("/hide")] +#[utoipa::path( + post, + path = "/activity/hide", + security( + ("api_key" = []) + ), + responses( + (status = OK, body = HideResponse) + ) +)] pub async fn hide_project( user: UserId, db: DatabaseWrapper, body: Json, -) -> Result { +) -> Result, TimeError> { let renamed = db .set_project_hidden(user.id, &body.target_project, body.hidden) .await?; - Ok(web::Json(json!({ "affected_activities": renamed }))) + Ok(Json(HideResponse { + affected_activities: renamed, + })) } diff --git a/src/api/auth.rs b/src/api/auth.rs index eaa8a89..566ede9 100644 --- a/src/api/auth.rs +++ b/src/api/auth.rs @@ -1,70 +1,52 @@ -use std::{future::Future, pin::Pin}; +use std::sync::Arc; -use actix_web::{ - dev::{ConnectionInfo, Payload}, - error::*, - web::{Data, Json}, - FromRequest, HttpMessage, HttpRequest, HttpResponse, Responder, +use axum::{ + extract::{FromRequestParts, State}, + Json, }; +use chrono::{Duration, Local}; +use http::{request::Parts, StatusCode}; +use lettre::{ + message::header::ContentType, AsyncSmtpTransport, AsyncTransport, Message, Tokio1Executor, +}; +use serde::{Deserialize, Serialize}; +use utoipa::ToSchema; use crate::{ - auth::{secured_access::SecuredAccessTokenStorage, Authentication}, + api::users::UserAuthentication, + auth::Authentication, database::DatabaseWrapper, error::TimeError, - models::{SecuredAccessTokenResponse, SelfUser, UserId, UserIdentity}, - requests::*, - RegisterLimiter, + models::{NewUserIdentity, SelfUser, UserId, UserIdentity}, + utils::{generate_password_reset_token, validate_email}, + PasswordReset, PasswordResetState, }; -impl FromRequest for UserId { - type Error = TimeError; - type Future = Pin>>>; - - fn from_request(req: &HttpRequest, _payload: &mut Payload) -> Self::Future { - let auth = req.extensions().get::().cloned().unwrap(); - Box::pin(async move { - if let Authentication::AuthToken(user) = auth { - Ok(UserId { id: user.id }) - } else { - Err(TimeError::Unauthorized) - } - }) - } -} +impl FromRequestParts for UserId { + type Rejection = TimeError; -impl FromRequest for UserIdentity { - type Error = TimeError; - type Future = Pin>>>; + async fn from_request_parts(parts: &mut Parts, _: &S) -> Result { + let auth = parts.extensions.get::().cloned().unwrap(); - fn from_request(req: &HttpRequest, _payload: &mut Payload) -> Self::Future { - let auth = req.extensions().get::().cloned().unwrap(); - Box::pin(async move { - if let Authentication::AuthToken(user) = auth { - Ok(user) - } else { - Err(TimeError::Unauthorized) - } - }) + if let Authentication::AuthToken(user) = auth { + Ok(UserId { id: user.id }) + } else { + Err(TimeError::Unauthorized) + } } } -pub struct SecuredUserIdentity { - pub identity: UserIdentity, -} +impl FromRequestParts for UserIdentity { + type Rejection = TimeError; -impl FromRequest for SecuredUserIdentity { - type Error = TimeError; - type Future = Pin>>>; + async fn from_request_parts(parts: &mut Parts, _state: &S) -> Result { + let auth = parts.extensions.get::().cloned().unwrap(); - fn from_request(req: &HttpRequest, _payload: &mut Payload) -> Self::Future { - let auth = req.extensions().get::().cloned().unwrap(); - Box::pin(async move { - if let Authentication::SecuredAuthToken(user) = auth { - Ok(SecuredUserIdentity { identity: user }) - } else { - Err(TimeError::UnauthroizedSecuredAccess) - } - }) + if let Authentication::AuthToken(user) = auth { + Ok(user) + } else { + Err(TimeError::Unauthorized) + } } } @@ -72,171 +54,326 @@ pub struct UserIdentityOptional { pub identity: Option, } -impl FromRequest for UserIdentityOptional { - type Error = TimeError; - type Future = Pin>>>; +impl FromRequestParts for UserIdentityOptional +where + S: Send + Sync, +{ + type Rejection = TimeError; + + async fn from_request_parts(parts: &mut Parts, _: &S) -> Result { + let auth = parts.extensions.get::().cloned().unwrap(); - fn from_request(req: &HttpRequest, _payload: &mut Payload) -> Self::Future { - let auth = req.extensions().get::().cloned().unwrap(); - Box::pin(async move { - if let Authentication::AuthToken(user) = auth { - Ok(UserIdentityOptional { - identity: Some(user), - }) - } else { - Ok(UserIdentityOptional { identity: None }) - } - }) + if let Authentication::AuthToken(user) = auth { + Ok(UserIdentityOptional { + identity: Some(user), + }) + } else { + Ok(UserIdentityOptional { identity: None }) + } } } -#[post("/auth/login")] -pub async fn login( - data: Json, - db: DatabaseWrapper, -) -> Result { - if data.password.len() > 128 { - return Err(TimeError::InvalidLength( - "Password cannot be longer than 128 characters".to_string(), - )); - } - match db - .verify_user_password(&data.username, &data.password) - .await - { - Ok(Some(user)) => Ok(Json(SelfUser::from(user))), - _ => Err(TimeError::InvalidCredentials), - } +#[derive(Deserialize, Debug, ToSchema)] +pub struct LoginRequest { + pub username: String, + pub password: String, } -#[post("/auth/securedaccess")] -pub async fn get_secured_access_token( - data: Json, - secured_access_storage: Data, +#[utoipa::path( + post, + path = "/auth/login", + responses( + (status = OK, body = SelfUser), + ) +)] +pub async fn login( db: DatabaseWrapper, -) -> Result { + data: Json, +) -> Result, TimeError> { if data.password.len() > 128 { return Err(TimeError::InvalidLength( "Password cannot be longer than 128 characters".to_string(), )); } - match db .verify_user_password(&data.username, &data.password) .await { - Ok(Some(user)) => Ok(Json(SecuredAccessTokenResponse { - token: secured_access_storage.create_token(user.id), - })), + Ok(Some(user)) => Ok(Json(SelfUser::from(user))), _ => Err(TimeError::InvalidCredentials), } } -#[post("/auth/regenerate")] -pub async fn regenerate( - user: SecuredUserIdentity, - db: DatabaseWrapper, -) -> Result { - db.regenerate_token(user.identity.id) - .await - .inspect_err(|e| error!("{}", e)) - .map(|token| { - let token = json!({ "token": token }); - Json(token) - }) +#[derive(Deserialize, Debug, ToSchema)] +pub struct RegisterRequest { + pub username: String, + pub email: Option, + pub password: String, } -#[post("/auth/register")] +#[utoipa::path( + post, + path = "/auth/register", + responses( + (status = OK, body = NewUserIdentity) + ) +)] pub async fn register( - conn_info: ConnectionInfo, - data: Json, db: DatabaseWrapper, - rls: Data, -) -> Result { + Json(data): Json, +) -> Result, TimeError> { if data.password.len() < 8 || data.password.len() > 128 { return Err(TimeError::InvalidLength( "Password has to be between 8 and 128 characters long".to_string(), )); } - if !super::REGEX.with(|r| r.is_match(&data.username)) { + if !super::VALID_NAME_REGEX.is_match(&data.username) { return Err(TimeError::BadUsername); } - if db.get_user_by_name(&data.username).await.is_ok() { - return Err(TimeError::UserExists); + if data.email.as_ref().is_some_and(|e| validate_email(e)) { + return Err(TimeError::InvalidEmail); } - let ip = if rls.limit_by_peer_ip { - conn_info.peer_addr().ok_or(TimeError::UnknownError)? - } else { - conn_info - .realip_remote_addr() - .ok_or(TimeError::UnknownError)? - }; - - if let Some(res) = rls.storage.get(ip) { - if chrono::Local::now() - .naive_local() - .signed_duration_since(*res) - < chrono::Duration::days(1) - { - return Err(TimeError::TooManyRegisters); - } + let username = data.username.clone(); + if db.get_user_by_name(&username).await.is_ok() { + return Err(TimeError::UsernameTaken); } let res = db - .new_testaustime_user(&data.username, &data.password) + .new_testaustime_user(&data.username, &data.password, data.email.as_deref()) .await?; - rls.storage - .insert(ip.to_string(), chrono::Local::now().naive_local()); - Ok(Json(res)) } -#[post("/auth/changeusername")] -pub async fn changeusername( - user: SecuredUserIdentity, - data: Json, +#[derive(Serialize, ToSchema)] +pub struct RegenerateResponse { + pub token: String, +} + +#[utoipa::path( + post, + path = "/auth/regenerate", + responses( + (status = OK, body = RegenerateResponse) + ) +)] +pub async fn regenerate_auth_token( + db: DatabaseWrapper, + Json(credentials): Json, +) -> Result, TimeError> { + if let Some(user) = db + .verify_user_password(&credentials.username, &credentials.password) + .await? + { + db.regenerate_token(user.id) + .await + .inspect_err(|e| error!("{}", e)) + .map(|token| Json(RegenerateResponse { token })) + } else { + Err(TimeError::Unauthorized) + } +} + +#[derive(Deserialize, ToSchema)] +pub struct UsernameChangeRequest { + pub new: String, +} + +#[utoipa::path( + post, + path = "/auth/change-username", + security( + ("api_key" = []) + ), + responses( + (status = OK) + ) +)] +pub async fn change_username( + user: UserIdentity, db: DatabaseWrapper, -) -> Result { + Json(data): Json, +) -> Result { if data.new.len() < 2 || data.new.len() > 32 { return Err(TimeError::InvalidLength( "Username is not between 2 and 32 chars".to_string(), )); } - if !super::REGEX.with(|r| r.is_match(&data.new)) { + + if !super::VALID_NAME_REGEX.is_match(&data.new) { return Err(TimeError::BadUsername); } - if db.get_user_by_name(&data.new).await.is_ok() { - return Err(TimeError::UserExists); + let result = db.change_username(user.id, &data.new).await; + + if result.as_ref().is_err_and(|e| e.is_unique_violation()) { + return Err(TimeError::UsernameTaken); } - let user = db.get_user_by_id(user.identity.id).await?; - db.change_username(user.id, &data.new).await?; - Ok(HttpResponse::Ok().finish()) + result.map(|_| StatusCode::OK) } -#[post("/auth/changepassword")] -pub async fn changepassword( +#[derive(Deserialize, ToSchema)] +pub struct EmailChangeRequest { + pub new: String, +} + +#[utoipa::path( + post, + path = "/auth/change-email", + security( + ("api_key" = []) + ), + responses( + (status = OK) + ) +)] +pub async fn change_email( user: UserIdentity, - data: Json, db: DatabaseWrapper, -) -> Result { - if data.new.len() < 8 || data.new.len() > 128 { + Json(data): Json, +) -> Result { + if !validate_email(&data.new) { + return Err(TimeError::InvalidEmail); + } + + let result = db.change_email(user.id, data.new).await; + + if result.as_ref().is_err_and(|e| e.is_unique_violation()) { + return Err(TimeError::EmailTaken); + } + + result.map(|_| StatusCode::OK) +} + +#[derive(Deserialize, ToSchema)] +pub struct PasswordChangeRequest { + pub old: String, + pub new: String, +} + +#[utoipa::path( + post, + path = "/auth/change-password", + security( + ("api_key" = []) + ), + responses( + (status = OK) + ) +)] +pub async fn change_password( + user: UserIdentity, + db: DatabaseWrapper, + Json(body): Json, +) -> Result { + if body.new.len() < 8 || body.new.len() > 128 { return Err(TimeError::InvalidLength( "Password has to be between 8 and 128 characters long".to_string(), )); } - let old = data.old.to_owned(); - let tuser = db.get_testaustime_user_by_id(user.id).await?; - let k = db.verify_user_password(&user.username, &old).await?; - if k.is_some() || tuser.password.iter().all(|n| *n == 0) { - db.change_password(user.id, &data.new) - .await - .map(|_| HttpResponse::Ok().finish()) + + let testaustime_user = db.get_testaustime_user_by_id(user.id).await?; + let k = db.verify_user_password(&user.username, &body.old).await?; + + if k.is_some() || testaustime_user.password.iter().all(|n| *n == 0) { + db.change_password(user.id, &body.new).await?; + Ok(StatusCode::OK) } else { Err(TimeError::Unauthorized) } } + +#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] +pub struct PasswordResetRequest { + pub email: String, +} + +#[utoipa::path( + post, + path = "/auth/reset-password", + responses( + (status = OK) + ) +)] +pub async fn request_password_reset( + db: DatabaseWrapper, + State(password_resets): State>, + State(relay): State>, + Json(body): Json, +) -> Result { + let Some(user) = db.get_user_by_email(&body.email).await? else { + return Ok(StatusCode::OK); + }; + + let Some(ref email) = user.email else { + return Ok(StatusCode::OK); + }; + + let token = generate_password_reset_token(); + + let message = Message::builder() + .from("Testaustime ".parse().unwrap()) + .to(format!("{} <{}>", user.username, email).parse().map_err(|_| TimeError::InvalidEmail)?) + .subject("Testaustime password reset") + .header(ContentType::TEXT_PLAIN) + .body(format!("Here is your testaustime password reset link: https://testaustime.fi/reset_password?token={token}")).unwrap(); + + tokio::spawn(async move { + if let Err(err) = relay.send(message).await { + error!("{}", err); + }; + }); + + debug!("Sent password reset of user {} to {}", user.username, email); + + password_resets.storage.insert( + token, + PasswordReset { + expires: Local::now().naive_local() + Duration::minutes(30), + user, + }, + ); + + Ok(StatusCode::OK) +} + +#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] +pub struct PasswordResetCompletionRequest { + password: String, + token: String, +} + +#[utoipa::path( + post, + path = "/auth/complete-password-reset", + responses( + (status = OK) + ) +)] +pub async fn reset_password( + db: DatabaseWrapper, + State(password_resets): State>, + Json(body): Json, +) -> Result { + let Some(reset) = password_resets.storage.get(&body.token) else { + return Err(TimeError::InvalidPasswordResetToken); + }; + + if reset.expires > Local::now().naive_local() { + db.change_password(reset.user.id, &body.password).await?; + debug!("Changed password for user {}", reset.user.username); + + drop(reset); + password_resets.storage.remove(&body.token); + + Ok(StatusCode::OK) + } else { + drop(reset); + password_resets.storage.remove(&body.token); + + Err(TimeError::ExpiredPasswordResetToken) + } +} diff --git a/src/api/friends.rs b/src/api/friends.rs index b5f888b..27c482b 100644 --- a/src/api/friends.rs +++ b/src/api/friends.rs @@ -1,26 +1,41 @@ -use actix_web::{ - error::*, - web::{self, Data}, - HttpResponse, Responder, -}; +use std::sync::Arc; + +use axum::{extract::State, Json}; use diesel::result::DatabaseErrorKind; +use http::StatusCode; +use serde::{Deserialize, Serialize}; +use utoipa::ToSchema; use crate::{ - api::{activity::HeartBeatMemoryStore, auth::SecuredUserIdentity}, + api::activity::HeartBeatMemoryStore, database::DatabaseWrapper, error::TimeError, - models::{CurrentActivity, FriendWithTimeAndStatus, UserId}, + models::{CurrentActivity, FriendWithTimeAndStatus, UserId, UserIdentity}, }; -#[post("/friends/add")] +#[derive(Deserialize, Debug, ToSchema)] +pub struct FriendRequest { + pub code: String, +} + +#[utoipa::path( + post, + path = "/friends/add", + security( + ("api_key" = []) + ), + responses( + (status = OK, body = FriendWithTimeAndStatus) + ) +)] pub async fn add_friend( user: UserId, - body: String, db: DatabaseWrapper, - heartbeats: Data, -) -> Result { + State(heartbeats): State>, + Json(body): Json, +) -> Result, TimeError> { match db - .add_friend(user.id, body.trim().trim_start_matches("ttfc_").to_string()) + .add_friend(user.id, body.code.trim_start_matches("ttfc_").to_string()) .await { // This is not correct @@ -52,17 +67,26 @@ pub async fn add_friend( }), }; - Ok(web::Json(friend_with_time)) + Ok(Json(friend_with_time)) } } } -#[get("/friends/list")] +#[utoipa::path( + get, + path = "/friends/list", + security( + ("api_key" = []) + ), + responses( + (status = OK, body = Vec) + ) +)] pub async fn get_friends( user: UserId, db: DatabaseWrapper, - heartbeats: Data, -) -> Result { + State(heartbeats): State>, +) -> Result>, TimeError> { let friends = db .get_friends_with_time(user.id) .await @@ -86,31 +110,59 @@ pub async fn get_friends( }) .collect::>(); - Ok(web::Json(friends)) + Ok(Json(friends)) } -#[post("/friends/regenerate")] +#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] +pub struct RegenerateFriendCodeResponse { + friend_code: String, +} + +#[utoipa::path( + post, + path = "/friends/regenerate", + security( + ("api_key" = []) + ), + responses( + (status = OK, body = RegenerateFriendCodeResponse) + ) +)] pub async fn regenerate_friend_code( - user: SecuredUserIdentity, + user: UserIdentity, db: DatabaseWrapper, -) -> Result { - db.regenerate_friend_code(user.identity.id) +) -> Result, TimeError> { + db.regenerate_friend_code(user.id) .await .inspect_err(|e| error!("{}", e)) - .map(|code| web::Json(json!({ "friend_code": code }))) + .map(|c| Json(RegenerateFriendCodeResponse { friend_code: c })) +} + +#[derive(Debug, Clone, Deserialize, ToSchema)] +pub struct RemoveFriendRequest { + name: String, } -#[delete("/friends/remove")] +#[utoipa::path( + delete, + path = "/friends/remove", + security( + ("api_key" = []) + ), + responses( + (status = OK) + ) +)] pub async fn remove( - user: SecuredUserIdentity, + user: UserIdentity, db: DatabaseWrapper, - body: String, -) -> Result { - let friend = db.get_user_by_name(&body).await?; - let deleted = db.remove_friend(user.identity.id, friend.id).await?; + Json(body): Json, +) -> Result { + let friend = db.get_user_by_name(&body.name).await?; + let deleted = db.remove_friend(user.id, friend.id).await?; if deleted { - Ok(HttpResponse::Ok().finish()) + Ok(StatusCode::OK) } else { Err(TimeError::BadId) } diff --git a/src/api/leaderboards.rs b/src/api/leaderboards.rs index 39d03f3..31ad4ba 100644 --- a/src/api/leaderboards.rs +++ b/src/api/leaderboards.rs @@ -1,37 +1,48 @@ -use actix_web::{ - error::*, - web::{self, Json, Path}, - HttpResponse, Responder, -}; -use diesel::result::DatabaseErrorKind; +use axum::{extract::Path, Json}; +use diesel::result::{DatabaseErrorKind, Error as DieselError}; +use http::StatusCode; use serde::{Deserialize, Serialize}; +use utoipa::ToSchema; use crate::{ - api::auth::SecuredUserIdentity, database::DatabaseWrapper, error::TimeError, models::UserId, + database::DatabaseWrapper, + error::TimeError, + models::{PrivateLeaderboard, UserId, UserIdentity}, }; -#[derive(Deserialize, Serialize)] -pub struct LeaderboardName { - pub name: String, -} +use super::users::MinimalLeaderboard; -#[derive(Deserialize, Serialize)] -pub struct LeaderboardInvite { - pub invite: String, +#[derive(Deserialize, Serialize, ToSchema)] +pub struct LeaderboardCreateRequest { + pub name: String, } -#[derive(Deserialize)] +#[derive(Deserialize, ToSchema)] pub struct LeaderboardUser { pub user: String, } -#[post("/leaderboards/create")] +#[derive(Serialize, ToSchema)] +pub struct LeaderboardCreateResponse { + invite_code: String, +} + +#[utoipa::path( + post, + path = "/leaderboards/create", + security( + ("api_key" = []) + ), + responses( + (status = OK, body = LeaderboardCreateResponse) + ) +)] pub async fn create_leaderboard( creator: UserId, - body: Json, db: DatabaseWrapper, -) -> Result { - if !super::REGEX.with(|r| r.is_match(&body.name)) { + body: Json, +) -> Result, TimeError> { + if !super::VALID_NAME_REGEX.is_match(&body.name) { return Err(TimeError::BadLeaderboardName); } @@ -40,11 +51,11 @@ pub async fn create_leaderboard( } match db.create_leaderboard(creator.id, &body.name).await { - Ok(code) => Ok(web::Json(json!({ "invite_code": code }))), + Ok(code) => Ok(Json(LeaderboardCreateResponse { invite_code: code })), Err(e) => { error!("{}", e); Err(match e { - TimeError::DieselError(diesel::result::Error::DatabaseError( + TimeError::DieselError(DieselError::DatabaseError( DatabaseErrorKind::UniqueViolation, .., )) => TimeError::LeaderboardExists, @@ -54,50 +65,88 @@ pub async fn create_leaderboard( } } -#[get("/leaderboards/{name}")] +#[utoipa::path( + get, + path = "/leaderboards/{name}", + params( + ("name", description = "Leaderboard name") + ), + security( + ("api_key" = []) + ), + responses( + (status = OK, body = PrivateLeaderboard) + ) +)] pub async fn get_leaderboard( user: UserId, - path: Path<(String,)>, + Path(name): Path, db: DatabaseWrapper, -) -> Result { +) -> Result, TimeError> { let lid = db - .get_leaderboard_id_by_name(&path.0) + .get_leaderboard_id_by_name(&name) .await .map_err(|_| TimeError::LeaderboardNotFound)?; if db.is_leaderboard_member(user.id, lid).await? { - let board = db.get_leaderboard(&path.0).await?; - Ok(web::Json(board)) + let board = db.get_leaderboard(&name).await?; + Ok(Json(board)) } else { Err(TimeError::Unauthorized) } } -#[delete("/leaderboards/{name}")] +#[utoipa::path( + delete, + path = "/leaderboards/{name}", + params( + ("name", description = "Leaderboard name") + ), + security( + ("api_key" = []) + ), + responses( + (status = OK) + ) +)] pub async fn delete_leaderboard( - user: SecuredUserIdentity, - path: Path<(String,)>, + user: UserIdentity, + Path(name): Path, db: DatabaseWrapper, -) -> Result { +) -> Result { let lid = db - .get_leaderboard_id_by_name(&path.0) + .get_leaderboard_id_by_name(&name) .await .map_err(|_| TimeError::LeaderboardNotFound)?; - if db.is_leaderboard_admin(user.identity.id, lid).await? { - db.delete_leaderboard(&path.0).await?; - Ok(HttpResponse::Ok().finish()) + if db.is_leaderboard_admin(user.id, lid).await? { + db.delete_leaderboard(&name).await?; + Ok(StatusCode::OK) } else { Err(TimeError::Unauthorized) } } -#[post("/leaderboards/join")] +#[derive(Deserialize, Serialize, ToSchema)] +pub struct LeaderboardInvite { + pub invite: String, +} + +#[utoipa::path( + post, + path = "/leaderboards/join", + security( + ("api_key" = []) + ), + responses( + (status = OK, body = MinimalLeaderboard) + ) +)] pub async fn join_leaderboard( user: UserId, - body: Json, db: DatabaseWrapper, -) -> Result { + body: Json, +) -> Result, TimeError> { match db .add_user_to_leaderboard(user.id, body.invite.trim().trim_start_matches("ttlic_")) .await @@ -105,60 +154,79 @@ pub async fn join_leaderboard( Err(e) => { error!("{}", e); Err(match e { - TimeError::DieselError(diesel::result::Error::DatabaseError( + TimeError::DieselError(DieselError::DatabaseError( DatabaseErrorKind::UniqueViolation, .., )) => TimeError::AlreadyMember, - TimeError::DieselError(diesel::result::Error::NotFound) => { - TimeError::LeaderboardNotFound - } + TimeError::DieselError(DieselError::NotFound) => TimeError::LeaderboardNotFound, _ => e, }) } - Ok(leaderboard) => Ok(web::Json(json!(leaderboard))), + Ok(leaderboard) => Ok(Json(leaderboard)), } } -#[post("/leaderboards/{name}/leave")] +#[utoipa::path( + post, + path = "/leaderboards/{name}/leave", + params( + ("name", description = "Leaderboard name") + ), + security( + ("api_key" = []), + ), + responses( + (status = OK) + ) +)] pub async fn leave_leaderboard( - user: SecuredUserIdentity, - path: Path<(String,)>, + user: UserIdentity, + Path(name): Path, db: DatabaseWrapper, -) -> Result { +) -> Result { let lid = db - .get_leaderboard_id_by_name(&path.0) + .get_leaderboard_id_by_name(&name) .await .map_err(|_| TimeError::LeaderboardNotFound)?; - if db.is_leaderboard_admin(user.identity.id, lid).await? + if db.is_leaderboard_admin(user.id, lid).await? && db.get_leaderboard_admin_count(lid).await? == 1 { return Err(TimeError::LastAdmin); } - if db - .remove_user_from_leaderboard(lid, user.identity.id) - .await? - { - Ok(HttpResponse::Ok().finish()) + if db.remove_user_from_leaderboard(lid, user.id).await? { + Ok(StatusCode::OK) } else { Err(TimeError::NotMember) } } -#[post("/leaderboards/{name}/promote")] +#[utoipa::path( + post, + path = "/leaderboards/{name}/promote", + params( + ("name", description = "Leaderboard name") + ), + security( + ("api_key" = []) + ), + responses( + (status = OK) + ) +)] pub async fn promote_member( - user: SecuredUserIdentity, - path: Path<(String,)>, + user: UserIdentity, + Path(name): Path, db: DatabaseWrapper, promotion: Json, -) -> Result { +) -> Result { let lid = db - .get_leaderboard_id_by_name(&path.0) + .get_leaderboard_id_by_name(&name) .await .map_err(|_| TimeError::LeaderboardNotFound)?; - if db.is_leaderboard_admin(user.identity.id, lid).await? { + if db.is_leaderboard_admin(user.id, lid).await? { let newadmin = db .get_user_by_name(&promotion.user) .await @@ -168,7 +236,7 @@ pub async fn promote_member( .promote_user_to_leaderboard_admin(lid, newadmin.id) .await? { - Ok(HttpResponse::Ok().finish()) + Ok(StatusCode::OK) } else { // FIXME: This is not correct Err(TimeError::NotMember) @@ -178,19 +246,31 @@ pub async fn promote_member( } } -#[post("/leaderboards/{name}/demote")] +#[utoipa::path( + post, + path = "/leaderboards/{name}/demote", + params( + ("name", description = "Leaderboard name") + ), + security( + ("api_key" = []) + ), + responses( + (status = OK) + ) +)] pub async fn demote_member( - user: SecuredUserIdentity, - path: Path<(String,)>, + user: UserIdentity, + Path(name): Path, db: DatabaseWrapper, demotion: Json, -) -> Result { +) -> Result { let lid = db - .get_leaderboard_id_by_name(&path.0) + .get_leaderboard_id_by_name(&name) .await .map_err(|_| TimeError::LeaderboardNotFound)?; - if db.is_leaderboard_admin(user.identity.id, lid).await? { + if db.is_leaderboard_admin(user.id, lid).await? { let oldadmin = db .get_user_by_name(&demotion.user) .await @@ -200,7 +280,7 @@ pub async fn demote_member( .demote_user_to_leaderboard_member(lid, oldadmin.id) .await? { - Ok(HttpResponse::Ok().finish()) + Ok(StatusCode::OK) } else { // FIXME: This is not correct Err(TimeError::NotMember) @@ -210,19 +290,31 @@ pub async fn demote_member( } } -#[post("/leaderboards/{name}/kick")] +#[utoipa::path( + post, + path = "/leaderboards/{name}/kick", + params( + ("name", description = "Leaderboard name") + ), + security( + ("api_key" = []) + ), + responses( + (status = OK) + ) +)] pub async fn kick_member( - user: SecuredUserIdentity, - path: Path<(String,)>, + user: UserIdentity, + Path(name): Path, db: DatabaseWrapper, kick: Json, -) -> Result { +) -> Result { let lid = db - .get_leaderboard_id_by_name(&path.0) + .get_leaderboard_id_by_name(&name) .await .map_err(|_| TimeError::LeaderboardNotFound)?; - if db.is_leaderboard_admin(user.identity.id, lid).await? { + if db.is_leaderboard_admin(user.id, lid).await? { let kmember = db .get_user_by_name(&kick.user) .await @@ -231,26 +323,43 @@ pub async fn kick_member( db.remove_user_from_leaderboard(lid, kmember.id) .await .map_err(|_| TimeError::NotMember)?; - Ok(HttpResponse::Ok().finish()) + Ok(StatusCode::OK) } else { Err(TimeError::Unauthorized) } } -#[post("/leaderboards/{name}/regenerate")] +#[derive(Debug, Clone, Serialize, ToSchema)] +pub struct InviteCodeRegenerateResponse { + invite_code: String, +} + +#[utoipa::path( + post, + path = "/leaderboards/{name}/regenerate", + params( + ("name", description = "Leaderboard name") + ), + security( + ("api_key" = []) + ), + responses( + (status = OK, body = InviteCodeRegenerateResponse) + ) +)] pub async fn regenerate_invite( - user: SecuredUserIdentity, - path: Path<(String,)>, + user: UserIdentity, + Path(name): Path, db: DatabaseWrapper, -) -> Result { +) -> Result, TimeError> { let lid = db - .get_leaderboard_id_by_name(&path.0) + .get_leaderboard_id_by_name(&name) .await .map_err(|_| TimeError::LeaderboardNotFound)?; - if db.is_leaderboard_admin(user.identity.id, lid).await? { + if db.is_leaderboard_admin(user.id, lid).await? { let code = db.regenerate_leaderboard_invite(lid).await?; - Ok(web::Json(json!({ "invite_code": code }))) + Ok(Json(InviteCodeRegenerateResponse { invite_code: code })) } else { Err(TimeError::Unauthorized) } diff --git a/src/api/mod.rs b/src/api/mod.rs index afd13ed..8c9c3c2 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -1,4 +1,6 @@ -use actix_web::{HttpResponse, Responder}; +use std::sync::LazyLock; + +use http::StatusCode; use regex::Regex; pub mod account; @@ -12,11 +14,17 @@ pub mod search; pub mod stats; pub mod users; -thread_local! { - pub static REGEX: Regex = Regex::new("^[[:word:]]{2,32}$").unwrap(); -} +pub static VALID_NAME_REGEX: LazyLock = + LazyLock::new(|| Regex::new("^[[:word:]]{2,32}$").unwrap()); -#[get("/health")] -async fn health() -> impl Responder { - HttpResponse::Ok() +#[utoipa::path( + get, + path = "/health", + responses( + (status = OK) + ), + description = "Is the api healthy" +)] +pub async fn health() -> StatusCode { + StatusCode::OK } diff --git a/src/api/oauth.rs b/src/api/oauth.rs index d9d9a90..882c592 100644 --- a/src/api/oauth.rs +++ b/src/api/oauth.rs @@ -1,18 +1,14 @@ -use std::collections::HashMap; +use std::{collections::HashMap, sync::LazyLock}; -use actix_web::{ - cookie::Cookie, - error::*, - web::{Data, Query}, - HttpResponse, Responder, -}; -use awc::Client; +use axum::{extract::Query, response::Redirect}; +use axum_extra::extract::{cookie::Cookie, CookieJar}; +use reqwest::Client; use serde_derive::Deserialize; use crate::{database::DatabaseWrapper, error::TimeError}; #[derive(Deserialize)] -struct TokenExchangeRequest { +pub struct TokenExchangeRequest { code: String, } @@ -43,26 +39,40 @@ struct TestausIdPlatformInfo { id: String, } -#[get("/auth/callback")] -async fn callback( - request: Query, - client: Data, - oauth_client: Data, +static CLIENT_INFO: LazyLock = LazyLock::new(|| { + toml::from_str(&std::fs::read_to_string("settings.toml").expect("Missing settings.toml")) + .expect("Invalid Toml in settings.toml") +}); + +#[utoipa::path( + get, + path = "/auth/callback", + responses( + (status = OK) + ) +)] +pub async fn callback( db: DatabaseWrapper, -) -> Result { + jar: CookieJar, + request: Query, +) -> Result<(CookieJar, Redirect), TimeError> { if request.code.chars().any(|c| !c.is_alphanumeric()) { return Err(TimeError::BadCode); } + // Maybe store in state? + let client = Client::new(); + let res = client .post("http://id.testausserveri.fi/api/v1/token") - .insert_header(("content-type", "application/x-www-form-urlencoded")) - .send_form(&HashMap::from([ + .header("content-type", "application/x-www-form-urlencoded") + .form(&HashMap::from([ ("code", &request.code), - ("redirect_uri", &oauth_client.redirect_uri), - ("client_id", &oauth_client.id), - ("client_secret", &oauth_client.secret), + ("redirect_uri", &CLIENT_INFO.redirect_uri), + ("client_id", &CLIENT_INFO.id), + ("client_secret", &CLIENT_INFO.secret), ])) + .send() .await .unwrap() .json::() @@ -71,7 +81,7 @@ async fn callback( let res = client .get("http://id.testausserveri.fi/api/v1/me") - .insert_header(("Authorization", format!("Bearer {}", res.token))) + .header("Authorization", format!("Bearer {}", res.token)) .send() .await .unwrap() @@ -83,14 +93,13 @@ async fn callback( .testausid_login(res.id, res.name, res.platform.id) .await?; - Ok(HttpResponse::PermanentRedirect() - .insert_header(("location", "https://testaustime.fi/oauth_redirect")) - .cookie( - Cookie::build("testaustime_token", token) + Ok(( + jar.add( + Cookie::build(("testaustime_token", token)) .domain("testaustime.fi") .path("/") - .secure(true) - .finish(), - ) - .finish()) + .secure(true), + ), + Redirect::permanent("https://testaustime.fi/oauth_redirect"), + )) } diff --git a/src/api/search.rs b/src/api/search.rs index 6ebd7f8..8d55e21 100644 --- a/src/api/search.rs +++ b/src/api/search.rs @@ -1,21 +1,28 @@ -use actix_web::{ - web::{Json, Query}, - Responder, -}; +use axum::{extract::Query, Json}; use serde_derive::Deserialize; +use utoipa::IntoParams; -use crate::{database::DatabaseWrapper, error::TimeError}; +use crate::{database::DatabaseWrapper, error::TimeError, models::PublicUser}; -#[derive(Deserialize)] +#[derive(Deserialize, IntoParams)] pub struct UserSearch { pub keyword: String, } //TODO: Maybe return small coding summary? -#[get("/search/users")] +#[utoipa::path( + get, + path = "/search/users", + params( + UserSearch + ), + responses( + (status = OK, body = Vec) + ) +)] pub async fn search_public_users( db: DatabaseWrapper, search: Query, -) -> Result { +) -> Result>, TimeError> { Ok(Json(db.search_public_users(search.keyword.clone()).await?)) } diff --git a/src/api/stats.rs b/src/api/stats.rs index 5f81b5c..a9de6e2 100644 --- a/src/api/stats.rs +++ b/src/api/stats.rs @@ -1,20 +1,27 @@ -use actix_web::{web, Responder}; +use axum::Json; use serde_derive::Serialize; +use utoipa::ToSchema; use crate::{database::DatabaseWrapper, error::TimeError}; -#[derive(Serialize)] -struct Stats { +#[derive(Serialize, ToSchema)] +pub struct Stats { pub user_count: u64, pub coding_time: u64, } -#[get("/stats")] -async fn stats(db: DatabaseWrapper) -> Result { +#[utoipa::path( + get, + path = "/stats", + responses( + (status = OK, body = Stats) + ) +)] +pub async fn stats(db: DatabaseWrapper) -> Result, TimeError> { let user_count = db.get_total_user_count().await?; let coding_time = db.get_total_coding_time().await?; - Ok(web::Json(Stats { + Ok(Json(Stats { user_count, coding_time, })) diff --git a/src/api/users.rs b/src/api/users.rs index 5ee5e03..f0d09e7 100644 --- a/src/api/users.rs +++ b/src/api/users.rs @@ -1,32 +1,53 @@ -use actix_web::{ - error::*, - web::{self, Data, Path, Query}, - HttpResponse, Responder, +use std::{collections::HashMap, sync::Arc}; + +use axum::{ + extract::{Path, Query, State}, + Json, }; -use chrono::{Duration, Local}; +use chrono::{serde::ts_seconds_option, DateTime, Duration, Local, Utc}; +use http::StatusCode; +use serde::Serialize; use serde_derive::Deserialize; +use utoipa::ToSchema; use crate::{ api::{activity::HeartBeatMemoryStore, auth::UserIdentityOptional}, database::DatabaseWrapper, error::TimeError, - models::{CurrentActivity, PrivateLeaderboardMember, UserId, UserIdentity}, - requests::DataRequest, + models::{CodingActivity, CurrentActivity, PrivateLeaderboardMember, UserId, UserIdentity}, utils::group_by_language, }; -#[derive(Deserialize)] -pub struct UserAuthentication { - pub username: String, - pub password: String, +#[derive(Deserialize, Debug)] +pub struct DataRequest { + #[serde(default)] + #[serde(with = "ts_seconds_option")] + pub from: Option>, + #[serde(default)] + #[serde(with = "ts_seconds_option")] + pub to: Option>, + pub min_duration: Option, + pub editor_name: Option, + pub language: Option, + pub hostname: Option, + pub project_name: Option, } -#[get("/users/@me")] -pub async fn my_profile(user: UserIdentity) -> Result { - Ok(web::Json(user)) +#[utoipa::path( + get, + path = "/users/@me", + security( + ("api_key" = []) + ), + responses( + (status = OK, body = UserIdentity) + ) +)] +pub async fn my_profile(user: UserIdentity) -> Result, TimeError> { + Ok(Json(user)) } -#[derive(serde::Serialize)] +#[derive(Serialize, ToSchema)] pub struct ListLeaderboard { pub name: String, pub member_count: i32, @@ -35,51 +56,87 @@ pub struct ListLeaderboard { pub me: PrivateLeaderboardMember, } -#[derive(serde::Serialize)] +#[derive(Serialize, ToSchema)] pub struct MinimalLeaderboard { pub name: String, pub member_count: i32, } -#[get("/users/@me/leaderboards")] +#[utoipa::path( + get, + path = "/users/@me/leaderboards", + security( + ("api_key" = []) + ), + responses( + (status = OK, body = Vec) + ) +)] pub async fn my_leaderboards( user: UserId, db: DatabaseWrapper, -) -> Result { - Ok(web::Json(db.get_user_leaderboards(user.id).await?)) +) -> Result>, TimeError> { + Ok(Json(db.get_user_leaderboards(user.id).await?)) +} + +#[derive(Deserialize, ToSchema)] +pub struct UserAuthentication { + pub username: String, + pub password: String, } -#[delete("/users/@me/delete")] +#[utoipa::path( + delete, + path = "/users/@me/delete", + security( + ("api_key" = []) + ), + responses( + (status = OK) + ) +)] pub async fn delete_user( db: DatabaseWrapper, - user: web::Json, -) -> Result { + user: Json, +) -> Result { if let Some(user) = db .verify_user_password(&user.username, &user.password) .await? { db.delete_user(user.id).await?; + Ok(StatusCode::OK) + } else { + Err(TimeError::Unauthorized) } - - Ok(HttpResponse::Ok().finish()) } -#[get("/users/{username}/activity/current")] +#[utoipa::path( + get, + path = "/users/{username}/activity/current", + params( + ("username", description = "User name"), + ), + security( + ("api_key" = []) + ), + responses( + (status = OK, body = Option) + ) +)] pub async fn get_current_activity( - path: Path<(String,)>, + Path(name): Path, opt_user: UserIdentityOptional, db: DatabaseWrapper, - heartbeats: Data, -) -> Result { - let mut is_self: bool = false; - let target_user = if let Some(user) = opt_user.identity { - if path.0 == "@me" { - is_self = true; + State(heartbeats): State>, +) -> Result>, TimeError> { + let mut is_self = false; + let target_user = if let Some(user) = opt_user.identity { + if name == "@me" { user.id } else { let target_user = db - .get_user_by_name(&path.0) + .get_user_by_name(&name) .await .map_err(|_| TimeError::UserNotFound)?; @@ -95,7 +152,7 @@ pub async fn get_current_activity( } } else { let target_user = db - .get_user_by_name(&path.0) + .get_user_by_name(&name) .await .map_err(|_| TimeError::UserNotFound)?; @@ -113,8 +170,7 @@ pub async fn get_current_activity( let curtime = Local::now().naive_local(); if curtime.signed_duration_since(start + duration) > Duration::seconds(900) { db.add_activity(target_user, inner_heartbeat, start, duration) - .await - .map_err(ErrorInternalServerError)?; + .await?; heartbeats.remove(&target_user); Err(TimeError::NotActive) @@ -129,42 +185,52 @@ pub async fn get_current_activity( current_heartbeat.heartbeat.project_name = Some(String::from("hidden")); } - Ok(web::Json(Some(current_heartbeat))) + Ok(Json(Some(current_heartbeat))) } } None => Err(TimeError::NotActive), } } -#[get("/users/{username}/activity/data")] +#[utoipa::path( + get, + path = "/users/{username}/activity/data", + params( + ("username", description = "User name"), + ), + security( + ("api_key" = []) + ), + responses( + (status = OK, body = Vec) + ) +)] pub async fn get_activities( + db: DatabaseWrapper, Query(data): Query, - path: Path<(String,)>, + Path(name): Path, opt_user: UserIdentityOptional, - db: DatabaseWrapper, -) -> Result { +) -> Result>, TimeError> { let Some(user) = opt_user.identity else { let target_user = db - .get_user_by_name(&path.0) + .get_user_by_name(&name) .await .map_err(|_| TimeError::UserNotFound)?; if target_user.is_public { - return Ok(web::Json( - db.get_activity(data, target_user.id, false).await?, - )); + return Ok(Json(db.get_activity(data, target_user.id, false).await?)); } else { return Err(TimeError::UserNotFound); }; }; - let data = if path.0 == "@me" { + let data: Vec = if name == "@me" { db.get_activity(data, user.id, true).await? } else { //FIXME: This is technically not required when the username equals the username of the //authenticated user let target_user = db - .get_user_by_name(&path.0) + .get_user_by_name(&name) .await .map_err(|_| TimeError::UserNotFound)?; @@ -179,21 +245,46 @@ pub async fn get_activities( } }; - Ok(web::Json(data)) + Ok(Json(data)) } -#[get("/users/{username}/activity/summary")] +#[derive(Debug, Clone, Serialize, ToSchema)] +pub struct LanguageSummary { + languages: HashMap, + total: i32, +} + +#[derive(Debug, Clone, Serialize, ToSchema)] +pub struct ActivitySummary { + last_week: LanguageSummary, + last_month: LanguageSummary, + all_time: LanguageSummary, +} + +#[utoipa::path( + get, + path = "/users/{username}/activity/summary", + params( + ("username", description = "User name") + ), + security( + ("api_key" = []) + ), + responses( + (status = OK, body = ActivitySummary) + ) +)] pub async fn get_activity_summary( - path: Path<(String,)>, + Path(path): Path, opt_user: UserIdentityOptional, db: DatabaseWrapper, -) -> Result { +) -> Result, TimeError> { let data = if let Some(user) = opt_user.identity { - if path.0 == "@me" { + if path == "@me" { db.get_all_activity(user.id).await? } else { let target_user = db - .get_user_by_name(&path.0) + .get_user_by_name(&path) .await .map_err(|_| TimeError::UserNotFound)?; @@ -208,7 +299,7 @@ pub async fn get_activity_summary( } } else { let target_user = db - .get_user_by_name(&path.0) + .get_user_by_name(&path) .await .map_err(|_| TimeError::UserNotFound)?; @@ -233,20 +324,18 @@ pub async fn get_activity_summary( .filter(|d| now.signed_duration_since(d.start_time) < Duration::days(7)), ); - let langs = serde_json::json!({ - "last_week": { - "languages": last_week, - "total": last_week.values().sum::(), + Ok(Json(ActivitySummary { + last_week: LanguageSummary { + total: last_week.values().sum::(), + languages: last_week, }, - "last_month": { - "languages": last_month, - "total": last_month.values().sum::(), + last_month: LanguageSummary { + total: last_month.values().sum::(), + languages: last_month, }, - "all_time": { - "languages": all_time, - "total": all_time.values().sum::(), + all_time: LanguageSummary { + total: all_time.values().sum::(), + languages: all_time, }, - }); - - Ok(web::Json(langs)) + })) } diff --git a/src/auth/mod.rs b/src/auth/mod.rs index f216208..1309422 100644 --- a/src/auth/mod.rs +++ b/src/auth/mod.rs @@ -1,107 +1,94 @@ -pub mod secured_access; - -use std::rc::Rc; - -use actix_web::{ - dev::{forward_ready, Service, ServiceRequest, ServiceResponse, Transform}, - error::{ErrorInternalServerError, ErrorUnauthorized}, - web::Data, - Error, FromRequest, HttpMessage, +use std::{ + mem, + task::{Context, Poll}, }; -use futures::future::LocalBoxFuture; -use self::secured_access::SecuredAccessTokenStorage; -use crate::{database::DatabaseWrapper, models::UserIdentity}; +use axum::extract::Request; +use futures_util::future::BoxFuture; +use tower::{Layer, Service}; + +use crate::{database::DatabaseWrapper, models::UserIdentity, TestaustimeState}; #[derive(Debug, Clone, PartialEq, Eq)] pub enum Authentication { NoAuth, AuthToken(UserIdentity), - SecuredAuthToken(UserIdentity), } -pub struct AuthMiddleware; +#[derive(Clone)] +pub struct AuthMiddleware { + pub state: TestaustimeState, +} -pub struct AuthMiddlewareTransform { - service: Rc, +#[derive(Clone)] +pub struct AuthMiddlewareService { + inner: S, + state: TestaustimeState, } -impl Transform for AuthMiddleware -where - S: Service, Error = Error> + 'static, - S::Future: 'static, - B: 'static, -{ - type Response = ServiceResponse; - type Error = Error; - type InitError = (); - type Transform = AuthMiddlewareTransform; - type Future = LocalBoxFuture<'static, Result>; +impl Authentication { + pub fn user(&self) -> Option<&UserIdentity> { + match self { + Authentication::NoAuth => None, + Authentication::AuthToken(user_identity) => Some(user_identity), + } + } +} - fn new_transform(&self, service: S) -> Self::Future { - Box::pin(async move { - Ok(AuthMiddlewareTransform { - service: Rc::new(service), - }) - }) +impl Layer for AuthMiddleware { + type Service = AuthMiddlewareService; + + fn layer(&self, inner: S) -> Self::Service { + AuthMiddlewareService { + inner, + state: self.state.clone(), + } } } -impl Service for AuthMiddlewareTransform +impl Service> for AuthMiddlewareService where - S: Service, Error = Error> + 'static, - S::Future: 'static, - B: 'static, + S: Service> + Clone + 'static, + S::Future: Send + 'static, + S: Send + 'static, + B: Send + 'static, { - type Response = ServiceResponse; + type Response = S::Response; type Error = S::Error; - type Future = LocalBoxFuture<'static, Result>; + type Future = BoxFuture<'static, Result>; - forward_ready!(service); + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + self.inner.poll_ready(cx) + } - fn call(&self, req: ServiceRequest) -> Self::Future { - let db = DatabaseWrapper::extract(req.request()); - let secured_access_storage = req - .app_data::>() - .expect("Secured token access storage not initialized") - .clone(); + fn call(&mut self, mut req: Request) -> Self::Future { + let db = DatabaseWrapper::from(&self.state.database); let auth = req.headers().get("Authorization").cloned(); - let service = Rc::clone(&self.service); + + let clone = self.inner.clone(); + let mut inner = mem::replace(&mut self.inner, clone); Box::pin(async move { - if let Some(auth) = auth { - if let Some(token) = auth.to_str().unwrap().trim().strip_prefix("Bearer ") { - let db = db.await.map_err(ErrorInternalServerError)?; - - if let Ok(secured_access_instance) = secured_access_storage.get(token).clone() { - let user = db - .get_user_by_id(secured_access_instance.user_id) - .await - .map_err(ErrorUnauthorized)?; - - req.extensions_mut() - .insert(Authentication::SecuredAuthToken(user)); - } else { - let user = db - .get_user_by_token(token.to_string()) - .await - .map_err(ErrorUnauthorized); - - if let Ok(user_identity) = user { - req.extensions_mut() - .insert(Authentication::AuthToken(user_identity)); - } else { - req.extensions_mut().insert(Authentication::NoAuth); - } - } + let auth = 'auth: { + let Some(auth) = auth else { + break 'auth Authentication::NoAuth; + }; + + let Some(token) = auth.to_str().unwrap().trim().strip_prefix("Bearer ") else { + break 'auth Authentication::NoAuth; + }; + + if let Ok(user_identity) = db.get_user_by_token(token.to_string()).await { + Authentication::AuthToken(user_identity) } else { - req.extensions_mut().insert(Authentication::NoAuth); + Authentication::NoAuth } - } else { - req.extensions_mut().insert(Authentication::NoAuth); - } + }; + + req.extensions_mut().insert(auth); + + let resp = inner.call(req).await?; - let resp = service.call(req).await?; Ok(resp) }) } diff --git a/src/auth/secured_access.rs b/src/auth/secured_access.rs deleted file mode 100644 index 33c6891..0000000 --- a/src/auth/secured_access.rs +++ /dev/null @@ -1,62 +0,0 @@ -use std::time::{Duration, Instant}; - -use dashmap::DashMap; - -use crate::utils::generate_token; - -#[derive(Clone, Copy, Debug)] -pub enum SecuredAccessError { - InvalidToken, - ExpiredToken, -} - -#[derive(Clone)] -pub struct SecuredAccessTokenInstance { - pub user_id: i32, - pub expires: Instant, -} - -pub struct SecuredAccessTokenStorage { - inner: DashMap, -} - -impl SecuredAccessTokenStorage { - pub fn new() -> Self { - Self { - inner: DashMap::new(), - } - } - - pub fn get(&self, token: &str) -> Result { - let instance = self - .inner - .get(token) - .ok_or(SecuredAccessError::InvalidToken)? - .clone(); - - if instance.expires < Instant::now() { - self.inner.remove(token); - Err(SecuredAccessError::ExpiredToken) - } else { - Ok(instance) - } - } - - pub fn create_token(&self, user_id: i32) -> String { - let token = generate_token(); - - self.inner.insert( - token.clone(), - SecuredAccessTokenInstance { - user_id, - expires: Instant::now() + Duration::from_secs(60 * 60), - }, - ); - - let now = Instant::now(); - - self.inner.retain(|_, v| v.expires > now); - - token - } -} diff --git a/src/database/activity.rs b/src/database/activity.rs index 51c5b65..b1d60ca 100644 --- a/src/database/activity.rs +++ b/src/database/activity.rs @@ -2,11 +2,7 @@ use chrono::{prelude::*, Duration}; use diesel::prelude::*; use diesel_async::RunQueryDsl; -use crate::{ - error::TimeError, - models::*, - requests::{DataRequest, HeartBeat}, -}; +use crate::{api::users::DataRequest, error::TimeError, models::*}; impl super::DatabaseWrapper { pub async fn add_activity( diff --git a/src/database/auth.rs b/src/database/auth.rs index 8a4d185..33673e6 100644 --- a/src/database/auth.rs +++ b/src/database/auth.rs @@ -1,6 +1,6 @@ use argon2::{ password_hash::{rand_core::OsRng, PasswordHasher, SaltString}, - Argon2, + Algorithm, Argon2, Params, Version, }; use diesel::prelude::*; use diesel_async::RunQueryDsl; @@ -28,7 +28,7 @@ impl super::DatabaseWrapper { pub async fn get_user_by_name(&self, target_username: &str) -> Result { let mut conn = self.db.get().await?; use crate::schema::user_identities::dsl::*; - sql_function!(fn lower(x: diesel::sql_types::Text) -> Text); + define_sql_function!(fn lower(x: diesel::sql_types::Text) -> Text); Ok(user_identities .filter(lower(username).eq(target_username.to_lowercase())) @@ -46,39 +46,35 @@ impl super::DatabaseWrapper { > 0) } - pub async fn get_user_by_id(&self, userid: i32) -> Result { - let mut conn = self.db.get().await?; - use crate::schema::user_identities::dsl::*; - - Ok(user_identities - .find(userid) - .first::(&mut conn) - .await?) - } - - // TODO: get rid of unwraps pub async fn verify_user_password( &self, arg_username: &str, password: &str, ) -> Result, TimeError> { let mut conn = self.db.get().await?; + define_sql_function!(fn lower(x: diesel::sql_types::Text) -> Text); use user_identities::dsl::username; let (user, tuser) = user_identities::table - .filter(username.eq(arg_username)) + .filter(lower(username).eq(arg_username.to_lowercase())) .inner_join(testaustime_users::table) .first::<(UserIdentity, TestaustimeUser)>(&mut conn) .await?; - let argon2 = Argon2::default(); - let Ok(salt) = SaltString::new(std::str::from_utf8(&tuser.salt).expect("bug: impossible")) - else { - return Ok(None); // The user has no password - }; - let password_hash = argon2.hash_password(password.as_bytes(), &salt).unwrap(); - if password_hash.hash.expect("bug: impossible").as_bytes() == tuser.password { + let argon2 = Argon2::new( + Algorithm::Argon2id, + Version::V0x13, + Params::new(4096, 3, 1, None).unwrap(), + ); + let salt = SaltString::from_b64(std::str::from_utf8(&tuser.salt).expect("Infallible"))?; + + let password_hash = argon2.hash_password(password.as_bytes(), &salt)?; + + if password_hash + .hash + .is_some_and(|p| p.as_bytes() == tuser.password) + { Ok(Some(user)) } else { Ok(None) @@ -88,7 +84,7 @@ impl super::DatabaseWrapper { pub async fn regenerate_token(&self, userid: i32) -> Result { let mut conn = self.db.get().await?; - let token = crate::utils::generate_token(); + let token = crate::utils::generate_auth_token(); use crate::schema::user_identities::dsl::*; @@ -104,20 +100,26 @@ impl super::DatabaseWrapper { &self, username: &str, password: &str, + email: Option<&str>, ) -> Result { if self.user_exists(username.to_string()).await? { - return Err(TimeError::UserExists); + return Err(TimeError::UsernameTaken); } let salt = SaltString::generate(&mut OsRng); - let argon2 = Argon2::default(); + let argon2 = Argon2::new( + Algorithm::Argon2id, + Version::V0x13, + Params::new(4096, 3, 1, None).unwrap(), + ); let password_hash = argon2.hash_password(password.as_bytes(), &salt).unwrap(); - let token = generate_token(); + let token = generate_auth_token(); let hash = password_hash.hash.unwrap(); let new_user = NewUserIdentity { auth_token: token, registration_time: chrono::Local::now().naive_local(), username: username.to_string(), friend_code: generate_friend_code(), + email: email.map(String::from), }; let new_user_clone = new_user.clone(); @@ -134,11 +136,11 @@ impl super::DatabaseWrapper { .returning(user_identities::id) .get_results::(&mut conn) .await - .map_err(|_| TimeError::UserExists)?; + .map_err(|_| TimeError::UsernameTaken)?; let testaustime_user = NewTestaustimeUser { password: hash.as_bytes().to_vec(), - salt: salt.as_bytes().to_vec(), + salt: salt.as_str().as_bytes().to_vec(), identity: id[0], }; @@ -158,37 +160,39 @@ impl super::DatabaseWrapper { pub async fn change_username(&self, user: i32, new_username: &str) -> Result<(), TimeError> { let mut conn = self.db.get().await?; - conn.build_transaction() - .read_write() - .run(|mut conn| { - Box::pin(async move { - use crate::schema::user_identities::dsl::*; - - if (user_identities - .filter(username.eq(new_username)) - .first::(&mut conn) - .await) - .is_ok() - { - return Err(TimeError::UserExists); - }; + use crate::schema::user_identities::dsl::*; + diesel::update(crate::schema::user_identities::table) + .filter(id.eq(user)) + .set(username.eq(new_username)) + .execute(&mut conn) + .await + .map_err(|_| TimeError::UsernameTaken)?; - diesel::update(crate::schema::user_identities::table) - .filter(id.eq(user)) - .set(username.eq(new_username)) - .execute(&mut conn) - .await - .map_err(|_| TimeError::UserExists)?; + Ok(()) + } - Ok::<(), TimeError>(()) - }) - }) + pub async fn change_email(&self, user: i32, new_email: String) -> Result<(), TimeError> { + let mut conn = self.db.get().await?; + + use crate::schema::user_identities::dsl::*; + diesel::update(crate::schema::user_identities::table) + .filter(id.eq(user)) + .set(email.eq(new_email)) + .execute(&mut conn) .await + .map_err(|_| TimeError::EmailTaken)?; + + Ok(()) } pub async fn change_password(&self, user: i32, new_password: &str) -> Result<(), TimeError> { let new_salt = SaltString::generate(&mut OsRng); - let argon2 = Argon2::default(); + let argon2 = Argon2::new( + Algorithm::Argon2id, + Version::V0x13, + Params::new(4096, 3, 1, None).unwrap(), + ); + let password_hash = argon2 .hash_password(new_password.as_bytes(), &new_salt) .unwrap(); @@ -201,7 +205,7 @@ impl super::DatabaseWrapper { .filter(identity.eq(user)) .set(( password.eq(&new_hash.as_bytes()), - salt.eq(new_salt.as_bytes()), + salt.eq(new_salt.as_str().as_bytes()), )) .execute(&mut conn) .await?; @@ -223,6 +227,24 @@ impl super::DatabaseWrapper { Ok(user) } + pub async fn get_user_by_email( + &self, + searched_email: &str, + ) -> Result, TimeError> { + let mut conn = self.db.get().await?; + let user = { + use crate::schema::user_identities::dsl::*; + + user_identities + .filter(email.eq(searched_email)) + .first::(&mut conn) + .await + .optional()? + }; + + Ok(user) + } + pub async fn get_testaustime_user_by_id(&self, uid: i32) -> Result { use crate::schema::testaustime_users::dsl::*; let mut conn = self.db.get().await?; @@ -265,17 +287,18 @@ impl super::DatabaseWrapper { Ok(token) } else { let new_user = NewUserIdentity { - auth_token: generate_token(), + auth_token: generate_auth_token(), registration_time: chrono::Local::now().naive_local(), username, friend_code: generate_friend_code(), + email: None, }; let new_user_id = diesel::insert_into(crate::schema::user_identities::table) .values(&new_user) .returning(id) .get_results::(&mut conn) .await - .map_err(|_| TimeError::UserExists)?; + .map_err(|_| TimeError::UsernameTaken)?; let testausid_user = NewTestausIdUser { user_id: user_id_arg, diff --git a/src/database/leaderboards.rs b/src/database/leaderboards.rs index 5501686..4ef192f 100644 --- a/src/database/leaderboards.rs +++ b/src/database/leaderboards.rs @@ -22,7 +22,7 @@ impl super::DatabaseWrapper { creator_id: i32, name: &str, ) -> Result { - let code = crate::utils::generate_token(); + let code = crate::utils::generate_auth_token(); let board = NewLeaderboard { name: name.to_string(), @@ -64,7 +64,7 @@ impl super::DatabaseWrapper { } pub async fn regenerate_leaderboard_invite(&self, lid: i32) -> Result { - let newinvite = crate::utils::generate_token(); + let newinvite = crate::utils::generate_auth_token(); let mut conn = self.db.get().await?; @@ -89,7 +89,7 @@ impl super::DatabaseWrapper { } pub async fn get_leaderboard_id_by_name(&self, lname: &str) -> Result { - sql_function!(fn lower(x: diesel::sql_types::Text) -> Text); + define_sql_function!(fn lower(x: diesel::sql_types::Text) -> Text); use crate::schema::leaderboards::dsl::*; let mut conn = self.db.get().await?; @@ -102,7 +102,7 @@ impl super::DatabaseWrapper { } pub async fn get_leaderboard(&self, lname: &str) -> Result { - sql_function!(fn lower(x: diesel::sql_types::Text) -> Text); + define_sql_function!(fn lower(x: diesel::sql_types::Text) -> Text); let mut conn = self.db.get().await?; let board = { diff --git a/src/database/mod.rs b/src/database/mod.rs index 3fa976b..f3a0d9f 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -1,6 +1,6 @@ -use std::{future::Future, pin::Pin, sync::Arc}; +use std::sync::Arc; -use actix_web::{dev::Payload, web::Data, FromRequest, HttpRequest}; +use axum::extract::{FromRef, FromRequestParts}; use diesel_async::{ pooled_connection::{ deadpool::{Object, Pool}, @@ -8,8 +8,9 @@ use diesel_async::{ }, AsyncPgConnection, }; +use http::request::Parts; -use crate::error::TimeError; +use crate::{error::TimeError, TestaustimeState}; pub mod activity; pub mod auth; @@ -27,20 +28,27 @@ pub struct DatabaseWrapper { db: Arc, } -impl FromRequest for DatabaseWrapper { - type Error = TimeError; - type Future = Pin>>>; +impl From<&Arc> for DatabaseWrapper { + fn from(value: &Arc) -> Self { + Self { + db: Arc::clone(value), + } + } +} + +impl FromRequestParts for DatabaseWrapper +where + TestaustimeState: FromRef, +{ + type Rejection = TimeError; - fn from_request(req: &HttpRequest, _payload: &mut Payload) -> Self::Future { + async fn from_request_parts(_parts: &mut Parts, state: &S) -> Result { + let state = TestaustimeState::from_ref(state); let wrapper = DatabaseWrapper { - db: req - .app_data::>() - .unwrap() - .clone() - .into_inner(), + db: Arc::clone(&state.database), }; - Box::pin(async move { Ok(wrapper) }) + Ok(wrapper) } } diff --git a/src/error.rs b/src/error.rs index 812e0b3..1bb22c8 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,8 +1,8 @@ -use actix_web::{ - error::{BlockingError, ResponseError}, - http::{header::ContentType, StatusCode}, - HttpResponse, +use axum::{ + response::{IntoResponse, Response}, + Json, }; +use http::StatusCode; use thiserror::Error; #[derive(Debug, Error)] @@ -14,9 +14,9 @@ pub enum TimeError { #[error("Internal server error")] DieselConnectionError(#[from] diesel::result::ConnectionError), #[error(transparent)] - ActixError(#[from] actix_web::error::Error), + AxumError(#[from] axum::Error), #[error("User exists")] - UserExists, + UsernameTaken, #[error("User not found")] UserNotFound, #[error("You cannot add yourself")] @@ -27,17 +27,17 @@ pub enum TimeError { LeaderboardNotFound, #[error("You are not authorized")] Unauthorized, - #[error("Missing secured access token")] - UnauthroizedSecuredAccess, #[error("Invalid username or password")] InvalidCredentials, - #[error(transparent)] - BlockingError(#[from] BlockingError), #[error("{0}")] InvalidLength(String), - #[error("Username has to contain characters from [a-zA-Z0-9_] and has to be between 2 and 32 characters")] + #[error( + "Username has to contain characters from [a-zA-Z0-9_] and has to be between 2 and 32 characters" + )] BadUsername, - #[error("Leaderboard name has to contain characters from [a-zA-Z0-9_] and has to be between 2 and 32 characters")] + #[error( + "Leaderboard name has to contain characters from [a-zA-Z0-9_] and has to be between 2 and 32 characters" + )] BadLeaderboardName, #[error("Bad id")] BadId, @@ -57,39 +57,69 @@ pub enum TimeError { TooManyRegisters, #[error("The user has no active session")] NotActive, + #[error("Cannot connect to mail server")] + SmtpError(#[from] lettre::transport::smtp::Error), + #[error("Invalid password reset token")] + InvalidPasswordResetToken, + #[error("Invalid email")] + InvalidEmail, + #[error("Expired password reset token")] + ExpiredPasswordResetToken, + #[error("Account with this email exists")] + EmailTaken, + #[error("Password hashing failed")] + HashError(#[from] argon2::password_hash::Error), } -unsafe impl Send for TimeError {} - -impl ResponseError for TimeError { - fn status_code(&self) -> StatusCode { +impl IntoResponse for TimeError { + fn into_response(self) -> Response { error!("{}", self); - match self { + let status_code = match self { TimeError::UserNotFound | TimeError::LeaderboardNotFound | TimeError::NotActive => { StatusCode::NOT_FOUND } TimeError::BadUsername | TimeError::InvalidLength(_) | TimeError::BadId - | TimeError::BadLeaderboardName => StatusCode::BAD_REQUEST, + | TimeError::BadLeaderboardName + | TimeError::InvalidEmail + | TimeError::BadCode => StatusCode::BAD_REQUEST, TimeError::CurrentUser | TimeError::NotMember | TimeError::LastAdmin => { StatusCode::FORBIDDEN } TimeError::AlreadyFriends | TimeError::LeaderboardExists | TimeError::AlreadyMember - | TimeError::UserExists => StatusCode::CONFLICT, + | TimeError::UsernameTaken + | TimeError::EmailTaken => StatusCode::CONFLICT, TimeError::Unauthorized | TimeError::InvalidCredentials - | TimeError::UnauthroizedSecuredAccess => StatusCode::UNAUTHORIZED, + | TimeError::InvalidPasswordResetToken + | TimeError::ExpiredPasswordResetToken => StatusCode::UNAUTHORIZED, TimeError::TooManyRegisters => StatusCode::TOO_MANY_REQUESTS, - _ => StatusCode::INTERNAL_SERVER_ERROR, - } + TimeError::DieselError(_) + | TimeError::DieselConnectionError(_) + | TimeError::DeadpoolError(_) + | Self::AxumError(_) + | TimeError::UnknownError + | TimeError::SmtpError(_) + | TimeError::HashError(_) => StatusCode::INTERNAL_SERVER_ERROR, + }; + + let body = Json(json!({"error": self.to_string()})); + + (status_code, body).into_response() } +} - fn error_response(&self) -> HttpResponse { - HttpResponse::build(self.status_code()) - .insert_header(ContentType::json()) - .body(json!({ "error": self.to_string() }).to_string()) +impl TimeError { + pub fn is_unique_violation(&self) -> bool { + matches!( + self, + TimeError::DieselError(diesel::result::Error::DatabaseError( + diesel::result::DatabaseErrorKind::UniqueViolation, + .. + )) + ) } } diff --git a/src/main.rs b/src/main.rs index 69643d4..b55b110 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,41 +4,38 @@ mod database; mod error; mod models; mod ratelimiter; -mod requests; mod schema; +mod state; mod utils; #[cfg(test)] mod tests; -use std::{num::NonZeroU32, sync::Arc}; +use std::{net::SocketAddr, num::NonZeroU32, sync::Arc}; -use actix_cors::Cors; -use actix_web::{ - dev::{ServiceRequest, ServiceResponse}, - error::{ErrorBadRequest, QueryPayloadError}, - web, - web::{Data, QueryConfig}, - App, HttpMessage, HttpServer, -}; -#[cfg(feature = "testausid")] -use api::oauth::ClientInfo; -use auth::{secured_access::SecuredAccessTokenStorage, AuthMiddleware, Authentication}; -use awc::Client; +use api::activity::HeartBeatMemoryStore; +use auth::{AuthMiddleware, Authentication}; +use axum::{body::Body, Router}; use chrono::NaiveDateTime; use dashmap::DashMap; use database::Database; use governor::{Quota, RateLimiter}; +use lettre::{transport::smtp::authentication::Credentials, AsyncSmtpTransport, Tokio1Executor}; +use models::UserIdentity; use ratelimiter::TestaustimeRateLimiter; use serde_derive::Deserialize; -use tracing::Span; -use tracing_actix_web::{root_span, RootSpanBuilder, TracingLogger}; - -#[macro_use] -extern crate actix_web; +use tower::ServiceBuilder; +use tower_http::trace::TraceLayer; +use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; +use utoipa::{ + openapi::security::{HttpAuthScheme, HttpBuilder, SecurityScheme}, + Modify, OpenApi, +}; +use utoipa_axum::{router::OpenApiRouter, routes}; +use utoipa_swagger_ui::SwaggerUi; #[macro_use] -extern crate log; +extern crate tracing; #[macro_use] extern crate diesel; @@ -47,156 +44,231 @@ extern crate diesel; extern crate serde_json; #[derive(Debug, Deserialize)] -pub struct TimeConfig { +pub struct TestaustimeConfig { pub bypass_token: String, pub ratelimit_by_peer_ip: bool, - pub max_requests_per_min: usize, + pub max_requests_per_min: u32, + pub max_registers_per_hour: u32, pub address: String, pub database_url: String, pub allowed_origin: String, - #[cfg(feature = "testausid")] - #[serde(flatten)] - pub oauth_client_info: ClientInfo, + pub mail_server: String, + pub mail_user: String, + pub mail_password: String, } -pub struct TestaustimeRootSpanBuilder; +pub struct RegisterLimiter { + pub limit_by_peer_ip: bool, + pub storage: DashMap, +} -impl RootSpanBuilder for TestaustimeRootSpanBuilder { - fn on_request_start(request: &ServiceRequest) -> Span { - if let Authentication::AuthToken(user) = - request.extensions().get::().unwrap() - { - root_span!(request, user.id, user.username) - } else { - root_span!(request) - } - } +pub struct PasswordReset { + pub user: UserIdentity, + pub expires: NaiveDateTime, +} - fn on_request_end(_span: Span, _outcome: &Result, actix_web::Error>) {} +pub struct PasswordResetState { + pub storage: DashMap, } -pub struct RegisterLimiter { - pub limit_by_peer_ip: bool, - pub storage: DashMap, +#[derive(Clone)] +pub struct TestaustimeState { + smtp: AsyncSmtpTransport, + database: Arc, + heartbeat_store: Arc, + register_limiter: Arc, + password_reset_state: Arc, } -#[actix_web::main] -async fn main() -> std::io::Result<()> { - dotenv::dotenv().ok(); - env_logger::init(); +#[derive(OpenApi)] +#[openapi( + modifiers(&SecurityAddon), +)] +struct ApiDoc; - let config: TimeConfig = - toml::from_str(&std::fs::read_to_string("settings.toml").expect("Missing settings.toml")) - .expect("Invalid Toml in settings.toml"); +struct SecurityAddon; + +impl Modify for SecurityAddon { + fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) { + if let Some(components) = openapi.components.as_mut() { + components.add_security_scheme( + "api_key", + SecurityScheme::Http( + HttpBuilder::new() + .scheme(HttpAuthScheme::Bearer) + .bearer_format("Bearer") + .build(), + ), + ) + } + } +} - let database = Data::new(Database::new(config.database_url)); +fn create_router_with_openapi(config: &TestaustimeConfig) -> (Router, utoipa::openapi::OpenApi) { + let database = Arc::new(Database::new(config.database_url.clone())); - let register_limiter = Data::new(RegisterLimiter { + let register_limiter = Arc::new(RegisterLimiter { limit_by_peer_ip: config.ratelimit_by_peer_ip, storage: DashMap::new(), }); + let heartbeat_store = Arc::new(HeartBeatMemoryStore::new()); + + let password_reset_state = Arc::new(PasswordResetState { + storage: DashMap::default(), + }); + + let creds = Credentials::new(config.mail_user.to_owned(), config.mail_password.to_owned()); + + let smtp: AsyncSmtpTransport = + AsyncSmtpTransport::::starttls_relay(&config.mail_server) + .unwrap_or_else(|_| panic!("failed to connect to {}", &config.mail_server)) + .credentials(creds) + .build(); + + debug!( + "Connected to mail server on {} as {}", + config.mail_server, config.mail_user + ); + + let state = TestaustimeState { + smtp, + heartbeat_store, + database, + register_limiter, + password_reset_state, + }; + + let auth = AuthMiddleware { + state: state.clone(), + }; + let ratelimiter = Arc::new( RateLimiter::keyed(Quota::per_minute( - NonZeroU32::new(config.max_requests_per_min as u32).unwrap(), + NonZeroU32::new(config.max_requests_per_min).unwrap(), )) .with_middleware(), ); - let heartbeat_store = Data::new(api::activity::HeartBeatMemoryStore::new()); - - let secured_access_token_storage = Data::new(SecuredAccessTokenStorage::new()); - - HttpServer::new(move || { - #[cfg(feature = "testausid")] - let tracing = TracingLogger::::new(); - let client = Client::new(); - let cors = Cors::default() - .allow_any_origin() - .allowed_methods(vec!["GET", "POST", "DELETE"]) - .allowed_headers(vec![ - http::header::AUTHORIZATION, - http::header::ACCEPT, - http::header::CONTENT_TYPE, - ]) - .max_age(3600); - let query_config = QueryConfig::default().error_handler(|err, _| match err { - QueryPayloadError::Deserialize(e) => ErrorBadRequest(json!({ "error": e.to_string() })), - _ => unreachable!(), - }); - let app = App::new() - .app_data(Data::clone(®ister_limiter)) - .app_data(query_config) - .app_data(Data::clone(&secured_access_token_storage)) - .wrap(cors) - .service(api::health) - .service(api::auth::register) - .service({ - let scope = web::scope("") - .wrap(tracing) - .wrap(AuthMiddleware) - .wrap(TestaustimeRateLimiter { - limiter: Arc::clone(&ratelimiter), - use_peer_addr: config.ratelimit_by_peer_ip, - bypass_token: config.bypass_token.clone(), - }) - .service({ - web::scope("/activity") - .service(api::activity::update) - .service(api::activity::delete) - .service(api::activity::flush) - .service(api::activity::rename_project) - .service(api::activity::hide_project) - }) - .service(api::auth::login) - .service(api::auth::regenerate) - .service(api::auth::changeusername) - .service(api::auth::changepassword) - .service(api::auth::get_secured_access_token) - .service(api::account::change_settings) - .service(api::friends::add_friend) - .service(api::friends::get_friends) - .service(api::friends::regenerate_friend_code) - .service(api::friends::remove) - .service(api::users::my_profile) - .service(api::users::get_activities) - .service(api::users::get_current_activity) - .service(api::users::delete_user) - .service(api::users::my_leaderboards) - .service(api::users::get_activity_summary) - .service(api::leaderboards::create_leaderboard) - .service(api::leaderboards::get_leaderboard) - .service(api::leaderboards::join_leaderboard) - .service(api::leaderboards::leave_leaderboard) - .service(api::leaderboards::delete_leaderboard) - .service(api::leaderboards::promote_member) - .service(api::leaderboards::demote_member) - .service(api::leaderboards::kick_member) - .service(api::leaderboards::regenerate_invite) - .service(api::search::search_public_users) - .service(api::stats::stats); - #[cfg(feature = "testausid")] - { - scope.service(api::oauth::callback) - } - #[cfg(not(feature = "testausid"))] - { - scope - } - }) - .app_data(Data::clone(&database)) - .app_data(Data::clone(&heartbeat_store)); - #[cfg(feature = "testausid")] - { - app.app_data(Data::new(client)) - .app_data(Data::new(config.oauth_client_info.clone())) - } - #[cfg(not(feature = "testausid"))] - { - app - } - }) - .bind(config.address)? - .run() + let register_ratelimiter = Arc::new( + RateLimiter::keyed(Quota::per_hour( + NonZeroU32::new(config.max_registers_per_hour).unwrap(), + )) + .with_middleware(), + ); + + OpenApiRouter::new() + .routes(routes!(api::health)) + .merge( + OpenApiRouter::new() + .routes(routes!(api::auth::register)) + .layer(TestaustimeRateLimiter { + limiter: register_ratelimiter, + use_peer_addr: config.ratelimit_by_peer_ip, + bypass_token: config.bypass_token.clone(), + }), + ) + .merge({ + let router = OpenApiRouter::with_openapi(ApiDoc::openapi()) + .routes(routes!(api::activity::update)) + .routes(routes!(api::activity::delete)) + .routes(routes!(api::activity::flush)) + .routes(routes!(api::activity::rename_project)) + .routes(routes!(api::activity::hide_project)) + .routes(routes!(api::auth::login)) + .routes(routes!(api::auth::regenerate_auth_token)) + .routes(routes!(api::auth::change_username)) + .routes(routes!(api::auth::change_email)) + .routes(routes!(api::auth::change_password)) + .routes(routes!(api::auth::request_password_reset)) + .routes(routes!(api::auth::reset_password)) + .routes(routes!(api::account::change_settings)) + .routes(routes!(api::friends::add_friend)) + .routes(routes!(api::friends::get_friends)) + .routes(routes!(api::friends::regenerate_friend_code)) + .routes(routes!(api::friends::remove)) + .routes(routes!(api::users::my_profile)) + .routes(routes!(api::users::delete_user)) + .routes(routes!(api::users::my_leaderboards)) + .routes(routes!(api::users::get_activities)) + .routes(routes!(api::users::get_current_activity)) + .routes(routes!(api::users::get_activity_summary)) + .routes(routes!(api::leaderboards::create_leaderboard)) + .routes(routes!( + // utoipa/axum will not resolve these correctly based on method if registered + // seperately, go figure + api::leaderboards::get_leaderboard, + api::leaderboards::delete_leaderboard + )) + .routes(routes!(api::leaderboards::join_leaderboard)) + .routes(routes!(api::leaderboards::leave_leaderboard)) + .routes(routes!(api::leaderboards::promote_member)) + .routes(routes!(api::leaderboards::demote_member)) + .routes(routes!(api::leaderboards::kick_member)) + .routes(routes!(api::leaderboards::regenerate_invite)) + .routes(routes!(api::search::search_public_users)) + .routes(routes!(api::stats::stats)); + + #[cfg(feature = "testausid")] + let router = router.routes(routes!(api::oauth::callback)); + + router + .layer( + ServiceBuilder::new() + .layer(TestaustimeRateLimiter { + limiter: ratelimiter, + use_peer_addr: config.ratelimit_by_peer_ip, + bypass_token: config.bypass_token.clone(), + }) + .layer(auth), + ) + .layer(TraceLayer::new_for_http().make_span_with( + |request: &http::Request| { + tracing::debug_span!( + "request", + method = %request.method(), + uri = request.uri().path(), + user = request + .extensions() + .get::() + .and_then(|auth| auth.user().map(|u| &u.username))) + }, + )) + }) + .with_state(state) + .split_for_parts() +} + +#[tokio::main] +async fn main() { + dotenv::dotenv().ok(); + tracing_subscriber::registry() + .with( + tracing_subscriber::EnvFilter::try_from_env("TESTAUSTIME_LOG").unwrap_or_else(|_| { + "testaustime=debug,tower_http=debug,axum::rejection=trace".into() + }), + ) + .with(tracing_subscriber::fmt::layer()) + .init(); + + let config: TestaustimeConfig = + toml::from_str(&std::fs::read_to_string("settings.toml").expect("Missing settings.toml")) + .expect("Invalid Toml in settings.toml"); + + let (router, openapi) = create_router_with_openapi(&config); + let router = + router.merge(SwaggerUi::new("/swagger-ui").url("/api-docs/openapi.json", openapi.clone())); + + let listener = tokio::net::TcpListener::bind(&config.address) + .await + .unwrap(); + + info!("Staring server on {}", config.address); + + axum::serve( + listener, + router.into_make_service_with_connect_info::(), + ) .await + .unwrap(); } diff --git a/src/models.rs b/src/models.rs index 89062b1..2958766 100644 --- a/src/models.rs +++ b/src/models.rs @@ -1,12 +1,14 @@ #![allow(clippy::extra_unused_lifetimes)] +use serde::Deserializer; use serde::{Deserialize, Serialize}; +use utoipa::ToSchema; #[derive(Serialize, Deserialize, Debug, Default, Clone, Eq, PartialEq, Hash)] pub struct UserId { pub id: i32, } -#[derive(Identifiable, Queryable, Clone, Debug, Serialize, PartialEq, Eq)] +#[derive(Identifiable, Queryable, Clone, Debug, Serialize, PartialEq, Eq, ToSchema)] #[diesel(table_name = user_identities)] pub struct UserIdentity { pub id: i32, @@ -16,9 +18,10 @@ pub struct UserIdentity { pub username: String, pub registration_time: chrono::NaiveDateTime, pub is_public: bool, + pub email: Option, } -#[derive(Clone, Debug, Serialize)] +#[derive(Clone, Debug, Serialize, ToSchema)] pub struct PublicUser { pub id: i32, pub username: String, @@ -47,7 +50,7 @@ pub struct TestaustimeUser { pub identity: i32, } -use crate::{requests::HeartBeat, schema::testaustime_users}; +use crate::schema::testaustime_users; #[derive(Insertable, Serialize, Clone)] #[diesel(table_name = testaustime_users)] @@ -59,7 +62,7 @@ pub struct NewTestaustimeUser { pub identity: i32, } -#[derive(Clone, Debug, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)] pub struct SelfUser { pub id: i32, pub auth_token: String, @@ -107,13 +110,14 @@ pub struct TestausIdUser { use crate::schema::user_identities; -#[derive(Insertable, Serialize, Clone, Deserialize)] +#[derive(Insertable, Serialize, ToSchema, Clone, Deserialize)] #[diesel(table_name = user_identities)] pub struct NewUserIdentity { pub auth_token: String, pub username: String, pub friend_code: String, pub registration_time: chrono::NaiveDateTime, + pub email: Option, } // NOTE: It is impossible to use diesel::assocations here @@ -134,7 +138,7 @@ pub struct NewFriendRelation { pub greater_id: i32, } -#[derive(Queryable, Clone, Debug, Serialize, Identifiable, Associations)] +#[derive(Queryable, Clone, Debug, Serialize, Identifiable, Associations, ToSchema)] #[diesel(belongs_to(UserIdentity, foreign_key=user_id))] #[diesel(table_name = coding_activities)] pub struct CodingActivity { @@ -204,7 +208,7 @@ pub struct NewLeaderboardMember { pub admin: bool, } -#[derive(Serialize, Clone, Debug, Deserialize)] +#[derive(Serialize, Clone, Debug, Deserialize, ToSchema)] pub struct PrivateLeaderboardMember { pub id: i32, pub username: String, @@ -212,7 +216,7 @@ pub struct PrivateLeaderboardMember { pub time_coded: i32, } -#[derive(Serialize, Clone, Debug, Deserialize)] +#[derive(Serialize, Clone, Debug, Deserialize, ToSchema)] pub struct PrivateLeaderboard { pub name: String, pub invite: String, @@ -220,14 +224,14 @@ pub struct PrivateLeaderboard { pub members: Vec, } -#[derive(Serialize, Deserialize, Debug, Default, Clone, Eq, PartialEq, Hash)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, Eq, PartialEq, Hash, ToSchema)] pub struct CodingTimeSteps { pub all_time: i32, pub past_month: i32, pub past_week: i32, } -#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)] +#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone, ToSchema)] pub struct CurrentActivity { pub started: chrono::NaiveDateTime, pub duration: i64, @@ -240,14 +244,34 @@ pub struct FriendWithTime { pub coding_time: CodingTimeSteps, } -#[derive(Serialize, Deserialize, Debug, Default, Clone, Eq, PartialEq, Hash)] +#[derive(Serialize, Deserialize, Debug, Default, Clone, Eq, PartialEq, Hash, ToSchema)] pub struct FriendWithTimeAndStatus { pub username: String, pub coding_time: CodingTimeSteps, pub status: Option, } -#[derive(Serialize, Deserialize, Debug, Default, Clone, Eq, PartialEq, Hash)] -pub struct SecuredAccessTokenResponse { - pub token: String, +#[derive(Deserialize, Serialize, ToSchema, Debug, Hash, Eq, PartialEq, Clone)] +pub struct HeartBeat { + #[serde(deserialize_with = "project_deserialize")] + pub project_name: Option, + pub language: Option, + pub editor_name: Option, + pub hostname: Option, + pub hidden: Option, +} + +// Wtf is this +fn project_deserialize<'de, D>(deserializer: D) -> Result, D::Error> +where + D: Deserializer<'de>, +{ + let project = Option::::deserialize(deserializer)?; + Ok(project.map(|p| { + if p.starts_with("tmp.") { + String::from("tmp") + } else { + p + } + })) } diff --git a/src/ratelimiter.rs b/src/ratelimiter.rs index 2ffe1f5..a97c9e7 100644 --- a/src/ratelimiter.rs +++ b/src/ratelimiter.rs @@ -1,72 +1,77 @@ -use std::{net::IpAddr, rc::Rc, sync::Arc}; +use std::{ + net::{IpAddr, SocketAddr}, + sync::Arc, + task::{Context, Poll}, +}; -use actix_web::{ - body::EitherBody, - dev::{forward_ready, Service, ServiceRequest, ServiceResponse, Transform}, - Error, HttpResponse, +use axum::{ + body::Body, + extract::{ConnectInfo, Request}, + response::Response, }; -use futures_util::future::LocalBoxFuture; +use futures_util::future::BoxFuture; use governor::{ clock::DefaultClock, middleware::StateInformationMiddleware, state::keyed::DefaultKeyedStateStore, RateLimiter, }; -use http::{header::HeaderName, HeaderValue}; +use http::{ + header::{HeaderName, FORWARDED}, + HeaderValue, StatusCode, +}; +use tower::{Layer, Service}; type SharedRateLimiter = Arc, DefaultClock, M>>; +#[derive(Clone)] pub struct TestaustimeRateLimiter { pub limiter: SharedRateLimiter, pub use_peer_addr: bool, pub bypass_token: String, } -impl Transform for TestaustimeRateLimiter -where - S: Service, Error = Error> + 'static, - S::Future: 'static, - B: 'static, -{ - type Response = ServiceResponse>; - type Error = Error; - type InitError = (); - type Transform = TestaustimeRateLimiterTransform; - type Future = LocalBoxFuture<'static, Result>; - - fn new_transform(&self, service: S) -> Self::Future { - let transform = Ok(Self::Transform { - service: Rc::new(service), +impl Layer for TestaustimeRateLimiter { + type Service = TestaustimeRateLimiterService; + + fn layer(&self, inner: S) -> Self::Service { + Self::Service { + inner, limiter: Arc::clone(&self.limiter), use_peer_addr: self.use_peer_addr, bypass_token: self.bypass_token.clone(), - }); - - Box::pin(async move { transform }) + } } } -pub struct TestaustimeRateLimiterTransform { - service: Rc, +#[derive(Clone)] +pub struct TestaustimeRateLimiterService { + inner: S, limiter: SharedRateLimiter, use_peer_addr: bool, bypass_token: String, } -impl Service for TestaustimeRateLimiterTransform +impl Service for TestaustimeRateLimiterService where - S: Service, Error = Error> + 'static, - S::Future: 'static, - B: 'static, + S: Service, + S::Future: Send + 'static, { - type Response = ServiceResponse>; + type Response = S::Response; type Error = S::Error; - type Future = LocalBoxFuture<'static, Result>; + type Future = BoxFuture<'static, Result>; - forward_ready!(service); + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + self.inner.poll_ready(cx) + } - fn call(&self, req: ServiceRequest) -> Self::Future { - let conn_info = req.connection_info().clone(); + fn call(&mut self, req: Request) -> Self::Future { if let Some(ip) = { + let conn_info = req + .extensions() + .get::>() + .unwrap() + .ip(); + let bypass = req .headers() .get("bypass-token") @@ -75,18 +80,27 @@ where let addr = if bypass { req.headers() .get("client-ip") - .and_then(|ip| ip.to_str().ok()) + .and_then(|ip| ip.to_str().ok().and_then(|ip| ip.parse::().ok())) } else if self.use_peer_addr { - conn_info.peer_addr() + Some(conn_info) } else { - conn_info.realip_remote_addr() + let header = req + .headers() + .get("x-forwarded-for") + .or_else(|| req.headers().get(FORWARDED)); + + Some( + header + .and_then(|ip| ip.to_str().ok().and_then(|ip| ip.parse::().ok())) + .unwrap_or(conn_info), + ) }; - addr.and_then(|addr| addr.parse::().ok()) + addr } { match self.limiter.check_key(&ip) { Ok(state) => { - let res = self.service.call(req); + let res = self.inner.call(req); Box::pin(async move { let mut res = res.await?; @@ -97,42 +111,45 @@ where headers.insert( HeaderName::from_static("ratelimit-limit"), - HeaderValue::from_str("a.burst_size().to_string())?, + HeaderValue::from_str("a.burst_size().to_string()).unwrap(), ); headers.insert( HeaderName::from_static("ratelimit-remaining"), - HeaderValue::from_str(&state.remaining_burst_capacity().to_string())?, + HeaderValue::from_str(&state.remaining_burst_capacity().to_string()) + .unwrap(), ); headers.insert( HeaderName::from_static("ratelimit-reset"), HeaderValue::from_str( "a.replenish_interval().as_secs().to_string(), - )?, + ) + .unwrap(), ); - Ok(res.map_into_left_body()) + Ok(res) }) } Err(denied) => Box::pin(async move { - let response = HttpResponse::TooManyRequests() - .insert_header(("ratelimit-limit", denied.quota().burst_size().to_string())) - .insert_header(("ratelimit-remaining", "0")) - .insert_header(( + Ok(Response::builder() + .status(StatusCode::TOO_MANY_REQUESTS) + .header("ratelimit-limit", denied.quota().burst_size().to_string()) + .header("ratelimit-remaining", "0") + .header( "ratelimit-reset", denied.quota().replenish_interval().as_secs().to_string(), - )) - .finish(); - - Ok(req.into_response(response.map_into_right_body())) + ) + .body(Body::empty()) + .unwrap()) }), } } else { Box::pin(async move { - Err(actix_web::error::ErrorInternalServerError( - "Failed to get request ip (?)", - )) + Ok(Response::builder() + .status(StatusCode::INTERNAL_SERVER_ERROR) + .body(Body::empty()) + .unwrap()) }) } } diff --git a/src/requests.rs b/src/requests.rs deleted file mode 100644 index 161d41f..0000000 --- a/src/requests.rs +++ /dev/null @@ -1,58 +0,0 @@ -use chrono::{serde::ts_seconds_option, DateTime, Utc}; -use serde::{Deserialize, Deserializer, Serialize}; - -#[derive(Deserialize, Serialize, Debug, Hash, Eq, PartialEq, Clone)] -pub struct HeartBeat { - #[serde(deserialize_with = "project_deserialize")] - pub project_name: Option, - pub language: Option, - pub editor_name: Option, - pub hostname: Option, - pub hidden: Option, -} - -fn project_deserialize<'de, D>(deserializer: D) -> Result, D::Error> -where - D: Deserializer<'de>, -{ - let project = Option::::deserialize(deserializer)?; - Ok(project.map(|p| { - if p.starts_with("tmp.") { - String::from("tmp") - } else { - p - } - })) -} - -#[derive(Deserialize, Debug)] -pub struct DataRequest { - #[serde(default)] - #[serde(with = "ts_seconds_option")] - pub from: Option>, - #[serde(default)] - #[serde(with = "ts_seconds_option")] - pub to: Option>, - pub min_duration: Option, - pub editor_name: Option, - pub language: Option, - pub hostname: Option, - pub project_name: Option, -} - -#[derive(Deserialize, Debug)] -pub struct RegisterRequest { - pub username: String, - pub password: String, -} - -#[derive(Deserialize)] -pub struct UsernameChangeRequest { - pub new: String, -} - -#[derive(Deserialize)] -pub struct PasswordChangeRequest { - pub old: String, - pub new: String, -} diff --git a/src/schema.rs b/src/schema.rs index b3bc6a2..2a73baf 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -8,11 +8,11 @@ diesel::table! { duration -> Int4, #[max_length = 64] project_name -> Nullable, - #[max_length = 32] + #[max_length = 64] language -> Nullable, - #[max_length = 32] + #[max_length = 64] editor_name -> Nullable, - #[max_length = 32] + #[max_length = 64] hostname -> Nullable, hidden -> Bool, } @@ -75,6 +75,7 @@ diesel::table! { username -> Varchar, registration_time -> Timestamp, is_public -> Bool, + email -> Nullable, } } diff --git a/src/state.rs b/src/state.rs new file mode 100644 index 0000000..121cc2b --- /dev/null +++ b/src/state.rs @@ -0,0 +1,32 @@ +use std::sync::Arc; + +use axum::extract::FromRef; +use lettre::{AsyncSmtpTransport, Tokio1Executor}; + +use crate::{ + api::activity::HeartBeatMemoryStore, PasswordResetState, RegisterLimiter, TestaustimeState, +}; + +impl FromRef for Arc { + fn from_ref(input: &TestaustimeState) -> Self { + Arc::clone(&input.heartbeat_store) + } +} + +impl FromRef for Arc { + fn from_ref(input: &TestaustimeState) -> Self { + Arc::clone(&input.register_limiter) + } +} + +impl FromRef for Arc { + fn from_ref(input: &TestaustimeState) -> Self { + Arc::clone(&input.password_reset_state) + } +} + +impl FromRef for AsyncSmtpTransport { + fn from_ref(input: &TestaustimeState) -> Self { + input.smtp.clone() + } +} diff --git a/src/tests/account.rs b/src/tests/account.rs index e8d90ea..de5a2e5 100644 --- a/src/tests/account.rs +++ b/src/tests/account.rs @@ -1,66 +1,55 @@ -use std::net::{IpAddr, Ipv4Addr, SocketAddr}; - -use actix_web::test::{self, TestRequest}; use serde_json::json; use super::{macros::*, *}; -use crate::models::{NewUserIdentity, SecuredAccessTokenResponse}; +use crate::models::NewUserIdentity; -#[actix_web::test] +#[tokio::test] async fn public_accounts() { - let app = test::init_service(App::new().configure(init_test_services)).await; + let mut app = create_test_router().into_service(); let body = json!({"username": "celebrity", "password": "password"}); - let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 80u16); - let resp = request!(app, addr, post, "/auth/register", body); + let resp = request!(app, POST, "/auth/register", body); assert!(resp.status().is_success(), "Creating user failed"); - let user: NewUserIdentity = test::read_body_json(resp).await; - let resp = request_auth!(app, addr, get, "/users/@me", user.auth_token); + let user: NewUserIdentity = body_to_json(resp).await; + let resp = request_auth!(app, GET, "/users/@me", user.auth_token); assert!(resp.status().is_success(), "Getting profile failed"); - let profile: serde_json::Value = test::read_body_json(resp).await; + let profile: serde_json::Value = body_to_json(resp).await; assert!( !profile["is_public"].as_bool().unwrap(), "New account should be private" ); - let resp = request!(app, addr, get, "/users/celebrity/activity/data"); + let resp = request!(app, GET, "/users/celebrity/activity/data"); assert!( resp.status().is_client_error(), "Data should be private for private accounts" ); - let resp = request!(app, addr, post, "/auth/securedaccess", body); - assert!( - resp.status().is_success(), - "Getting secured access token failed" - ); - let sat: SecuredAccessTokenResponse = test::read_body_json(resp).await; - let change = json!({"public_profile": true}); - let resp = request_auth!(app, addr, post, "/account/settings", sat.token, change); + let resp = request_auth!(app, POST, "/account/settings", user.auth_token, change); assert!(resp.status().is_success(), "Changing settings failed"); - let resp = request_auth!(app, addr, get, "/users/@me", user.auth_token); + let resp = request_auth!(app, GET, "/users/@me", user.auth_token); assert!(resp.status().is_success(), "Getting profile failed"); - let profile: serde_json::Value = test::read_body_json(resp).await; + let profile: serde_json::Value = body_to_json(resp).await; assert!( profile["is_public"].as_bool().unwrap(), "Setting account public failed" ); - let resp = request!(app, addr, get, "/users/celebrity/activity/data"); + let resp = request!(app, GET, "/users/celebrity/activity/data"); assert!( resp.status().is_success(), "Data should be public for public accounts" ); - let resp = request!(app, addr, delete, "/users/@me/delete", body); + let resp = request!(app, DELETE, "/users/@me/delete", body); assert!(resp.status().is_success(), "Failed to delete user"); } diff --git a/src/tests/activity.rs b/src/tests/activity.rs index 57f16ad..3a09e71 100644 --- a/src/tests/activity.rs +++ b/src/tests/activity.rs @@ -1,22 +1,17 @@ -use std::net::{IpAddr, Ipv4Addr, SocketAddr}; +use std::time::Duration; -use actix_web::test::{self, TestRequest}; use serde_json::json; use super::{macros::*, *}; -use crate::{ - models::{CurrentActivity, NewUserIdentity, SecuredAccessTokenResponse}, - requests::HeartBeat, -}; +use crate::models::{CurrentActivity, HeartBeat, NewUserIdentity}; -#[actix_web::test] +#[tokio::test] async fn updating_activity_works() { - let app = test::init_service(App::new().configure(init_test_services)).await; - let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 80u16); + let mut app = create_test_router().into_service(); let body = json!({"username": "activeuser", "password": "password"}); - let resp = request!(app, addr, post, "/auth/register", body); - let user: NewUserIdentity = test::read_body_json(resp).await; + let resp = request!(app, POST, "/auth/register", body); + let user: NewUserIdentity = body_to_json(resp).await; let heartbeat = HeartBeat { hostname: Some(String::from("hostname")), @@ -26,32 +21,19 @@ async fn updating_activity_works() { hidden: Some(false), }; - let resp = request_auth!( - app, - addr, - post, - "/activity/update", - user.auth_token, - heartbeat - ); + let resp = request_auth!(app, POST, "/activity/update", user.auth_token, heartbeat); assert!( resp.status().is_success(), "Sending heartbeat should succeed" ); - let resp = request_auth!( - app, - addr, - get, - "/users/@me/activity/current", - user.auth_token - ); + let resp = request_auth!(app, GET, "/users/@me/activity/current", user.auth_token); assert!( resp.status().is_success(), "Getting current activity should work" ); - let current: CurrentActivity = test::read_body_json(resp).await; + let current: CurrentActivity = body_to_json(resp).await; assert_eq!( heartbeat, current.heartbeat, @@ -59,26 +41,13 @@ async fn updating_activity_works() { ); // NOTE: adding duration to the session - actix_web::rt::time::sleep(std::time::Duration::from_secs(1)).await; + tokio::time::sleep(Duration::from_secs(2)).await; - let resp = request_auth!( - app, - addr, - post, - "/activity/update", - user.auth_token, - heartbeat - ); + let resp = request_auth!(app, POST, "/activity/update", user.auth_token, heartbeat); assert!(resp.status().is_success(), "Extending session should work"); - let resp = request_auth!( - app, - addr, - get, - "/users/@me/activity/current", - user.auth_token - ); - let current: CurrentActivity = test::read_body_json(resp).await; + let resp = request_auth!(app, GET, "/users/@me/activity/current", user.auth_token); + let current: CurrentActivity = body_to_json(resp).await; assert!( current.duration >= 1, "Duration should be at least 1 second" @@ -93,8 +62,7 @@ async fn updating_activity_works() { }; let resp = request_auth!( app, - addr, - post, + POST, "/activity/update", user.auth_token, new_heartbeat @@ -104,36 +72,29 @@ async fn updating_activity_works() { "Sending heartbeat should succeed" ); - let resp = request_auth!( - app, - addr, - get, - "/users/@me/activity/current", - user.auth_token - ); - let current: CurrentActivity = test::read_body_json(resp).await; + let resp = request_auth!(app, GET, "/users/@me/activity/current", user.auth_token); + let current: CurrentActivity = body_to_json(resp).await; assert!( current.heartbeat == new_heartbeat, "Mismatch should start new session" ); - let resp = request_auth!(app, addr, get, "/users/@me/activity/data", user.auth_token); - let data: Vec = test::read_body_json(resp).await; + let resp = request_auth!(app, GET, "/users/@me/activity/data", user.auth_token); + let data: Vec = body_to_json(resp).await; assert!(!data.is_empty(), "Old session is stored in the database"); - let resp = request!(app, addr, delete, "/users/@me/delete", body); + let resp = request!(app, DELETE, "/users/@me/delete", body); assert!(resp.status().is_success(), "Failed to delete user"); } -#[actix_web::test] +#[tokio::test] async fn flushing_works() { - let app = test::init_service(App::new().configure(init_test_services)).await; - let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 80u16); + let mut app = create_test_router().into_service(); let body = json!({"username": "activeuser2", "password": "password"}); - let resp = request!(app, addr, post, "/auth/register", body); - let user: NewUserIdentity = test::read_body_json(resp).await; + let resp = request!(app, POST, "/auth/register", body); + let user: NewUserIdentity = body_to_json(resp).await; let heartbeat = HeartBeat { hostname: Some(String::from("hostname")), @@ -143,44 +104,36 @@ async fn flushing_works() { hidden: Some(false), }; - let resp = request_auth!( - app, - addr, - post, - "/activity/update", - user.auth_token, - heartbeat - ); + let resp = request_auth!(app, POST, "/activity/update", user.auth_token, heartbeat); assert!( resp.status().is_success(), "Sending heartbeat should succeed" ); - let resp = request_auth!(app, addr, get, "/users/@me/activity/data", user.auth_token); - let data: Vec = test::read_body_json(resp).await; + let resp = request_auth!(app, GET, "/users/@me/activity/data", user.auth_token); + let data: Vec = body_to_json(resp).await; assert!(data.is_empty(), "No session should exist"); - let resp = request_auth!(app, addr, post, "/activity/flush", user.auth_token); + let resp = request_auth!(app, POST, "/activity/flush", user.auth_token); assert!(resp.status().is_success(), "Flushing should work"); - let resp = request_auth!(app, addr, get, "/users/@me/activity/data", user.auth_token); - let data: Vec = test::read_body_json(resp).await; + let resp = request_auth!(app, GET, "/users/@me/activity/data", user.auth_token); + let data: Vec = body_to_json(resp).await; - assert!(!data.is_empty(), "Session should be saved after a flush"); + assert!(data.is_empty(), "0 duration session should not be saved"); - let resp = request!(app, addr, delete, "/users/@me/delete", body); + let resp = request!(app, DELETE, "/users/@me/delete", body); assert!(resp.status().is_success(), "Failed to delete user"); } -#[actix_web::test] -async fn hidden_works() { - let app = test::init_service(App::new().configure(init_test_services)).await; - let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 80u16); +#[tokio::test] +async fn hidden_project() { + let mut app = create_test_router().into_service(); let body = json!({"username": "activeuser3", "password": "password"}); - let resp = request!(app, addr, post, "/auth/register", body); - let user: NewUserIdentity = test::read_body_json(resp).await; + let resp = request!(app, POST, "/auth/register", body); + let user: NewUserIdentity = body_to_json(resp).await; let heartbeat = HeartBeat { hostname: Some(String::from("nsa-supercomputer")), @@ -190,56 +143,52 @@ async fn hidden_works() { hidden: Some(true), }; - let resp = request_auth!( - app, - addr, - post, - "/activity/update", - user.auth_token, - heartbeat + let resp = request_auth!(app, POST, "/activity/update", user.auth_token, heartbeat); + assert!( + resp.status().is_success(), + "Sending heartbeat should succeed" ); + + tokio::time::sleep(Duration::from_secs(2)).await; + + let resp = request_auth!(app, POST, "/activity/update", user.auth_token, heartbeat); assert!( resp.status().is_success(), "Sending heartbeat should succeed" ); - let resp = request_auth!(app, addr, get, "/users/@me/activity/data", user.auth_token); - let data: Vec = test::read_body_json(resp).await; + let resp = request_auth!(app, GET, "/users/@me/activity/data", user.auth_token); + let data: Vec = body_to_json(resp).await; assert!(data.is_empty(), "No session should exist"); - let resp = request_auth!(app, addr, post, "/activity/flush", user.auth_token); + let resp = request_auth!(app, POST, "/activity/flush", user.auth_token); assert!(resp.status().is_success(), "Flushing should work"); - let resp = request!(app, addr, post, "/auth/securedaccess", body); - assert!( - resp.status().is_success(), - "Getting secured access token failed" - ); - let sat: SecuredAccessTokenResponse = test::read_body_json(resp).await; - let change = json!({"public_profile": true}); - let resp = request_auth!(app, addr, post, "/account/settings", sat.token, change); + let resp = request_auth!(app, POST, "/account/settings", user.auth_token, change); assert!(resp.status().is_success(), "Making profile public failed"); let resp = request!( app, - addr, - get, + GET, "/users/activeuser3/activity/data", user.auth_token ); - let data: Vec = test::read_body_json(resp).await; + let data: Vec = body_to_json(resp).await; - assert!(!data.is_empty(), "Session should be saved after a flush"); + assert!( + !data.is_empty(), + "Session with non-zero duration should be saved" + ); // Print the actual value of the project name to see what it is assert!( data[0].get("project_name").unwrap_or(&json!("not_hidden")) == &json!("hidden"), "Activity project name should be empty string" ); - let resp = request!(app, addr, delete, "/users/@me/delete", body); + let resp = request!(app, DELETE, "/users/@me/delete", body); assert!(resp.status().is_success(), "Failed to delete user"); } diff --git a/src/tests/auth.rs b/src/tests/auth.rs index bdf7a20..e029d9b 100644 --- a/src/tests/auth.rs +++ b/src/tests/auth.rs @@ -1,94 +1,68 @@ -use std::net::{IpAddr, Ipv4Addr, SocketAddr}; - -use actix_web::test::{self, TestRequest}; use serde_json::json; use super::{macros::*, *}; -use crate::models::{NewUserIdentity, SecuredAccessTokenResponse, SelfUser}; +use crate::models::{NewUserIdentity, SelfUser}; -#[actix_web::test] +#[tokio::test] async fn register_and_delete() { - let app = test::init_service(App::new().configure(init_test_services)).await; - let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 80u16); + let mut app = create_test_router().into_service(); + let body = json!({"username": "testuser", "password": "password"}); - let resp = request!(app, addr, post, "/auth/register", body); + let resp = request!(app, POST, "/auth/register", body); assert!(resp.status().is_success(), "Failed to create user"); - let user: NewUserIdentity = test::read_body_json(resp).await; + let user: NewUserIdentity = body_to_json(resp).await; - let resp = request!(app, addr, post, "/auth/register", body); + let resp = request!(app, POST, "/auth/register", body); assert!(resp.status().is_client_error(), "Usernames must be unique"); - let resp = request_auth!(app, addr, get, "/users/@me", user.auth_token); + let resp = request_auth!(app, GET, "/users/@me", user.auth_token); assert!( resp.status().is_success(), "Authentication token should work" ); - let resp = request!(app, addr, delete, "/users/@me/delete", body); + let resp = request!(app, DELETE, "/users/@me/delete", body); assert!(resp.status().is_success(), "Failed to delete user"); - let resp = request!(app, addr, post, "/auth/login", body); + let resp = request!(app, POST, "/auth/login", body); assert!(resp.status().is_client_error(), "User should be deleted") } -#[actix_web::test] +#[tokio::test] async fn login_change_username_and_password() { - let app = test::init_service(App::new().configure(init_test_services)).await; + let mut app = create_test_router().into_service(); let body = json!({"username": "testuser2", "password": "password"}); - let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 80u16); - let resp = request!(app, addr, post, "/auth/register", body); + let resp = request!(app, POST, "/auth/register", body); assert!(resp.status().is_success(), "Failed to create user"); - let user: NewUserIdentity = test::read_body_json(resp).await; + let user: NewUserIdentity = body_to_json(resp).await; - let resp = request!(app, addr, post, "/auth/login", body); + let resp = request!(app, POST, "/auth/login", body); assert!(resp.status().is_success(), "Login failed"); - let login_user: SelfUser = test::read_body_json(resp).await; + let login_user: SelfUser = body_to_json(resp).await; assert_eq!( user.auth_token, login_user.auth_token, "Auth tokens should be equal" ); - let resp = request!(app, addr, post, "/auth/securedaccess", body); - assert!( - resp.status().is_success(), - "Getting secured access token failed" - ); - - let sat: SecuredAccessTokenResponse = test::read_body_json(resp).await; - let change_request = json!({ "new": "testuser3" }); let resp = request_auth!( app, - addr, - post, - "/auth/changeusername", + POST, + "/auth/change-username", user.auth_token, change_request ); - assert!( - resp.status().is_client_error(), - "Auth token is not secured access token" - ); - - let resp = request_auth!( - app, - addr, - post, - "/auth/changeusername", - sat.token, - change_request - ); assert!(resp.status().is_success(), "Username change failed"); - let resp = request_auth!(app, addr, get, "/users/@me", user.auth_token); - let renamed_user: serde_json::Value = test::read_body_json(resp).await; + let resp = request_auth!(app, GET, "/users/@me", user.auth_token); + let renamed_user: serde_json::Value = body_to_json(resp).await; assert_eq!( renamed_user["username"], change_request["new"], "Username not changed" @@ -101,9 +75,8 @@ async fn login_change_username_and_password() { let resp = request_auth!( app, - addr, - post, - "/auth/changepassword", + POST, + "/auth/change-password", user.auth_token, pw_request ); @@ -111,26 +84,25 @@ async fn login_change_username_and_password() { let new_body = json!({"username": "testuser3", "password": "password1"}); - let resp = request!(app, addr, post, "/auth/login", new_body); + let resp = request!(app, POST, "/auth/login", new_body); assert!(resp.status().is_success(), "Password not changed"); - let resp = request!(app, addr, delete, "/users/@me/delete", new_body); + let resp = request!(app, DELETE, "/users/@me/delete", new_body); assert!(resp.status().is_success(), "Failed to delete user"); } -#[actix_web::test] +#[tokio::test] async fn invalid_usernames_and_passwords_are_rejected() { - let app = test::init_service(App::new().configure(init_test_services)).await; - - let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 80u16); + let mut app = create_test_router().into_service(); let body = json!({"username": "invalid[$$]", "password": "password"}); - let resp = request!(app, addr, post, "/auth/register", body); + let resp = request!(app, POST, "/auth/register", body); + assert!( resp.status().is_client_error(), "Invalid username should fail" ); - let resp_body: serde_json::Value = test::read_body_json(resp).await; + let resp_body: serde_json::Value = body_to_json(resp).await; assert!(resp_body["error"] .as_str() @@ -139,12 +111,12 @@ async fn invalid_usernames_and_passwords_are_rejected() { .contains("username")); let body = json!({"username": "validusername", "password": "short"}); - let resp = request!(app, addr, post, "/auth/register", body); + let resp = request!(app, POST, "/auth/register", body); assert!( resp.status().is_client_error(), "Too short password should fail" ); - let resp_body: serde_json::Value = test::read_body_json(resp).await; + let resp_body: serde_json::Value = body_to_json(resp).await; assert!(resp_body["error"] .as_str() diff --git a/src/tests/friends.rs b/src/tests/friends.rs index db83f5f..64842f6 100644 --- a/src/tests/friends.rs +++ b/src/tests/friends.rs @@ -1,62 +1,41 @@ -use std::net::{IpAddr, Ipv4Addr, SocketAddr}; - -use actix_web::test::{self, TestRequest}; use serde_json::json; use super::{macros::*, *}; use crate::models::NewUserIdentity; -#[actix_web::test] +#[tokio::test] async fn adding_friends_works() { - let app = test::init_service(App::new().configure(init_test_services)).await; + let mut app = create_test_router().into_service(); let f1_body = json!({"username": "friend1", "password": "password"}); let f2_body = json!({"username": "friend2", "password": "password"}); - let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 80u16); - let other_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 2)), 80u16); - let resp = request!(app, addr, post, "/auth/register", f1_body); + let resp = request!(app, POST, "/auth/register", f1_body); assert!(resp.status().is_success(), "Failed to create user"); - let f1: NewUserIdentity = test::read_body_json(resp).await; + let f1: NewUserIdentity = body_to_json(resp).await; - let resp = request!(app, other_addr, post, "/auth/register", f2_body); + let resp = request!(app, POST, "/auth/register", f2_body); assert!(resp.status().is_success(), "Failed to create user"); - let f2: NewUserIdentity = test::read_body_json(resp).await; + let f2: NewUserIdentity = body_to_json(resp).await; - let resp = TestRequest::post() - .peer_addr(addr) - .uri("/friends/add") - .insert_header(("authorization", "Bearer ".to_owned() + &f1.auth_token)) - .set_payload(f2.friend_code.clone()) - .send_request(&app) - .await; + let friend_body = json!({"code": f2.friend_code.clone()}); + let resp = request_auth!(app, POST, "/friends/add", f1.auth_token, friend_body); + println!("{resp:?}"); assert!(resp.status().is_success(), "Adding friend works"); - let resp = TestRequest::post() - .peer_addr(addr) - .uri("/friends/add") - .insert_header(("authorization", "Bearer ".to_owned() + &f1.auth_token)) - .set_payload(f2.friend_code.clone()) - .send_request(&app) - .await; + let resp = request_auth!(app, POST, "/friends/add", f1.auth_token, friend_body); assert!(resp.status().is_client_error(), "Re-adding friend fails"); - let resp = TestRequest::post() - .peer_addr(addr) - .uri("/friends/add") - .insert_header(("authorization", "Bearer ".to_owned() + &f1.auth_token)) - .set_payload(f1.friend_code.clone()) - .send_request(&app) - .await; + let self_body = json!({"code": f1.friend_code.clone()}); + let resp = request_auth!(app, POST, "/friends/add", f1.auth_token, self_body); assert!(resp.status().is_client_error(), "Adding self fails"); let resp = request_auth!( app, - addr, - get, + GET, &format!("/users/{}/activity/data", &f1.username), f2.auth_token ); @@ -65,16 +44,16 @@ async fn adding_friends_works() { "Friends can see eachothers data" ); - let resp = request_auth!(app, addr, get, "/friends/list", f2.auth_token); + let resp = request_auth!(app, GET, "/friends/list", f2.auth_token); assert!(resp.status().is_success(), "Getting friends-list works"); - let friends: Vec = test::read_body_json(resp).await; + let friends: Vec = body_to_json(resp).await; assert_eq!(friends.len(), 1, "Friend appears in friends-list"); - let resp = request!(app, addr, delete, "/users/@me/delete", f1_body); + let resp = request!(app, DELETE, "/users/@me/delete", f1_body); assert!(resp.status().is_success(), "Failed to delete user"); - let resp = request!(app, addr, delete, "/users/@me/delete", f2_body); + let resp = request!(app, DELETE, "/users/@me/delete", f2_body); assert!(resp.status().is_success(), "Failed to delete user"); } diff --git a/src/tests/leaderboards.rs b/src/tests/leaderboards.rs index 099c7dd..003322c 100644 --- a/src/tests/leaderboards.rs +++ b/src/tests/leaderboards.rs @@ -1,58 +1,39 @@ -use std::net::{IpAddr, Ipv4Addr, SocketAddr}; - -use actix_web::test::{self, TestRequest}; use serde_json::json; use super::{macros::*, *}; use crate::{ - api::leaderboards::{LeaderboardInvite, LeaderboardName}, - models::{NewUserIdentity, PrivateLeaderboard, SecuredAccessTokenResponse}, + api::leaderboards::{LeaderboardCreateRequest, LeaderboardInvite}, + models::{NewUserIdentity, PrivateLeaderboard}, }; -#[actix_web::test] +#[tokio::test] async fn creation_joining_and_deletion() { - let app = test::init_service(App::new().configure(init_test_services)).await; + let mut app = create_test_router().into_service(); let owner_body = json!({"username": "leaderboardowner", "password": "password"}); let member_body = json!({"username": "leaderboardmember", "password": "password"}); - let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 80u16); - let addr2 = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 2)), 80u16); - let resp = request!(app, addr, post, "/auth/register", owner_body); + let resp = request!(app, POST, "/auth/register", owner_body); assert!(resp.status().is_success(), "Creating user failed"); - let owner: NewUserIdentity = test::read_body_json(resp).await; + let owner: NewUserIdentity = body_to_json(resp).await; - let resp = request!(app, addr2, post, "/auth/register", member_body); + let resp = request!(app, POST, "/auth/register", member_body); assert!(resp.status().is_success(), "Creating user failed"); - let member: NewUserIdentity = test::read_body_json(resp).await; + let member: NewUserIdentity = body_to_json(resp).await; - let create = LeaderboardName { + let create = LeaderboardCreateRequest { name: "board".to_string(), }; - let resp = request_auth!( - app, - addr, - post, - "/leaderboards/create", - owner.auth_token, - create - ); + let resp = request_auth!(app, POST, "/leaderboards/create", owner.auth_token, create); assert!(resp.status().is_success(), "Leaderboard creation failed"); - let created: serde_json::Value = test::read_body_json(resp).await; + let created: serde_json::Value = body_to_json(resp).await; - let resp = request_auth!( - app, - addr, - post, - "/leaderboards/create", - owner.auth_token, - create - ); + let resp = request_auth!(app, POST, "/leaderboards/create", owner.auth_token, create); assert!( resp.status().is_client_error(), @@ -63,63 +44,42 @@ async fn creation_joining_and_deletion() { invite: created["invite_code"].as_str().unwrap().to_string(), }; - let resp = request_auth!( - app, - addr, - post, - "/leaderboards/join", - member.auth_token, - invite - ); + let resp = request_auth!(app, POST, "/leaderboards/join", member.auth_token, invite); assert!(resp.status().is_success(), "Joining leaderboard failed"); - let resp = request_auth!( - app, - addr, - post, - "/leaderboards/join", - owner.auth_token, - invite - ); + let resp = request_auth!(app, POST, "/leaderboards/join", owner.auth_token, invite); assert!( resp.status().is_client_error(), "Trying to re-join a leaderboard should fail" ); - let resp = request_auth!(app, addr, get, "/leaderboards/board", member.auth_token); + let resp = request_auth!(app, GET, "/leaderboards/board", member.auth_token); assert!(resp.status().is_success(), "Getting leaderboard failed"); - let board: PrivateLeaderboard = test::read_body_json(resp).await; + let board: PrivateLeaderboard = body_to_json(resp).await; assert_eq!( board.members.len(), 2, "Leaderboard member count should be 2" ); - let resp = request!(app, addr, post, "/auth/securedaccess", owner_body); - assert!( - resp.status().is_success(), - "Getting secured access token failed" - ); - let sat: SecuredAccessTokenResponse = test::read_body_json(resp).await; - - let resp = request_auth!(app, addr, delete, "/leaderboards/board", sat.token); + let resp = request_auth!(app, DELETE, "/leaderboards/board", owner.auth_token); assert!(resp.status().is_success(), "Leaderboards deletion failed"); - let resp = request_auth!(app, addr, get, "/leaderboards/board", member.auth_token); + let resp = request_auth!(app, GET, "/leaderboards/board", member.auth_token); assert!( resp.status().is_client_error(), "Leaderboard should be deleted" ); - let resp = request!(app, addr, delete, "/users/@me/delete", owner_body); + let resp = request!(app, DELETE, "/users/@me/delete", owner_body); assert!(resp.status().is_success(), "Failed to delete user"); - let resp = request!(app, addr, delete, "/users/@me/delete", member_body); + let resp = request!(app, DELETE, "/users/@me/delete", member_body); assert!(resp.status().is_success(), "Failed to delete user"); } diff --git a/src/tests/macros.rs b/src/tests/macros.rs index 5ec0209..d1d1ebf 100644 --- a/src/tests/macros.rs +++ b/src/tests/macros.rs @@ -1,38 +1,62 @@ macro_rules! request { - ($app:expr, $addr:expr, $method:tt, $uri:expr) => { - TestRequest::$method() - .peer_addr($addr) - .uri($uri) - .send_request(&$app) - .await + ($app:ident, $method:tt, $uri:expr) => { + tower::Service::call( + ServiceExt::>::ready(&mut $app).await.unwrap(), + Request::builder() + .uri($uri) + .method(http::Method::$method) + .extension(axum::extract::ConnectInfo(TEST_ADDR)) + .body(Body::empty()) + .unwrap(), + ) + .await + .unwrap() }; - ($app:expr, $addr:expr, $method:tt, $uri:expr, $body:expr) => { - TestRequest::$method() - .peer_addr($addr) - .uri($uri) - .set_json(&$body) - .send_request(&$app) - .await + ($app:ident, $method:tt, $uri:expr, $body:expr) => { + tower::Service::call( + ServiceExt::>::ready(&mut $app).await.unwrap(), + Request::builder() + .uri($uri) + .method(http::Method::$method) + .header(http::header::CONTENT_TYPE, mime::APPLICATION_JSON.as_ref()) + .extension(axum::extract::ConnectInfo(TEST_ADDR)) + .body(Body::from(serde_json::to_vec(&$body).unwrap())) + .unwrap(), + ) + .await + .unwrap() }; } macro_rules! request_auth { - ($app:expr, $addr:expr, $method:tt, $uri:expr, $token:expr) => { - TestRequest::$method() - .peer_addr($addr) - .uri($uri) - .insert_header(("authorization", "Bearer ".to_owned() + &$token)) - .send_request(&$app) - .await + ($app:expr, $method:tt, $uri:expr, $token:expr) => { + tower::Service::call( + ServiceExt::>::ready(&mut $app).await.unwrap(), + Request::builder() + .uri($uri) + .method(http::Method::$method) + .header("authorization", "Bearer ".to_owned() + &$token) + .extension(axum::extract::ConnectInfo(TEST_ADDR)) + .body(Body::empty()) + .unwrap(), + ) + .await + .unwrap() }; - ($app:expr, $addr:expr, $method:tt, $uri:expr, $token:expr, $body:expr) => { - TestRequest::$method() - .peer_addr($addr) - .uri($uri) - .set_json(&$body) - .insert_header(("authorization", "Bearer ".to_owned() + &$token)) - .send_request(&$app) - .await + ($app:expr, $method:tt, $uri:expr, $token:expr, $body:expr) => { + tower::Service::call( + ServiceExt::>::ready(&mut $app).await.unwrap(), + Request::builder() + .uri($uri) + .method(http::Method::$method) + .header(http::header::CONTENT_TYPE, "application/json") + .header("authorization", "Bearer ".to_owned() + &$token) + .extension(axum::extract::ConnectInfo(TEST_ADDR)) + .body(Body::from(serde_json::to_vec(&$body).unwrap())) + .unwrap(), + ) + .await + .unwrap() }; } diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 48a8da9..245df0e 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -1,4 +1,7 @@ +use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4}; + // TODO add tests for oauth and improve test coverage +use http_body_util::BodyExt; mod account; mod activity; mod auth; @@ -6,125 +9,54 @@ mod friends; mod leaderboards; mod macros; -use std::{num::NonZeroU32, sync::Arc}; - -use actix_web::{ - http::StatusCode, - test, web, - web::{Data, ServiceConfig}, - App, -}; -use governor::{Quota, RateLimiter}; +use axum::{body::Body, extract::connect_info::MockConnectInfo, response::Response, Router}; +use http::{Request, StatusCode}; +use serde::de::DeserializeOwned; +use tower::ServiceExt; // NOTE: We would like to use diesels Connection::begin_test_transaction // But cannot use them because our database uses transactions to implement // some of the routes and there cannot exists transactions within transactions :'( -use crate::database::Database; - -// FIXME: There is quite a lot of duplicate code from main -// in this function, perhaps these functions could be unified somehow. -fn init_test_services(cfg: &mut ServiceConfig) { - let db_url = - std::env::var("TEST_DATABASE").expect("TEST_DATABASE not set, refusing to run tests"); +use crate::create_router_with_openapi; - let ratelimiter = Arc::new( - RateLimiter::keyed(Quota::per_minute(NonZeroU32::new(500_u32).unwrap())).with_middleware(), - ); +const TEST_ADDR: SocketAddr = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 3000)); - let heartbeat_store = Data::new(crate::api::activity::HeartBeatMemoryStore::new()); +async fn body_to_json(response: Response) -> T { + let body = response.into_body().collect().await.unwrap().to_bytes(); - let secured_access_token_storage = Data::new(crate::SecuredAccessTokenStorage::new()); - - #[cfg(feature = "testausid")] - let client = crate::Client::new(); - - let cors = crate::Cors::default() - .allow_any_origin() - .allowed_methods(vec!["GET", "POST", "DELETE"]) - .allowed_headers(vec![ - http::header::AUTHORIZATION, - http::header::ACCEPT, - http::header::CONTENT_TYPE, - ]) - .max_age(3600); - let query_config = crate::QueryConfig::default().error_handler(|err, _| match err { - crate::QueryPayloadError::Deserialize(e) => { - crate::ErrorBadRequest(json!({ "error": e.to_string() })) - } - _ => unreachable!(), - }); + serde_json::from_slice(&body).unwrap() +} - cfg.service( - web::scope("") - .app_data(Data::new(crate::RegisterLimiter { - limit_by_peer_ip: false, - storage: crate::DashMap::new(), - })) - .app_data(Data::new(Database::new(db_url))) - .app_data(query_config) - .app_data(Data::clone(&secured_access_token_storage)) - .wrap(cors) - .service(crate::api::health) - .service(crate::api::auth::register) - .service({ - let scope = web::scope("") - .wrap(crate::AuthMiddleware) - .wrap(crate::TestaustimeRateLimiter { - limiter: Arc::clone(&ratelimiter), - use_peer_addr: false, - bypass_token: String::from("balls"), - }) - .service({ - web::scope("/activity") - .service(crate::api::activity::update) - .service(crate::api::activity::delete) - .service(crate::api::activity::flush) - .service(crate::api::activity::rename_project) - }) - .service(crate::api::auth::login) - .service(crate::api::auth::regenerate) - .service(crate::api::auth::changeusername) - .service(crate::api::auth::changepassword) - .service(crate::api::auth::get_secured_access_token) - .service(crate::api::account::change_settings) - .service(crate::api::friends::add_friend) - .service(crate::api::friends::get_friends) - .service(crate::api::friends::regenerate_friend_code) - .service(crate::api::friends::remove) - .service(crate::api::users::my_profile) - .service(crate::api::users::get_activities) - .service(crate::api::users::get_current_activity) - .service(crate::api::users::delete_user) - .service(crate::api::users::my_leaderboards) - .service(crate::api::users::get_activity_summary) - .service(crate::api::leaderboards::create_leaderboard) - .service(crate::api::leaderboards::get_leaderboard) - .service(crate::api::leaderboards::join_leaderboard) - .service(crate::api::leaderboards::leave_leaderboard) - .service(crate::api::leaderboards::delete_leaderboard) - .service(crate::api::leaderboards::promote_member) - .service(crate::api::leaderboards::demote_member) - .service(crate::api::leaderboards::kick_member) - .service(crate::api::leaderboards::regenerate_invite) - .service(crate::api::search::search_public_users) - .service(crate::api::stats::stats); - #[cfg(feature = "testausid")] - { - scope.service(crate::api::oauth::callback) - } - }), - ) - .app_data(Data::clone(&heartbeat_store)); - #[cfg(feature = "testausid")] - { - cfg.app_data(Data::new(client)); - } +fn create_test_router() -> Router { + let config = crate::TestaustimeConfig { + bypass_token: "0000".to_string(), + ratelimit_by_peer_ip: true, + max_requests_per_min: 30, + max_registers_per_hour: 5, + address: "localhost:3000".to_string(), + database_url: std::env::var("TEST_DATABASE").expect("TEST_DATABASE not defined"), + allowed_origin: "".to_string(), + mail_server: "".to_string(), + mail_user: "".to_string(), + mail_password: "".to_string(), + }; + + create_router_with_openapi(&config) + .0 + .layer(MockConnectInfo(SocketAddr::from(([127, 0, 0, 1], 3000)))) } -#[actix_web::test] +#[tokio::test] async fn health() { - let app = test::init_service(App::new().configure(init_test_services)).await; - let req = test::TestRequest::with_uri("/health").to_request(); - let resp = test::call_service(&app, req).await; - assert_eq!(resp.status(), StatusCode::OK) + let res = create_test_router() + .oneshot( + Request::builder() + .uri("/health") + .body(Body::empty()) + .unwrap(), + ) + .await + .unwrap(); + + assert_eq!(res.status(), StatusCode::OK) } diff --git a/src/utils.rs b/src/utils.rs index f2b5cdb..43b23f7 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,12 +1,13 @@ use std::collections::HashMap; use itertools::Itertools; -use rand::{distributions::Alphanumeric, thread_rng, Rng}; +use lettre::Address; +use rand::{distr::Alphanumeric, rng, Rng}; use crate::models::CodingActivity; -pub fn generate_token() -> String { - thread_rng() +pub fn generate_auth_token() -> String { + rng() .sample_iter(&Alphanumeric) .take(32) .map(char::from) @@ -14,13 +15,21 @@ pub fn generate_token() -> String { } pub fn generate_friend_code() -> String { - thread_rng() + rng() .sample_iter(&Alphanumeric) .take(24) .map(char::from) .collect() } +pub fn generate_password_reset_token() -> String { + rng() + .sample_iter(&Alphanumeric) + .take(48) + .map(char::from) + .collect() +} + pub fn group_by_language(iter: impl Iterator) -> HashMap { iter.map(|d| { ( @@ -31,3 +40,7 @@ pub fn group_by_language(iter: impl Iterator) -> HashMap< .into_grouping_map() .sum() } + +pub fn validate_email(email: &str) -> bool { + email.parse::
().is_ok() +}