Compare commits

...

14 Commits

Author SHA1 Message Date
Daniel García e45dab2fa2
Merge branch 'main' into passkey-login 2 days ago
Daniel García ec005eba90
Resend the verification email on passkey login 2 days ago
Mathijs van Veluw dbd7829ed1
Misc updates and fixes (#8006) 3 days ago
Daniel García b91cab3c24
Update web vault to v2026.11.0, Playwright tests and dependencies (#8002) 4 days ago
Daniel García b12874bd83
Align several API responses and request checks with upstream (#8001) 4 days ago
Steven Haigh 07c6b00da7
Support IPC on Web UI for sync (un)lock (#8000) 4 days ago
Tom 384fe6b442
Add the Autotype GA policy (policy 23) (#7994) 4 days ago
Timshel 6f7a7f7034
Improve Playwright tests (#7752) 5 days ago
maximilize cdf2035433
Do not fail login when push device registration fails (#7378) 5 days ago
Timshel 010c269e37
Improve and expand kdf_upgrade (#7855) 5 days ago
Tom c6e7da4b5c
Add the Send controls policy (policy 21) (#7519) 5 days ago
Steven Haigh 0a4909cfe0
Start support for sync (un)lock in 2026.11.0 onwards (#7986) 5 days ago
Dan Molik 2c9b7c06a9
Return an error instead of panicking on invalid attachment/cipher input (#7989) 5 days ago
Mathijs van Veluw baff1cabae
Misc updates (#7980) 1 week ago
  1. 14
      .env.template
  2. 3
      .github/workflows/build.yml
  3. 12
      .github/workflows/release.yml
  4. 7
      .github/workflows/sdk-live-tests.yml
  5. 2
      .github/workflows/trivy.yml
  6. 2
      .github/workflows/typos.yml
  7. 2
      .github/workflows/zizmor.yml
  8. 2
      .pre-commit-config.yaml
  9. 5
      .typos.toml
  10. 250
      Cargo.lock
  11. 10
      Cargo.toml
  12. 1
      THREAT_MODEL.md
  13. 4
      docker/DockerSettings.yaml
  14. 12
      docker/Dockerfile.alpine
  15. 12
      docker/Dockerfile.debian
  16. 2
      playwright/README.md
  17. 6
      playwright/compose/playwright/Dockerfile
  18. 2
      playwright/compose/warden/build.sh
  19. 16
      playwright/docker-compose.yml
  20. 8
      playwright/global-utils.ts
  21. 1398
      playwright/package-lock.json
  22. 10
      playwright/package.json
  23. 5
      playwright/playwright.config.ts
  24. 2
      playwright/test.env
  25. 2
      playwright/tests/collection.spec.ts
  26. 21
      playwright/tests/cyphers.spec.ts
  27. 12
      playwright/tests/organization.smtp.spec.ts
  28. 4
      playwright/tests/secrets.spec.ts
  29. 4
      playwright/tests/send.spec.ts
  30. 19
      playwright/tests/setups/orgs.ts
  31. 4
      playwright/tests/sso_organization.spec.ts
  32. 4
      src/api/admin.rs
  33. 129
      src/api/core/accounts.rs
  34. 63
      src/api/core/ciphers.rs
  35. 78
      src/api/core/organizations.rs
  36. 59
      src/api/core/sends.rs
  37. 4
      src/api/core/two_factor/authenticator.rs
  38. 4
      src/api/core/two_factor/duo.rs
  39. 4
      src/api/core/two_factor/email.rs
  40. 5
      src/api/core/two_factor/mod.rs
  41. 22
      src/api/core/two_factor/webauthn.rs
  42. 5
      src/api/core/two_factor/yubikey.rs
  43. 14
      src/api/core/webauthn_login.rs
  44. 30
      src/api/icons.rs
  45. 64
      src/api/identity.rs
  46. 4
      src/api/mod.rs
  47. 69
      src/config.rs
  48. 21
      src/db/models/auth_request.rs
  49. 6
      src/db/models/collection.rs
  50. 56
      src/db/models/org_policy.rs
  51. 289
      src/db/models/org_policy/send_controls.rs
  52. 6
      src/db/models/organization.rs
  53. 33
      src/db/models/user.rs
  54. 5
      src/sso_client.rs
  55. 664
      src/static/global_domains.json
  56. BIN
      src/static/images/fallback-icon.png
  57. 4
      src/static/scripts/datatables.css
  58. 80
      src/static/scripts/datatables.js
  59. 8
      src/util.rs

14
.env.template

@ -338,6 +338,8 @@
## "local" accepts it from any non global address, which covers a reverse proxy running on the same
## host or container network. Use "all" to accept it from anywhere, or list the addresses of your
## proxy as IPs and CIDR ranges if it connects from a public address.
## Non global addresses include the 6to4, Teredo and local-use NAT64 ranges, which can carry clients from anywhere:
## if those can reach Vaultwarden, list your proxy instead of using "local", or those clients can set the header.
## For a list header like X-Forwarded-For, the client IP is the rightmost address that isn't one of
## these proxies, so with several proxies in a row (a CDN in front of nginx, for example) list all of them.
# IP_HEADER_TRUSTED_PROXIES=local
@ -383,6 +385,7 @@
## Enabling this will cause the internal HTTP client to refuse to connect to any non-global IP address.
## Useful to secure your internal environment: See https://en.wikipedia.org/wiki/Reserved_IP_addresses for a list of IPs which it will block
## Requests through an outbound proxy (HTTP_PROXY, HTTPS_PROXY or ALL_PROXY) aren't checked, because the proxy resolves the names.
# HTTP_REQUEST_BLOCK_NON_GLOBAL_IPS=true
## Client Settings
@ -406,6 +409,8 @@
## - "pm-30529-webauthn-related-origins": Allow passkeys stored in the vault to be used on related origins listed in a site's /.well-known/webauthn file (Browser >= 2026.2.0)
## - "pm-32009-new-item-types": Enable new item types: Bank Account, Driver's License, and Passport (Clients >= 2026.4.0)
## - "pm-34171-card-scanner": Enable the new card scanner feature on mobile (Android >= 2026.4.1, iOS >= 2026.4.1)
## - "pm-31885-send-controls": Use the Send controls policy, which replaces the Remove Send and Send options policies (Web vault >= 2026.4.0, Android >= 2026.8.0, iOS >= 2026.7.1)
## The web vault, browser, desktop and CLI clients after 2026.10 always use it, only older versions and the mobile apps still read this flag.
## - "enable-basic-auth-response": Enable HTTP Basic Auth autofill in the browser extension (Browser >= 2026.9.0)
## - "undetermined-cipher-scenario-logic": Enable the rewritten add/update login notification triggering logic in the browser extension (Browser >= 2026.2.0)
## - "biometrics-sdk-ipc": Enable biometric unlock over the SDK IPC framework (Desktop >= 2026.9.0, Browser >= 2026.9.0)
@ -415,6 +420,8 @@
## - "pm-27278-v2-password-registration": Register new accounts with v2 encryption. (Web >= 2026.6.4, Desktop/Browser/CLI >= 2026.7.0, Android >= 2026.4.1, iOS >= 2026.5.1)
## - "enable-account-encryption-v2-jit-password-registration": Give SSO users who set their master password on their first login v2 encryption. (Web >= 2026.1.1, Desktop/Browser/CLI >= 2026.1.0, Android >= 2026.4.1, iOS >= 2026.6.0)
## These two flags can't be undone: a v2 account stays v2, and it can only log in from clients that are 2026.10.1 or newer (2026.10.2 for the desktop app), so the versions above are only enough to create one.
## - "innovation-sprint-shared-unlock-part-2": Enable shared unlock between extension / web / desktop in >= 2026.11.0
## - "content-script-ipc-channel-framework": Enable shared unlock on the web UI in web builds >= 2026.11.0
# EXPERIMENTAL_CLIENT_FEATURE_FLAGS=
## Require new device emails. When a user logs in an email is required to be sent.
@ -520,7 +527,7 @@
## Enforce that the Single Org policy is enabled before setting the Reset Password policy
## Bitwarden enforces this by default. In Vaultwarden we encouraged to use multiple organizations because groups were not available.
## Setting this to true will enforce the Single Org Policy to be enabled before you can enable the Reset Password policy.
# ENFORCE_SINGLE_ORG_WITH_RESET_PW_POLICY=false
# ENFORCE_SINGLE_ORG_WITH_RESET_PW_POLICY=true
## Prefer IPv6 (AAAA) resolving
## This settings configures the DNS resolver to resolve IPv6 first, and if not available try IPv4
@ -641,6 +648,11 @@
## Keep in mind that when a server drifts out of time, valid codes could be marked as invalid.
## In any case, if a code has been used it can not be used again, also codes which predates it will be invalid.
# AUTHENTICATOR_DISABLE_TIME_DRIFT=false
##
## WebAuthn Settings
## Enable WebAuthn 2FA prefer user verification
## Sets user verification to preferred instead of discouraged, improving compatibility with some security keys.
WEBAUTHN_2FA_PREFER_USER_VERIFICATION=false
## Passkey login extra origins
## Origins that may log in with a passkey besides the vault and the official Chromium extensions (Chrome Web Store,

3
.github/workflows/build.yml

@ -120,6 +120,9 @@ jobs:
# Set as the default toolchain
rustup default "${RUST_TOOLCHAIN}"
# rust-cache keys on every installed toolchain, so the runner image's stable would change the key on each image update
rustup toolchain uninstall stable
# Show environment
- name: "Show environment"
run: |

12
.github/workflows/release.yml

@ -106,7 +106,7 @@ jobs:
# Login to Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
@ -121,7 +121,7 @@ jobs:
# Login to GitHub Container Registry
- name: Login to GitHub Container Registry
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
@ -137,7 +137,7 @@ jobs:
# Login to Quay.io
- name: Login to Quay.io
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
@ -272,7 +272,7 @@ jobs:
# Login to Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
@ -287,7 +287,7 @@ jobs:
# Login to GitHub Container Registry
- name: Login to GitHub Container Registry
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
@ -303,7 +303,7 @@ jobs:
# Login to Quay.io
- name: Login to Quay.io
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}

7
.github/workflows/sdk-live-tests.yml

@ -1,5 +1,8 @@
name: SDK live tests
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# Runs the live-server end-to-end tests of bitwarden/sdk-internal against this branch, see tools/sdk-live-tests/run.sh.
# By default it tests the latest @bitwarden/sdk-internal on npm, which the SDK publishes for every commit to its main
@ -104,6 +107,8 @@ jobs:
rustup target add wasm32-unknown-unknown
rustup component add rust-src
fi
# rust-cache keys on every installed toolchain, so the runner image's stable would change the key on each image update
rustup toolchain uninstall stable
# One cache per SDK source, so that neither restores the other's.
# Only save caches on main to save cache space.
@ -128,7 +133,7 @@ jobs:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: "Setup Node"
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: sdk-internal/.nvmrc

2
.github/workflows/trivy.yml

@ -50,6 +50,6 @@ jobs:
severity: CRITICAL,HIGH
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
with:
sarif_file: 'trivy-results.sarif'

2
.github/workflows/typos.yml

@ -23,4 +23,4 @@ jobs:
# When this version is updated, do not forget to update this in `.pre-commit-config.yaml` too
- name: Spell Check Repo
uses: crate-ci/typos@7f9d0819ca1c008ade73f4b41fa9d258d48f605b # v1.51.1
uses: crate-ci/typos@276087d9a4f06398b3e04825487805e2d7375888 # v1.52.2

2
.github/workflows/zizmor.yml

@ -24,7 +24,7 @@ jobs:
persist-credentials: false
- name: Run zizmor
uses: zizmorcore/zizmor-action@53290badfa369cb0bf7ad16342cb62c2fa47ac7b # v0.8.0
uses: zizmorcore/zizmor-action@45d7276c9ca790aabd705e31ca99c6185c3e76dd # v0.8.1
with:
# intentionally not scanning the entire repository,
# since it contains integration tests.

2
.pre-commit-config.yaml

@ -18,7 +18,7 @@ repos:
# When this version is updated, do not forget to update this in `.github/workflows/typos.yaml` too
- repo: https://github.com/crate-ci/typos
rev: 7f9d0819ca1c008ade73f4b41fa9d258d48f605b # v1.51.1
rev: 276087d9a4f06398b3e04825487805e2d7375888 # v1.52.2
hooks:
- id: typos
always_run: true

5
.typos.toml

@ -1,7 +1,8 @@
[files]
extend-exclude = [
".git/",
"playwright/",
".git/**",
"target/**",
"playwright/**",
"*.js", # Ignore all JavaScript files
"!admin*.js", # Except our own JavaScript files
]

250
Cargo.lock

@ -10,11 +10,12 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
[[package]]
name = "ahash"
version = "0.8.12"
version = "0.8.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75"
checksum = "0fca89247609239eeb6915e6991111866b92d7b31025e69302bbf430cc4d2c38"
dependencies = [
"cfg-if",
"getrandom 0.4.3",
"once_cell",
"version_check",
"zerocopy",
@ -61,9 +62,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.104"
version = "1.0.105"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
checksum = "2cb931c189b85683d69a5cfad41d4d418671e1ac413dd209f3f2fc31e3cfd902"
[[package]]
name = "ar_archive_writer"
@ -159,9 +160,9 @@ dependencies = [
[[package]]
name = "async-compression"
version = "0.4.52"
version = "0.4.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ad47a740fb906fffdd891e8b6d5fde2511600f7bfaebd68939fa08a14999459"
checksum = "7bde8322bfc31ade96978b8d3c06be0fd60401192e7ddb9a0b2de5e215d22e61"
dependencies = [
"compression-codecs",
"compression-core",
@ -279,7 +280,7 @@ dependencies = [
"futures-core",
"futures-io",
"futures-lite",
"gloo-timers",
"gloo-timers 0.3.0",
"kv-log-macro",
"log",
"memchr",
@ -335,6 +336,12 @@ version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d2050892d4691cf110586070786712b504985a4d37ed64a9cd8a402718e1706"
[[package]]
name = "asyncband"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e53c31fb18f42e765610b2146531390e56966f601d8ffca530d292a34fe4218"
[[package]]
name = "atomic"
version = "0.6.1"
@ -474,9 +481,9 @@ dependencies = [
[[package]]
name = "aws-sdk-sts"
version = "1.127.0"
version = "1.128.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35d50661cd8816b7f23a652391c5b6f3645fce499e62e8fc5b3ed4145c5248f7"
checksum = "29c357588cdf8c9ae96c0d9930fff757f9b678d06b8f68d8e37a1278fe034912"
dependencies = [
"arc-swap",
"aws-credential-types",
@ -648,9 +655,9 @@ dependencies = [
[[package]]
name = "aws-smithy-types"
version = "1.9.4"
version = "1.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aff4bf014c512840b2bba80a20417b723cbd6a0a65c02e2d81f50b4268aedfc7"
checksum = "2085f9721fb3755821f8db7611a67ed15f4d6fdba6785b4db8ed7cd18eebee0f"
dependencies = [
"base64-simd",
"bytes",
@ -822,9 +829,9 @@ dependencies = [
[[package]]
name = "brotli-decompressor"
version = "6.3.2"
version = "6.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc031cd87c6529082b0b65c604e86af0ed7744841b17ccfe60b1e31fa606179e"
checksum = "664148598c930650998ef56df301329ffe7b4cdb02d49b2a3fca3bcaf2185bcb"
dependencies = [
"alloc-no-stdlib",
"alloc-stdlib",
@ -875,9 +882,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.11.2"
version = "1.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45"
checksum = "02f0e023adb368345ce0ca6cdfc0f24a06554468d0e8503e14a0841de79bfa69"
dependencies = [
"find-msvc-tools",
"jobserver",
@ -956,9 +963,9 @@ dependencies = [
[[package]]
name = "compression-codecs"
version = "0.4.47"
version = "0.4.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84f840cff84d10085260e460023934d0af699e71212b09b2a41452e8bd9cda43"
checksum = "5e41632c2efd201c62f1432f7cbee121b97878eab579da9d85676573d1fd33b9"
dependencies = [
"brotli",
"compression-core",
@ -997,21 +1004,20 @@ checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a"
[[package]]
name = "const-random"
version = "0.1.18"
version = "0.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359"
checksum = "d38d4bb3e79c716fd0330d8da84171b0135e59e01076e99f22b75a64c56e952c"
dependencies = [
"const-random-macro",
]
[[package]]
name = "const-random-macro"
version = "0.1.16"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e"
checksum = "d66bb491e9fc48cb3fed9d57df886880a751d540d645ebc86b6d9d35b8fa8457"
dependencies = [
"getrandom 0.2.17",
"once_cell",
"getrandom 0.4.3",
"tiny-keccak",
]
@ -1026,9 +1032,9 @@ dependencies = [
[[package]]
name = "cookie"
version = "0.18.2"
version = "0.18.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a373e3602691c3cdea496d2f0ee5935151e6168fe87739483c463db1b2f2f87"
checksum = "d55f2d6c30eeec7d5c6f98bd4395d4abb1895629eab97ee6522d340623615f8a"
dependencies = [
"percent-encoding",
"time",
@ -1121,9 +1127,9 @@ dependencies = [
[[package]]
name = "crc32fast"
version = "1.5.5"
version = "1.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64"
checksum = "fd9ae8fcb3ea71b0b26338b4ffb13006bb175de8fd07921089a906ce7e5e6945"
dependencies = [
"cfg-if",
]
@ -1894,9 +1900,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "form_urlencoded"
version = "1.2.2"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"
checksum = "afa489199eaffb1211795df1c6236ce1ad0d41a6fa45250add73e3b02420f06e"
dependencies = [
"percent-encoding",
]
@ -1990,6 +1996,10 @@ name = "futures-timer"
version = "3.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af43fadb8a98512d547e37b4e92e0ced13e205c061b87b4623eff01d918d6968"
dependencies = [
"gloo-timers 0.4.1",
"send_wrapper",
]
[[package]]
name = "futures-util"
@ -2090,6 +2100,18 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "gloo-timers"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4460540da666acdb5722b2a62ac47d18f627fcfc0c728d04dc7226b3f6d40a7"
dependencies = [
"futures-channel",
"futures-core",
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "governor"
version = "0.10.4"
@ -2213,9 +2235,9 @@ dependencies = [
[[package]]
name = "hashbrown"
version = "0.17.1"
version = "0.17.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
checksum = "735eaa21a6a5ffb2e84362faaeb90c05ba8e19797ca30428478cb6ea3a4921bc"
[[package]]
name = "heck"
@ -2409,9 +2431,9 @@ dependencies = [
[[package]]
name = "hyper"
version = "1.12.0"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c3e324da4c95177d6291d4c8730197c0d1822f8a9766814a4a44fa5ab797c9c"
checksum = "229c6ff5584df4c6becbfe00567128bac768c8cd32ebc8a8366bd81ed072e8f3"
dependencies = [
"atomic-waker",
"bytes",
@ -2622,7 +2644,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
dependencies = [
"equivalent",
"hashbrown 0.17.1",
"hashbrown 0.17.2",
"serde",
"serde_core",
]
@ -2687,9 +2709,9 @@ version = "0.2.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "175dc66334db3b9ab9985bf8b61cfed50dc16d20964bb47f9e479adcae984a7f"
dependencies = [
"jiff-core",
"jiff-static",
"jiff-tzdb-platform",
"jiff-core 0.1.8",
"jiff-static 0.2.46",
"jiff-tzdb-platform 0.1.3",
"js-sys",
"log",
"portable-atomic",
@ -2699,6 +2721,22 @@ dependencies = [
"windows-link",
]
[[package]]
name = "jiff"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "107f2e89536b6818514025f6787b0d94d819e54fe3b40365275fc753de485b3f"
dependencies = [
"jiff-core 1.0.2",
"jiff-static 1.0.3",
"jiff-tzdb-platform 1.0.0",
"log",
"portable-atomic",
"portable-atomic-util",
"serde_core",
"windows-link",
]
[[package]]
name = "jiff-core"
version = "0.1.8"
@ -2708,31 +2746,67 @@ dependencies = [
"log",
]
[[package]]
name = "jiff-core"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d44c923edf2bf456a982253f1a9ee1f6e89e421dffd0065d9b9a581da0def58f"
dependencies = [
"log",
]
[[package]]
name = "jiff-static"
version = "0.2.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7b1af7547d47354bc438d797e3854601bde8f8d185780c5ba4ab27afa54f1ba"
dependencies = [
"jiff-core",
"jiff-core 0.1.8",
"proc-macro2",
"quote",
"syn 2.0.119",
]
[[package]]
name = "jiff-static"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4996f71e569e3a3e32b925c28ef8f0027dc30bb1d594b33eeda409eea185f5c8"
dependencies = [
"jiff-core 1.0.2",
"proc-macro2",
"quote",
"syn 3.0.10",
]
[[package]]
name = "jiff-tzdb"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0980fca2cc272465bd60e82397607ba9f33add9e48defd77923301bbd03808f2"
[[package]]
name = "jiff-tzdb"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12e71a1b68a875a44a33bb7a1dd84392cb77145a3367a552a3cfe6a4f5cf3afc"
[[package]]
name = "jiff-tzdb-platform"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8"
dependencies = [
"jiff-tzdb",
"jiff-tzdb 0.1.10",
]
[[package]]
name = "jiff-tzdb-platform"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc65b284afcfa8f6cf189c7274c805505314a7ab975c60e1f548bff56525420e"
dependencies = [
"jiff-tzdb 1.0.0",
]
[[package]]
@ -3029,7 +3103,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec54a4ea92c533f8ed6b8c80dc4bbd60f5b578b173399d92f19bfb5a34bd99a3"
dependencies = [
"serde",
"toml 1.2.1+spec-1.1.0",
"toml 1.2.2+spec-1.1.0",
]
[[package]]
@ -3365,12 +3439,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33d5a635dfea36a7a0c3bbb2ca34c97af17f98dd69b0cdf31a1d436a346e0a12"
dependencies = [
"anyhow",
"asyncband",
"asyncband 0.7.4",
"base64 0.23.1",
"bytes",
"futures",
"http 1.5.0",
"jiff",
"jiff 0.2.46",
"log",
"md-5",
"percent-encoding",
@ -3855,9 +3929,9 @@ checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315"
[[package]]
name = "pin-project-lite"
version = "0.2.17"
version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
checksum = "c938015719552d665fd0553b90d96cd7ff58e83e4c061ca99e6bb78865a72752"
[[package]]
name = "pin-utils"
@ -3978,9 +4052,9 @@ dependencies = [
[[package]]
name = "pq-sys"
version = "0.7.8"
version = "0.7.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "297a95d6f2378891f949d9556723e15140e50d29eac07458dabcee8688995b1d"
checksum = "b3bc77e8957fcd07d9768dc26486b07e39339693e21d3c5564be908ef6911540"
dependencies = [
"libc",
"pkg-config",
@ -4325,12 +4399,15 @@ dependencies = [
[[package]]
name = "reqsign-aws-core"
version = "3.2.0"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d38c902d8ec745bd9eadd1abbcbe227f4c1fc2926b2ec8929f89234af3114500"
checksum = "163fc123fc7cf763a7c7f00f56825100e5dba5002c682eaa46f0bcd789d01bcd"
dependencies = [
"asyncband 0.8.0",
"bytes",
"form_urlencoded",
"futures",
"futures-timer",
"hex",
"http 1.5.0",
"log",
@ -4346,9 +4423,9 @@ dependencies = [
[[package]]
name = "reqsign-aws-v4"
version = "3.3.1"
version = "3.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "906bfd028f96bfe73fdb892ce26f3b3f99b4f30feb9bd024be58bd6657f68b2b"
checksum = "acf0c8db7ea8b38ef70375e273b4992227f8c2e57ee8f0df2201b41ccbf1d7c1"
dependencies = [
"bytes",
"http 1.5.0",
@ -4361,18 +4438,18 @@ dependencies = [
[[package]]
name = "reqsign-core"
version = "3.3.2"
version = "3.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85fed85c436b6b920e4b36310f699a77771a91e38ae483df48447bd7d162671c"
checksum = "a1eb4e857da46e242365c17ad0bc8ed2899d7c04b38add449c21a309b8776786"
dependencies = [
"anyhow",
"asyncband",
"asyncband 0.8.0",
"base64 0.23.1",
"bytes",
"hex",
"hmac 0.13.0",
"http 1.5.0",
"jiff",
"jiff 1.0.3",
"log",
"percent-encoding",
"sha1 0.11.0",
@ -4382,9 +4459,9 @@ dependencies = [
[[package]]
name = "reqsign-file-read-tokio"
version = "3.0.7"
version = "3.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "586a8e198057773f9616901fd723a4bc186812b9765bc0f20368661d6169d906"
checksum = "686019cebfbebec6a07da664ff3aece6c3214bb3537687aac6eb2da3d31b516f"
dependencies = [
"anyhow",
"reqsign-core",
@ -4486,9 +4563,9 @@ dependencies = [
[[package]]
name = "rocket"
version = "0.5.3"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a6f52722cade6c6423d6ad9ee5560a9ca2d888894f1bfef97f5b7f61c84f16b"
checksum = "b994aab1e1d2342ede2ee7a9be3aa18fc9eaa1c819d9a4b83cb6c5899f345bf8"
dependencies = [
"async-stream",
"async-trait",
@ -4524,9 +4601,9 @@ dependencies = [
[[package]]
name = "rocket_codegen"
version = "0.5.3"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0df92d0cfe50ffd2b125dc8f5aa6ecbfa85f9e5f87aeceb46ca2fed8260d4fb"
checksum = "45c73d9cca43eac063ffb1e7f6b2ba52c777d8c5e63dbc6268610e3c8e217154"
dependencies = [
"devise",
"glob",
@ -4542,9 +4619,9 @@ dependencies = [
[[package]]
name = "rocket_http"
version = "0.5.3"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92f626b274f1d3ade7e1162782e99dd920d04f797ea820ef75f3ffa5e8c2b78f"
checksum = "e87495dd15914c130bd1f90bba3c53f2b32535fc3b0203bf7a885c1259d973a3"
dependencies = [
"cookie",
"either",
@ -4886,6 +4963,12 @@ version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
[[package]]
name = "send_wrapper"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73"
[[package]]
name = "serde"
version = "1.0.229"
@ -5001,9 +5084,9 @@ dependencies = [
[[package]]
name = "serde_with"
version = "3.24.0"
version = "3.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df9adc193c780ef8f159aee8b61e2d5801aaa555e6eb0947fe45530ec506296f"
checksum = "56cb1ca7c93ae63d6439b5250f6b6b040f7e121f32e5dd2f5d523dd4149b3204"
dependencies = [
"base64 0.23.1",
"bs58",
@ -5011,7 +5094,8 @@ dependencies = [
"hex",
"indexmap 1.9.3",
"indexmap 2.14.2",
"jiff",
"jiff 0.2.46",
"jiff 1.0.3",
"schemars 0.9.0",
"schemars 1.2.3",
"serde_core",
@ -5022,9 +5106,9 @@ dependencies = [
[[package]]
name = "serde_with_macros"
version = "3.24.0"
version = "3.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e17bbc68e28663bbbb90df47e058aa7eda4fb445b89fe70457bb94fbccf6e49"
checksum = "cff15a7c864bbec77d9586ca6822bc7c369bdf19e9243134a62b0b51ce26b31f"
dependencies = [
"darling 0.24.1",
"proc-macro2",
@ -5623,9 +5707,9 @@ dependencies = [
[[package]]
name = "toml"
version = "1.2.1+spec-1.1.0"
version = "1.2.2+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5755c51863cdac711f1956baf8eb9588e060755f7d3c4c979e70ea1e1f32cd7"
checksum = "5426cb1b964690d913f6c5c1a1ae0b42f428ec506bb4d452876d7a209c9bca3b"
dependencies = [
"serde_core",
"serde_spanned 1.1.3",
@ -5668,9 +5752,9 @@ dependencies = [
[[package]]
name = "toml_parser"
version = "1.1.5+spec-1.1.0"
version = "1.1.6+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c"
checksum = "e6769c452d71ba30696c6b37770c439a9cc9110f47f7d5cdbeda79840ef5ea31"
dependencies = [
"winnow 1.0.5",
]
@ -5844,9 +5928,9 @@ dependencies = [
[[package]]
name = "ucd-trie"
version = "0.1.7"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971"
checksum = "8f20bdbfc9915686faa18fb5bbe8b4552778505defbf9f12289beefbc44092a6"
[[package]]
name = "uncased"
@ -5884,9 +5968,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]]
name = "url"
version = "2.5.8"
version = "2.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed"
checksum = "f00cd2407bb42c0ef17be88d4cf020f5cceffd121665bac9b8b9493a369b3b1a"
dependencies = [
"form_urlencoded",
"idna",
@ -6040,9 +6124,9 @@ checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64"
[[package]]
name = "walkdir"
version = "2.5.0"
version = "2.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
checksum = "b42e295b7452c4604982280d8586001fcad9b8b201cac67bca9771e7a7475403"
dependencies = [
"same-file",
"winapi-util",
@ -6626,18 +6710,18 @@ dependencies = [
[[package]]
name = "zerocopy"
version = "0.8.63"
version = "0.8.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8"
checksum = "ed43f3060383c64b000f3c630550aebdfa9d3b76d48de32390483dd2cc7e0865"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.8.63"
version = "0.8.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f"
checksum = "a5cbd820fe3e35fb38c83b6dc7e6b1618bc46e0cd10073ae94e8d52dc468d8b9"
dependencies = [
"proc-macro2",
"quote",
@ -6720,9 +6804,9 @@ dependencies = [
[[package]]
name = "zlib-rs"
version = "0.6.8"
version = "0.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112"
checksum = "aa76918995d776d9dd34d371030be228d021137449771493d56e29f77e4148ac"
[[package]]
name = "zmij"

10
Cargo.toml

@ -82,7 +82,7 @@ num-derive = "0.5.1"
bigdecimal = "0.4.11"
# Web framework
rocket = { version = "0.5.3", default-features = false, features = ["json", "tls"] }
rocket = { version = "0.5.4", default-features = false, features = ["json", "tls"] }
rocket_ws = { version = "0.2.0" }
# WebSockets libraries
@ -161,7 +161,7 @@ webauthn-rs-core = "0.5.5"
serde_cbor_2 = { version = "0.13.0", optional = true }
# Handling of URL's for WebAuthn and favicons
url = "2.5.8"
url = "2.5.9"
# Email libraries
lettre = { version = "0.11.24", default-features = false, features = [
@ -217,7 +217,7 @@ bytes = "1.12.2"
svg-hush = "0.9.7"
# Used for custom short lived cookie jar during favicon extraction
cookie = "0.18.2"
cookie = "0.18.3"
cookie_store = "0.22.1"
# Used by U2F, JWT and PostgreSQL
@ -270,8 +270,8 @@ aws-config = { version = "1.13.3", optional = true, default-features = false, fe
] }
aws-credential-types = { version = "1.3.1", optional = true }
aws-smithy-runtime-api = { version = "1.22.0", optional = true }
reqsign-aws-v4 = { version = "3.3.1", optional = true }
reqsign-core = { version = "3.3.2", optional = true }
reqsign-aws-v4 = { version = "3.5.0", optional = true }
reqsign-core = { version = "3.3.4", optional = true }
# Strip debuginfo from the release builds
# The debug symbols are to provide better panic traces

1
THREAT_MODEL.md

@ -81,6 +81,7 @@ These are intended behavior or outside this model. Several match upstream Bitwar
- Attacks that need a missing or misconfigured reverse proxy, such as one not sending `X-Forwarded-Proto` (it decides the admin cookie's `Secure` flag).
- Attacks that need another component to break its own specification, such as a NAT64 translator that forwards the `64:ff9b::/96` prefix to private addresses, against RFC 6052.
- Outbound requests to the SSO provider, Yubico server or S3 endpoint the operator configures, which skip the outbound filter and can be on the internal network.
- Requests sent through an outbound proxy (`HTTP_PROXY`, `HTTPS_PROXY` or `ALL_PROXY`). The proxy resolves names itself, so `HTTP_REQUEST_BLOCK_NON_GLOBAL_IPS` can't check where they go. Configure the proxy so it can't reach anything sensitive, or so it blocks internal addresses.
- File permissions in the data folder. Host security belongs to the operator.
- Attacks that need physical access to a user's device.
- Self-exploitation, where someone can only affect their own account, such as self-XSS or weak KDF settings they choose.

4
docker/DockerSettings.yaml

@ -1,6 +1,6 @@
---
vault_version: "v2026.10.1"
vault_image_digest: "sha256:7baaa7d5349742548b6c44e557c1512157b22010cdf314ccc399ffdcacb5eb52"
vault_version: "v2026.11.0"
vault_image_digest: "sha256:b3e7e1607a6a3c4521cd801d5e3e79ab201d27cb59bfd6e6bd204308b42dc7a9"
# Cross Compile Docker Helper Scripts v1.10.0
# We use the linux/amd64 platform shell scripts since there is no difference between the different platform scripts
# https://github.com/tonistiigi/xx | https://hub.docker.com/r/tonistiigi/xx/tags

12
docker/Dockerfile.alpine

@ -19,15 +19,15 @@
# - From https://hub.docker.com/r/vaultwarden/web-vault/tags,
# click the tag name to view the digest of the image it currently points to.
# - From the command line:
# $ docker pull docker.io/vaultwarden/web-vault:v2026.10.1
# $ docker image inspect --format "{{.RepoDigests}}" docker.io/vaultwarden/web-vault:v2026.10.1
# [docker.io/vaultwarden/web-vault@sha256:7baaa7d5349742548b6c44e557c1512157b22010cdf314ccc399ffdcacb5eb52]
# $ docker pull docker.io/vaultwarden/web-vault:v2026.11.0
# $ docker image inspect --format "{{.RepoDigests}}" docker.io/vaultwarden/web-vault:v2026.11.0
# [docker.io/vaultwarden/web-vault@sha256:b3e7e1607a6a3c4521cd801d5e3e79ab201d27cb59bfd6e6bd204308b42dc7a9]
#
# - Conversely, to get the tag name from the digest:
# $ docker image inspect --format "{{.RepoTags}}" docker.io/vaultwarden/web-vault@sha256:7baaa7d5349742548b6c44e557c1512157b22010cdf314ccc399ffdcacb5eb52
# [docker.io/vaultwarden/web-vault:v2026.10.1]
# $ docker image inspect --format "{{.RepoTags}}" docker.io/vaultwarden/web-vault@sha256:b3e7e1607a6a3c4521cd801d5e3e79ab201d27cb59bfd6e6bd204308b42dc7a9
# [docker.io/vaultwarden/web-vault:v2026.11.0]
#
FROM --platform=linux/amd64 docker.io/vaultwarden/web-vault@sha256:7baaa7d5349742548b6c44e557c1512157b22010cdf314ccc399ffdcacb5eb52 AS vault
FROM --platform=linux/amd64 docker.io/vaultwarden/web-vault@sha256:b3e7e1607a6a3c4521cd801d5e3e79ab201d27cb59bfd6e6bd204308b42dc7a9 AS vault
########################## ALPINE BUILD IMAGES ##########################
## NOTE: The Alpine Base Images do not support other platforms then linux/amd64 and linux/arm64

12
docker/Dockerfile.debian

@ -19,15 +19,15 @@
# - From https://hub.docker.com/r/vaultwarden/web-vault/tags,
# click the tag name to view the digest of the image it currently points to.
# - From the command line:
# $ docker pull docker.io/vaultwarden/web-vault:v2026.10.1
# $ docker image inspect --format "{{.RepoDigests}}" docker.io/vaultwarden/web-vault:v2026.10.1
# [docker.io/vaultwarden/web-vault@sha256:7baaa7d5349742548b6c44e557c1512157b22010cdf314ccc399ffdcacb5eb52]
# $ docker pull docker.io/vaultwarden/web-vault:v2026.11.0
# $ docker image inspect --format "{{.RepoDigests}}" docker.io/vaultwarden/web-vault:v2026.11.0
# [docker.io/vaultwarden/web-vault@sha256:b3e7e1607a6a3c4521cd801d5e3e79ab201d27cb59bfd6e6bd204308b42dc7a9]
#
# - Conversely, to get the tag name from the digest:
# $ docker image inspect --format "{{.RepoTags}}" docker.io/vaultwarden/web-vault@sha256:7baaa7d5349742548b6c44e557c1512157b22010cdf314ccc399ffdcacb5eb52
# [docker.io/vaultwarden/web-vault:v2026.10.1]
# $ docker image inspect --format "{{.RepoTags}}" docker.io/vaultwarden/web-vault@sha256:b3e7e1607a6a3c4521cd801d5e3e79ab201d27cb59bfd6e6bd204308b42dc7a9
# [docker.io/vaultwarden/web-vault:v2026.11.0]
#
FROM --platform=linux/amd64 docker.io/vaultwarden/web-vault@sha256:7baaa7d5349742548b6c44e557c1512157b22010cdf314ccc399ffdcacb5eb52 AS vault
FROM --platform=linux/amd64 docker.io/vaultwarden/web-vault@sha256:b3e7e1607a6a3c4521cd801d5e3e79ab201d27cb59bfd6e6bd204308b42dc7a9 AS vault
########################## Cross Compile Docker Helper Scripts ##########################
## We use the linux/amd64 no matter which Build Platform, since these are all bash scripts

2
playwright/README.md

@ -12,7 +12,7 @@ Databases (`Mariadb`, `Mysql` and `Postgres`) and `Playwright` will run in conta
### Running Playwright outside docker
It's possible to run `Playwright` outside of the container, this remove the need to rebuild the image for each change.
You'll additionally need `nodejs` then run:
You'll additionally need `nodejs` 24 or newer, then run:
```bash
npm ci --ignore-scripts --allow-git=none --allow-remote=none

6
playwright/compose/playwright/Dockerfile

@ -1,4 +1,4 @@
FROM docker.io/library/debian:trixie-slim
FROM docker.io/library/node:26-trixie-slim
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
@ -19,8 +19,6 @@ RUN apt-get update \
git \
libmariadb-dev-compat \
libpq5 \
nodejs \
npm \
openssl \
&& rm -rf /var/lib/apt/lists/*
@ -36,5 +34,5 @@ COPY compose ./compose
COPY *.ts test.env ./
COPY tests ./tests
ENTRYPOINT ["/usr/bin/npx", "playwright"]
ENTRYPOINT ["/usr/local/bin/npx", "playwright"]
CMD ["test"]

2
playwright/compose/warden/build.sh

@ -24,7 +24,7 @@ if [[ ! -z "$REPO_URL" ]] && [[ ! -z "$COMMIT_HASH" ]] ; then
fi
# Lower the KDF iterations default for faster tests.
sed -i 's/(6e5,2e6,6e5)/(1e5,2e6,1e5)/' /web-vault/app/main.*.js
sed -i 's/(6e5,2e6,6e5)/(6e3,2e6,6e3)/' /web-vault/app/main.*.js
# Generate a self signed cert
mkdir -p /data/ssl; cd /data/ssl

16
playwright/docker-compose.yml

@ -6,6 +6,8 @@ services:
build:
context: ..
dockerfile: Dockerfile
args:
DB: sqlite,mysql,postgresql,unsafe_test_mode
entrypoint: /bin/bash
restart: "no"
@ -23,12 +25,14 @@ services:
env_file: ${DC_ENV_FILE:-.env}
environment:
- ADMIN_TOKEN
- CLIENT_KDF_ITER
- DATABASE_URL
- CLIENT_SUPPRESS_ONBOARDING
- EMAIL_2FA_AUTO_FALLBACK
- I_REALLY_WANT_VOLATILE_STORAGE
- LOG_LEVEL
- LOGIN_RATELIMIT_MAX_BURST
- PASSWORD_ITERATIONS
- SMTP_HOST
- SMTP_FROM
- SMTP_DEBUG
@ -61,7 +65,7 @@ services:
Mariadb:
profiles: ["playwright"]
container_name: playwright_mariadb
image: mariadb:12.2.2
image: mariadb:12.3.3
env_file: test.env
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
@ -73,7 +77,7 @@ services:
Mysql:
profiles: ["playwright"]
container_name: playwright_mysql
image: mysql:9.7.0
image: mysql:9.7.4
env_file: test.env
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
@ -85,7 +89,7 @@ services:
Postgres:
profiles: ["playwright"]
container_name: playwright_postgres
image: postgres:18.4
image: postgres:18.7
env_file: test.env
healthcheck:
test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
@ -97,7 +101,7 @@ services:
Maildev:
profiles: ["vaultwarden", "maildev"]
container_name: maildev
image: timshel/maildev:3.2.19
image: timshel/maildev:3.3.8
ports:
- ${SMTP_PORT}:1025
- 1080:1080
@ -105,7 +109,7 @@ services:
Keycloak:
profiles: ["keycloak", "vaultwarden"]
container_name: keycloak-${ENV:-dev}
image: quay.io/keycloak/keycloak:26.6.2
image: quay.io/keycloak/keycloak:26.8.2
network_mode: "host"
command:
- start-dev
@ -120,7 +124,7 @@ services:
context: compose/keycloak
dockerfile: Dockerfile
args:
KEYCLOAK_VERSION: 26.6.2
KEYCLOAK_VERSION: 26.8.2
depends_on:
- Keycloak
restart: "no"

8
playwright/global-utils.ts

@ -221,13 +221,15 @@ export async function restartVault(page: Page, testInfo: TestInfo, env, resetDB:
}
export async function checkNotification(page: Page, hasText: string) {
await expect(page.locator('bit-toast', { hasText })).toBeVisible();
const toast = page.locator('bit-toast', { hasText });
await expect(toast).toBeVisible();
// An open dialog marks the toasts aria-hidden and covers them: find the button by CSS and dispatch the click.
try {
await page.locator('bit-toast', { hasText }).getByRole('button', { name: 'Close' }).click({force: true, timeout: 10_000});
await toast.locator('button[aria-label="Close"]').dispatchEvent('click', undefined, { timeout: 5_000 });
} catch (error) {
console.log(`Closing notification failed but it should now be invisible (${error})`);
}
await expect(page.locator('bit-toast', { hasText })).toHaveCount(0);
await expect(toast).toHaveCount(0);
}
export async function cleanLanding(page: Page) {

1398
playwright/package-lock.json

File diff suppressed because it is too large

10
playwright/package.json

@ -8,14 +8,14 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "1.60.0",
"@playwright/test": "1.65.1",
"dotenv": "17.4.2",
"dotenv-expand": "13.0.0",
"maildev": "npm:@timshel_npm/maildev@3.2.19"
"maildev": "npm:@timshel_npm/maildev@3.3.8"
},
"dependencies": {
"mysql2": "3.22.3",
"otpauth": "9.5.1",
"pg": "8.21.0"
"mysql2": "3.24.6",
"otpauth": "9.6.0",
"pg": "8.23.1"
}
}

5
playwright/playwright.config.ts

@ -26,14 +26,15 @@ export default defineConfig({
* But short action/nav/expect timeouts to fail on specific step (raise locally if not enough).
*/
timeout: 240 * 1000,
actionTimeout: 40 * 1000,
navigationTimeout: 40 * 1000,
expect: { timeout: 40 * 1000 },
"permissions": ["clipboard-read"],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
actionTimeout: 40 * 1000,
navigationTimeout: 40 * 1000,
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: process.env.DOMAIN,
browserName: 'firefox',

2
playwright/test.env

@ -58,6 +58,8 @@ LOG_LEVEL=info,oidcwarden::sso=debug
LOGIN_RATELIMIT_MAX_BURST=100
ADMIN_TOKEN=admin
CLIENT_SUPPRESS_ONBOARDING=true
PASSWORD_ITERATIONS=6000
CLIENT_KDF_ITER=6000
SMTP_SECURITY=off
SMTP_PORT=${MAILDEV_SMTP_PORT}

2
playwright/tests/collection.spec.ts

@ -21,7 +21,7 @@ test('Create', async ({ page }) => {
await orgs.create(test, page, 'New organisation');
await test.step('Create Collection', async () => {
await page.getByRole('button', { name: 'New', exact: true }).click();
await page.getByRole('button', { name: /^(New|Add)$/ }).click();
await page.getByRole('menuitem', { name: 'Collection' }).click();
await page.getByRole('textbox', { name: 'Name * (required)', exact: true }).fill('RandomCollec');
await page.getByRole('button', { name: 'Save' }).click();

21
playwright/tests/cyphers.spec.ts

@ -24,12 +24,16 @@ test('Change Key settings', async ({ page }) => {
await page.getByRole('link', { name: 'Security' }).click();
await page.getByRole('link', { name: 'Keys' }).click();
// V2 accounts (pm-27278-v2-password-registration) register with Argon2id, V1 ones with PBKDF2
await page.locator('.ng-arrow-wrapper').click();
await page.getByRole('option', { name: 'PBKDF2 SHA-256' }).click();
await page.getByRole('spinbutton', { name: 'KDF iterations * (required)'}).fill('700000');
await page.getByRole('button', { name: 'Update encryption settings' }).click();
await page.getByRole('textbox', { name: 'Master password * (required)' }).fill(users.user1.password);
await page.getByRole('button', { name: 'Update settings' }).click();
await page.getByRole('heading', { name: 'Log in' }).click();
await kdfChanged(test, page);
});
await logUser(test, page, users.user1);
@ -49,8 +53,21 @@ test('Change Key settings', async ({ page }) => {
await page.getByRole('button', { name: 'Update encryption settings' }).click();
await page.getByRole('textbox', { name: 'Master password * (required)' }).fill(users.user1.password);
await page.getByRole('button', { name: 'Update settings' }).click();
await page.getByRole('heading', { name: 'Log in' }).click();
await kdfChanged(test, page);
});
await logUser(test, page, users.user1);
});
// Before web vault 2026.10 a KDF change logged the user out, with "Please log back in." in the toast.
async function kdfChanged(test, page: Page) {
const toast = page.locator('bit-toast', { hasText: 'Encryption key settings changed' });
await expect(toast).toBeVisible();
const loggedOut = await toast.filter({ hasText: 'Please log back in' }).count() > 0;
await utils.checkNotification(page, 'Encryption key settings changed');
if (loggedOut) {
await expect(page.getByRole('heading', { name: 'Log in' })).toBeVisible();
} else {
await utils.logout(test, page, users.user1);
}
}

12
playwright/tests/organization.smtp.spec.ts

@ -42,11 +42,19 @@ test('Invite users', async ({ page }) => {
await createAccount(test, page, users.user1, mail1Buffer);
await orgs.create(test, page, 'Test');
await orgs.policies(test, page, 'Test');
// Account recovery requires the Single organisation policy (ENFORCE_SINGLE_ORG_WITH_RESET_PW_POLICY)
await test.step(`Set single organisation`, async () => {
await page.getByRole('button', { name: 'Single organisation' }).click();
await orgs.enablePolicy(page);
await page.getByRole('button', { name: 'Save' }).click();
await utils.checkNotification(page, 'Edited policy Single organisation');
});
await test.step(`Set account recovery`, async () => {
await orgs.policies(test, page, 'Test');
await page.getByRole('button', { name: 'Account recovery' }).click();
await page.getByRole('checkbox', { name: 'Turn on' }).check();
await orgs.enablePolicy(page);
await page.getByRole('checkbox', { name: 'Automatically enroll new' }).check();
await page.getByRole('button', { name: 'Save' }).click();
await utils.checkNotification(page, 'Edited policy Account recovery');

4
playwright/tests/secrets.spec.ts

@ -26,7 +26,7 @@ test('Password', async ({ context, page }, testInfo: TestInfo) => {
await logUser(test, page, users.user1);
await test.step('Create password entry', async () => {
await page.getByRole('button', { name: 'New item' }).click();
await page.getByRole('button', { name: /^(New|Add) item$/ }).click();
await page.getByRole('textbox', { name: 'Item name * (required)' }).fill(label);
await page.getByRole('textbox', { name: 'Username' }).fill(users.user1.name);
await page.getByRole('textbox', { name: 'Password' }).fill(users.user1.password);
@ -71,7 +71,7 @@ test('SSH Key', async ({ context, page }, testInfo: TestInfo) => {
await logUser(test, page, users.user1);
const privateKey = await test.step('Create key entry', async () => {
await page.getByRole('button', { name: 'New', exact: true }).click();
await page.getByRole('button', { name: /^(New|Add)$/ }).click();
await page.getByRole('menuitem', { name: 'SSH key' }).click();
await page.getByRole('textbox', { name: 'Item name * (required)' }).fill('Test SSH key');
await page.getByRole('button', { name: 'Save' }).click();

4
playwright/tests/send.spec.ts

@ -21,7 +21,7 @@ test('Send', async ({ browser, page }) => {
await page.getByRole('link', { name: 'Send' }).click();
await expect(page.locator('#main-content').getByText('Send', { exact: true })).toBeVisible();
await page.getByRole('button', { name: 'New Send', exact: true }).click();
await page.getByRole('button', { name: /^(New|Create) Send$/ }).click();
await page.getByRole('menuitem', { name: 'Text' }).click();
await page.getByRole('textbox', { name: 'Send name * (required)' }).fill('Test');
@ -46,7 +46,7 @@ test('Send', async ({ browser, page }) => {
await page.getByRole('link', { name: 'Send' }).click();
await expect(page.locator('#main-content').getByText('Send', { exact: true })).toBeVisible();
await page.getByRole('button', { name: 'New' }).click();
await page.getByRole('button', { name: /\b(New|Create)$/ }).click();
await page.getByRole('menuitem', { name: 'Text' }).click();
await page.getByRole('textbox', { name: 'Send name * (required)' }).fill('Password');

19
playwright/tests/setups/orgs.ts

@ -29,6 +29,11 @@ export async function policies(test, page: Page, name: string) {
});
}
// Web vault 2026.10 replaced the "Turn on" checkbox with an "Enable policy" switch, whose thumb covers the input.
export async function enablePolicy(page: Page) {
await page.getByRole('checkbox', { name: 'Turn on' }).or(page.getByRole('switch', { name: 'Enable policy' })).check({ force: true });
}
export async function members(test, page: Page, name: string) {
await test.step(`Navigate to ${name} members`, async () => {
await page.locator('a').filter({ hasText: 'Admin Console' }).first().click();
@ -46,13 +51,19 @@ export async function invite(test, page: Page, name: string, email: string) {
await expect(page.getByRole('heading', { name: 'Members' })).toBeVisible();
await page.getByRole('button', { name: 'Invite member' }).click();
await page.getByRole('textbox', { name: 'Email * (required)', exact: true }).fill(email);
await page.getByRole('tab', { name: 'Collections' }).click();
await page.getByRole('combobox', { name: 'Permission' }).click();
// Web vault 2026.10 moved collections from a tab into "More settings" and renamed Save to Invite.
const moreSettings = page.getByRole('button', { name: 'More settings' });
if (await moreSettings.count() > 0) {
await moreSettings.click();
} else {
await page.getByRole('tab', { name: 'Collections' }).click();
}
await page.getByTestId('permission').getByRole('combobox').click();
await page.getByText('Edit items', { exact: true }).click();
await page.getByRole('combobox', { name: 'Select collections' }).click();
await page.getByRole('combobox', { name: /^(Select collections|Collections)/ }).click();
await page.getByLabel('Options List').getByText('Default collection').click();
await page.getByRole('columnheader', { name: 'Collection', exact: true }).click();
await page.getByRole('button', { name: 'Save' }).click();
await page.getByRole('button', { name: /^(Save|Invite)$/ }).click();
await utils.checkNotification(page, 'User(s) invited');
});
}

4
playwright/tests/sso_organization.spec.ts

@ -55,9 +55,9 @@ test('Activate password policy', async ({ page }) => {
await test.step(`Set master password policy`, async () => {
await page.getByRole('button', { name: 'Master password requirements' }).click();
await page.getByRole('checkbox', { name: 'Turn on' }).check();
await orgs.enablePolicy(page);
await page.getByRole('checkbox', { name: 'Require existing members to' }).check();
await page.getByRole('spinbutton', { name: 'Minimum length' }).fill('42');
await page.getByRole('spinbutton', { name: /^Minimum (character )?length/ }).fill('42');
await page.getByRole('button', { name: 'Save' }).click();
await utils.checkNotification(page, 'Edited policy Master password requirements.');
});

4
src/api/admin.rs

@ -99,8 +99,8 @@ static CAN_BACKUP: LazyLock<bool> = LazyLock::new(|| ACTIVE_DB_TYPE.get().is_som
static CAN_BACKUP: LazyLock<bool> = LazyLock::new(|| false);
#[get("/")]
fn admin_disabled() -> &'static str {
"The admin panel is disabled, please configure the 'ADMIN_TOKEN' variable to enable it"
fn admin_disabled() -> (Status, &'static str) {
(Status::NotFound, "The admin panel is disabled, please configure the 'ADMIN_TOKEN' variable to enable it")
}
const COOKIE_NAME: &str = "VW_ADMIN";

129
src/api/core/accounts.rs

@ -21,10 +21,10 @@ use crate::{
db::{
DbConn, DbPool,
models::{
AuthRequest, AuthRequestId, Cipher, CipherId, Device, DeviceId, DeviceType, DeviceWithAuthRequest,
EmergencyAccess, EmergencyAccessId, EventType, Folder, FolderId, Invitation, KeyId, Membership,
MembershipId, OrgPolicy, OrgPolicyType, Organization, OrganizationId, Send, SendId, SignatureAlgorithm,
User, UserId, UserKdfType, UserSignatureKeyPair, WebauthnCredential,
AuthRequest, AuthRequestId, Cipher, CipherId, Device, DeviceId, DeviceWithAuthRequest, EmergencyAccess,
EmergencyAccessId, EventType, Folder, FolderId, Invitation, KeyId, Membership, MembershipId, OrgPolicy,
OrgPolicyType, Organization, OrganizationId, Send, SendId, SignatureAlgorithm, User, UserId, UserKdfType,
UserSignatureKeyPair, WebauthnCredential,
},
},
mail,
@ -909,7 +909,9 @@ async fn get_keys(headers: Headers, conn: DbConn) -> JsonResult {
#[serde(rename_all = "camelCase")]
struct PostKeysData {
// Required like upstream, even next to `accountKeys`
#[serde(alias = "PublicKey")]
public_key: Option<String>,
#[serde(alias = "EncryptedPrivateKey")]
encrypted_private_key: Option<String>,
account_keys: Option<AccountKeysData>,
// The id of the user key these account keys belong to, only honored for v2 `accountKeys`
@ -1039,8 +1041,8 @@ async fn post_password(data: Json<ChangePassData>, headers: Headers, conn: DbCon
}
fn set_kdf_data(user: &mut User, data: &KDFData) -> EmptyResult {
if data.kdf == UserKdfType::Pbkdf2 as i32 && data.kdf_iterations < 100_000 {
err!("PBKDF2 KDF iterations must be at least 100000.")
if data.kdf == UserKdfType::Pbkdf2 as i32 && data.kdf_iterations < CONFIG.client_kdf_iter() {
err!(format!("PBKDF2 KDF iterations must be at least {}.", CONFIG.client_kdf_iter()))
}
if data.kdf == UserKdfType::Argon2id as i32 {
@ -1885,7 +1887,7 @@ async fn post_sstamp(data: Json<PasswordOrOtpData>, headers: Headers, conn: DbCo
let data: PasswordOrOtpData = data.into_inner();
let mut user = headers.user;
data.validate(&user, true, &conn).await?;
data.validate(&mut user, true, &conn).await?;
user.reset_security_stamp(&conn).await?;
let save_result = user.save(&conn).await;
@ -2143,9 +2145,9 @@ async fn post_delete_account(
#[delete("/accounts", data = "<data>")]
async fn delete_account(data: Json<PasswordOrOtpData>, headers: Headers, conn: DbConn, nt: Notify<'_>) -> EmptyResult {
let data: PasswordOrOtpData = data.into_inner();
let user = headers.user;
let mut user = headers.user;
data.validate(&user, true, &conn).await?;
data.validate(&mut user, true, &conn).await?;
// The devices are deleted together with the user, so check for push devices beforehand
let has_push_device = CONFIG.push_enabled() && Device::check_user_has_push_device(&user.uuid, &conn).await;
@ -2226,15 +2228,15 @@ fn unknown_email_kdf(email: &str) -> (i32, i32, Option<i32>, Option<i32>) {
const PBKDF2: i32 = UserKdfType::Pbkdf2 as i32;
const ARGON2ID: i32 = UserKdfType::Argon2id as i32;
// Same list as upstream, the default is in it twice to give it more weight
const KDF_SETTINGS: [(i32, i32, Option<i32>, Option<i32>); 6] = [
(User::CLIENT_KDF_TYPE_DEFAULT, User::CLIENT_KDF_ITER_DEFAULT, None, None),
(User::CLIENT_KDF_TYPE_DEFAULT, User::CLIENT_KDF_ITER_DEFAULT, None, None),
let kdf_settings: [(i32, i32, Option<i32>, Option<i32>); 6] = [
(User::CLIENT_KDF_TYPE_DEFAULT, CONFIG.client_kdf_iter(), None, None),
(User::CLIENT_KDF_TYPE_DEFAULT, CONFIG.client_kdf_iter(), None, None),
(PBKDF2, 100_000, None, None),
(PBKDF2, 5_000, None, None),
(ARGON2ID, 3, Some(64), Some(4)),
(ARGON2ID, 6, Some(32), Some(4)),
];
KDF_SETTINGS[crate::auth::prelogin_kdf_index(email, KDF_SETTINGS.len())]
kdf_settings[crate::auth::prelogin_kdf_index(email, kdf_settings.len())]
}
pub async fn prelogin(data: Json<PreloginData>, ip: ClientIp, conn: DbConn) -> JsonResult {
@ -2271,19 +2273,6 @@ struct SecretVerificationRequest {
master_password_hash: String,
}
// Change the KDF Iterations if necessary
pub async fn kdf_upgrade(user: &mut User, pwd_hash: &str, conn: &DbConn) -> ApiResult<()> {
if user.password_iterations < CONFIG.password_iterations() {
user.password_iterations = CONFIG.password_iterations();
user.set_password(pwd_hash, None, false, None, conn).await?;
if let Err(e) = user.save(conn).await {
error!("Error updating user: {e:#?}");
}
}
Ok(())
}
#[post("/accounts/verify-password", data = "<data>")]
async fn verify_password(data: Json<SecretVerificationRequest>, headers: Headers, conn: DbConn) -> JsonResult {
let data: SecretVerificationRequest = data.into_inner();
@ -2293,7 +2282,7 @@ async fn verify_password(data: Json<SecretVerificationRequest>, headers: Headers
err!("Invalid password")
}
kdf_upgrade(&mut user, &data.master_password_hash, &conn).await?;
user.check_persist_kdf_upgrade(&data.master_password_hash, &conn).await?;
Ok(Json(master_password_policy(&user, &conn).await))
}
@ -2302,7 +2291,7 @@ async fn update_api_key(data: Json<PasswordOrOtpData>, rotate: bool, headers: He
let data: PasswordOrOtpData = data.into_inner();
let mut user = headers.user;
data.validate(&user, true, &conn).await?;
data.validate(&mut user, true, &conn).await?;
if rotate || user.api_key.is_none() {
user.api_key = Some(crypto::generate_api_key());
@ -2527,19 +2516,7 @@ async fn post_auth_request(
)
.await;
Ok(Json(json!({
"id": auth_request.uuid,
"publicKey": auth_request.public_key,
"requestDeviceType": DeviceType::from_i32(auth_request.device_type).to_string(),
"requestIpAddress": auth_request.request_ip,
"key": null,
"masterPasswordHash": null,
"creationDate": format_date(&auth_request.creation_date),
"responseDate": null,
"requestApproved": false,
"origin": CONFIG.domain_origin(),
"object": "auth-request"
})))
Ok(Json(auth_request.to_json()))
}
#[get("/auth-requests/<auth_request_id>")]
@ -2549,21 +2526,7 @@ async fn get_auth_request(auth_request_id: AuthRequestId, headers: Headers, conn
err!("AuthRequest doesn't exist", "Record not found or user uuid does not match")
};
let response_date_utc = auth_request.response_date.map(|response_date| format_date(&response_date));
Ok(Json(json!({
"id": &auth_request_id,
"publicKey": auth_request.public_key,
"requestDeviceType": DeviceType::from_i32(auth_request.device_type).to_string(),
"requestIpAddress": auth_request.request_ip,
"key": auth_request.enc_key,
"masterPasswordHash": auth_request.master_password_hash,
"creationDate": format_date(&auth_request.creation_date),
"responseDate": response_date_utc,
"requestApproved": auth_request.approved,
"origin": CONFIG.domain_origin(),
"object":"auth-request"
})))
Ok(Json(auth_request.to_json()))
}
#[derive(Debug, Deserialize)]
@ -2598,15 +2561,14 @@ async fn put_auth_request(
err!("An authentication request with the same device already exists")
}
let response_date = Utc::now().naive_utc();
let response_date_utc = format_date(&response_date);
// Set the date now so that the response returns it
auth_request.response_date = Some(Utc::now().naive_utc());
if data.request_approved {
auth_request.approved = Some(data.request_approved);
auth_request.enc_key = Some(data.key);
auth_request.master_password_hash = data.master_password_hash;
auth_request.response_device_id = Some(data.device_identifier.clone());
auth_request.response_date = Some(response_date);
auth_request.save(&conn).await?;
ant.send_auth_response(&auth_request.user_uuid, &auth_request.uuid).await;
@ -2633,19 +2595,7 @@ async fn put_auth_request(
.await;
}
Ok(Json(json!({
"id": &auth_request_id,
"publicKey": auth_request.public_key,
"requestDeviceType": DeviceType::from_i32(auth_request.device_type).to_string(),
"requestIpAddress": auth_request.request_ip,
"key": auth_request.enc_key,
"masterPasswordHash": auth_request.master_password_hash,
"creationDate": format_date(&auth_request.creation_date),
"responseDate": response_date_utc,
"requestApproved": auth_request.approved,
"origin": CONFIG.domain_origin(),
"object":"auth-request"
})))
Ok(Json(auth_request.to_json()))
}
#[get("/auth-requests/<auth_request_id>/response?<code>")]
@ -2668,21 +2618,7 @@ async fn get_auth_request_response(
err!("AuthRequest doesn't exist", "Invalid device, IP or code")
}
let response_date_utc = auth_request.response_date.map(|response_date| format_date(&response_date));
Ok(Json(json!({
"id": &auth_request_id,
"publicKey": auth_request.public_key,
"requestDeviceType": DeviceType::from_i32(auth_request.device_type).to_string(),
"requestIpAddress": auth_request.request_ip,
"key": auth_request.enc_key,
"masterPasswordHash": auth_request.master_password_hash,
"creationDate": format_date(&auth_request.creation_date),
"responseDate": response_date_utc,
"requestApproved": auth_request.approved,
"origin": CONFIG.domain_origin(),
"object":"auth-request"
})))
Ok(Json(auth_request.to_json()))
}
// Now unused but not yet removed
@ -2700,23 +2636,8 @@ async fn get_auth_requests_pending(headers: Headers, conn: DbConn) -> JsonResult
"data": auth_requests
.iter()
.filter(|request| request.approved.is_none())
.map(|request| {
let response_date_utc = request.response_date.map(|response_date| format_date(&response_date));
json!({
"id": request.uuid,
"publicKey": request.public_key,
"requestDeviceType": DeviceType::from_i32(request.device_type).to_string(),
"requestIpAddress": request.request_ip,
"key": request.enc_key,
"masterPasswordHash": request.master_password_hash,
"creationDate": format_date(&request.creation_date),
"responseDate": response_date_utc,
"requestApproved": request.approved,
"origin": CONFIG.domain_origin(),
"object":"auth-request"
})
}).collect::<Vec<Value>>(),
.map(AuthRequest::to_json)
.collect::<Vec<Value>>(),
"continuationToken": null,
"object": "list"
})))

63
src/api/core/ciphers.rs

@ -1,6 +1,7 @@
use std::collections::{HashMap, HashSet};
use chrono::{NaiveDateTime, Utc};
use rocket::{
Route,
form::{Form, FromForm},
@ -12,7 +13,7 @@ use serde_json::Value;
use crate::{
CONFIG,
api::{self, ApiResult, EmptyResult, JsonResult, Notify, PasswordOrOtpData, UpdateType, core::log_event},
api::{self, EmptyResult, JsonResult, Notify, PasswordOrOtpData, UpdateType, core::log_event},
auth::ClientVersion,
auth::{Headers, OrgIdGuard, OwnerHeaders},
config::PathType,
@ -845,7 +846,7 @@ pub async fn seed_cipher(
user_id: &UserId,
folder_ids: &HashMap<FolderId, FolderId>,
conn: &DbConn,
) -> ApiResult<CipherId> {
) -> api::ApiResult<CipherId> {
// Not in the request model, but a trashed cipher has to stay trashed
let deleted_at = encrypted.get("deletedDate").and_then(Value::as_str).map(parse_seed_date).transpose()?;
let mut data: CipherData = serde_json::from_value(encrypted)?;
@ -892,7 +893,7 @@ pub async fn seed_cipher(
}
#[cfg(feature = "unsafe_test_mode")]
fn parse_seed_date(date: &str) -> ApiResult<NaiveDateTime> {
fn parse_seed_date(date: &str) -> api::ApiResult<NaiveDateTime> {
match chrono::DateTime::parse_from_rfc3339(date) {
Ok(date) => Ok(date.naive_utc()),
Err(e) => err!(format!("Invalid date {}: {e}", date.escape_debug())),
@ -1521,6 +1522,13 @@ async fn share_cipher_by_uuid(
false,
)
.await?;
// The moved attachments now count against the organization's limit
if transfer_cipher {
let moved: i64 = Attachment::find_by_cipher(&cipher.uuid, conn).await.iter().map(|a| a.file_size).sum();
if moved > 0 {
check_attachment_space(&cipher, moved, moved, conn).await?;
}
}
for col_id in &shared_to_collections {
CollectionCipher::save(&cipher.uuid, col_id, conn).await?;
}
@ -1622,17 +1630,17 @@ enum FileUploadType {
// Azure = 1, // only used upstream
}
/// Remaining attachment storage in bytes for the cipher's owner, `None` when unlimited.
/// `size_adjust` credits a v2 attachment whose record already counts as used.
async fn attachment_size_limit(cipher: &Cipher, size_adjust: i64, conn: &DbConn) -> ApiResult<Option<i64>> {
/// Fails when `size` more bytes don't fit in the attachment storage of the cipher's owner.
/// `size_adjust` credits bytes already counted as used, such as a v2 attachment's reserved record.
async fn check_attachment_space(cipher: &Cipher, size: i64, size_adjust: i64, conn: &DbConn) -> EmptyResult {
let (limit_kb, already_used) = if let Some(ref user_id) = cipher.user_uuid {
let Some(limit_kb) = CONFIG.user_attachment_limit() else {
return Ok(None);
return Ok(());
};
(limit_kb, Attachment::size_by_user(user_id, conn).await)
} else if let Some(ref org_id) = cipher.organization_uuid {
let Some(limit_kb) = CONFIG.org_attachment_limit() else {
return Ok(None);
return Ok(());
};
(limit_kb, Attachment::size_by_org(org_id, conn).await)
} else {
@ -1652,8 +1660,11 @@ async fn attachment_size_limit(cipher: &Cipher, size_adjust: i64, conn: &DbConn)
if left <= 0 {
err!("Attachment storage limit reached! Delete some attachments to free up space")
}
if size > left {
err!("Attachment storage limit exceeded with this file");
}
Ok(Some(left))
Ok(())
}
/// v2 API for creating an attachment associated with a cipher.
@ -1691,16 +1702,12 @@ async fn post_attachment_v2(
err!("Max file size is 525 MB.")
}
if let Some(size_limit) = attachment_size_limit(&cipher, 0, &conn).await?
&& file_size > size_limit
{
err!("Attachment storage limit exceeded with this file");
}
check_attachment_space(&cipher, file_size, 0, &conn).await?;
let attachment_id = crypto::generate_attachment_id();
let attachment =
Attachment::new(attachment_id.clone(), cipher.uuid.clone(), data.file_name, file_size, Some(data.key));
attachment.save(&conn).await.expect("Error saving attachment");
attachment.save(&conn).await?;
notify_attachment_created(&cipher, &headers, &conn, &nt).await;
let url = format!("/ciphers/{}/attachment/{attachment_id}", cipher.uuid);
@ -1765,11 +1772,7 @@ async fn save_attachment(
Some(a) => a.file_size, // v2 API
};
if let Some(size_limit) = attachment_size_limit(&cipher, size_adjust, &conn).await?
&& size > size_limit
{
err!("Attachment storage limit exceeded with this file");
}
check_attachment_space(&cipher, size, size_adjust, &conn).await?;
let file_id = match &attachment {
Some(attachment) => attachment.id.clone(), // v2 API
@ -1794,7 +1797,7 @@ async fn save_attachment(
if size != attachment.file_size {
// Update the attachment with the actual file size.
attachment.file_size = size;
attachment.save(&conn).await.expect("Error updating attachment");
attachment.save(&conn).await?;
}
} else {
attachment.delete(&conn).await.ok();
@ -1816,7 +1819,7 @@ async fn save_attachment(
}
let attachment =
Attachment::new(file_id.clone(), cipher_id.clone(), encrypted_filename.unwrap(), size, data.key);
attachment.save(&conn).await.expect("Error saving attachment");
attachment.save(&conn).await?;
}
save_temp_file(&PathType::Attachments, &format!("{cipher_id}/{file_id}"), data.data, true).await?;
@ -2208,6 +2211,16 @@ async fn move_cipher_selected(
let data = data.into_inner();
let user_id = &headers.user.uuid;
// Validate the cipher IDs are well-formed before they reach the query.
// Unlike path parameters (UuidFromParam), IDs deserialized from a JSON body
// are not checked, so a malformed value (e.g. one containing a NUL byte)
// would otherwise reach the database and error out.
for cipher_id in &data.ids {
if uuid::Uuid::parse_str(cipher_id.as_ref()).is_err() {
err!("Invalid cipher ID provided")
}
}
if let Some(ref folder_id) = data.folder_id
&& Folder::find_by_uuid_and_user(folder_id, user_id, &conn).await.is_none()
{
@ -2295,9 +2308,9 @@ async fn purge_org_vault(
}
let data: PasswordOrOtpData = data.into_inner();
let user = headers.user;
let mut user = headers.user;
data.validate(&user, true, &conn).await?;
data.validate(&mut user, true, &conn).await?;
match Membership::find_confirmed_by_user_and_org(&user.uuid, &organization.org_id, &conn).await {
Some(member) if member.atype == MembershipType::Owner => {
@ -2331,7 +2344,7 @@ async fn purge_personal_vault(
let data: PasswordOrOtpData = data.into_inner();
let mut user = headers.user;
data.validate(&user, true, &conn).await?;
data.validate(&mut user, true, &conn).await?;
for cipher in Cipher::find_owned_by_user(&user.uuid, &conn).await {
cipher.delete(&conn).await?;

78
src/api/core/organizations.rs

@ -120,11 +120,12 @@ struct OrgData {
plan_type: NumberOrString,
}
#[derive(Deserialize, Debug)]
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct OrganizationUpdateData {
billing_email: String,
name: String,
keys: Option<OrgKeyData>,
}
#[derive(Deserialize)]
@ -160,18 +161,24 @@ impl FullCollectionData {
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct CollectionGroupData {
#[serde(default)]
hide_passwords: bool,
id: GroupId,
#[serde(default)]
read_only: bool,
#[serde(default)]
manage: bool,
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct CollectionMembershipData {
#[serde(default)]
hide_passwords: bool,
id: MembershipId,
#[serde(default)]
read_only: bool,
#[serde(default)]
manage: bool,
}
@ -235,12 +242,14 @@ async fn delete_organization(
headers: OwnerHeaders,
conn: DbConn,
) -> EmptyResult {
let mut user = headers.user;
if org_id != headers.org_id {
err!("Organization not found", "Organization id's do not match");
}
let data: PasswordOrOtpData = data.into_inner();
data.validate(&headers.user, true, &conn).await?;
data.validate(&mut user, true, &conn).await?;
match Organization::find_by_uuid(&org_id, &conn).await {
None => err!("Organization not found"),
@ -307,6 +316,16 @@ async fn put_organization(
org.name = data.name;
org.billing_email = data.billing_email.to_lowercase();
if let Some(keys) = data.keys
&& !keys.public_key.trim().is_empty()
&& !keys.encrypted_private_key.trim().is_empty()
&& org.public_key.as_deref().is_none_or(|k| k.trim().is_empty())
&& org.private_key.as_deref().is_none_or(|k| k.trim().is_empty())
{
org.public_key = Some(keys.public_key);
org.private_key = Some(keys.encrypted_private_key);
}
org.save(&conn).await?;
log_event(
@ -2292,7 +2311,9 @@ async fn post_bulk_collections(data: Json<BulkCollectionsData>, headers: Headers
// Only act on existing cipher uuid's
// Do not abort the operation just ignore it, it could be a cipher was just deleted for example
if let Some(cipher) = Cipher::find_by_uuid_and_org(cipher_id, &data.organization_id, &conn).await
&& cipher.is_write_accessible_to_user(&headers.user.uuid, CipherAccessScope::OrganizationAdmin, &conn).await
&& cipher
.is_in_editable_collection_by_user(&headers.user.uuid, CipherAccessScope::OrganizationAdmin, &conn)
.await
{
// When selecting a specific collection from the left filter list, and use the bulk option, you can remove an item from that collection
// In these cases the client will call this endpoint twice, once for adding the new collections and a second for deleting.
@ -2316,7 +2337,10 @@ async fn list_policies(org_id: OrganizationId, headers: ManagePoliciesHeaders, c
if org_id != headers.org_id {
err!("Organization not found", "Organization id's do not match");
}
let policies = OrgPolicy::find_by_org(&org_id, &conn).await;
let mut policies = OrgPolicy::find_by_org(&org_id, &conn).await;
if !policies.iter().any(|p| p.has_type(OrgPolicyType::SendControls)) {
policies.push(OrgPolicy::synthesize_send_controls(&org_id, &policies));
}
let policies_json: Vec<Value> = policies.iter().map(OrgPolicy::to_json).collect();
Ok(Json(json!({
@ -2339,9 +2363,15 @@ async fn list_policies_token(org_id: OrganizationId, token: &str, conn: DbConn)
return Ok(Json(json!({})));
}
// TODO: We receive the invite token as ?token=<>, validate it contains the org id
let Some(member) = Membership::find_by_uuid_and_org(&invite.member_id, &org_id, &conn).await else {
err!("Organization not found", "The invited membership no longer exists")
};
if member.user_uuid != invite.sub || member.status != MembershipStatus::Invited as i32 {
err!("Organization not found", "The membership is not a pending invitation of this user")
}
let policies = OrgPolicy::find_by_org(&org_id, &conn).await;
let policies_json: Vec<Value> = policies.iter().map(OrgPolicy::to_json).collect();
let policies_json: Vec<Value> = policies.iter().filter(|p| p.enabled).map(OrgPolicy::to_json).collect();
Ok(Json(json!({
"data": policies_json,
@ -2387,9 +2417,13 @@ async fn get_policy(org_id: OrganizationId, pol_type: i32, headers: ManagePolici
err!("Invalid or unsupported policy type")
};
let policy = OrgPolicy::find_by_org_and_type(&org_id, pol_type_enum, &conn)
.await
.unwrap_or_else(|| OrgPolicy::new(org_id.clone(), pol_type_enum, false, "null".to_owned()));
let policy = match OrgPolicy::find_by_org_and_type(&org_id, pol_type_enum, &conn).await {
Some(p) => p,
None if pol_type_enum == OrgPolicyType::SendControls => {
OrgPolicy::synthesize_send_controls(&org_id, &OrgPolicy::find_by_org(&org_id, &conn).await)
}
None => OrgPolicy::new(org_id.clone(), pol_type_enum, false, "null".to_owned()),
};
Ok(Json(policy.to_json()))
}
@ -2453,7 +2487,6 @@ async fn put_policy(
// Vaultwarden encouraged to use multiple orgs instead of groups because groups were not available in the past
// Now that groups are available we can enforce this option when wanted.
// We put this behind a config option to prevent breaking current installation.
// Maybe we want to enable this by default in the future, but currently it is disabled by default.
if CONFIG.enforce_single_org_with_reset_pw_policy() {
if pol_type_enum == OrgPolicyType::ResetPassword && data.enabled {
let single_org_policy_enabled = OrgPolicy::find_by_org_and_type(&org_id, OrgPolicyType::SingleOrg, &conn)
@ -2529,13 +2562,15 @@ async fn put_policy(
.await?;
}
let policy_data = OrgPolicy::send_policy_data(pol_type_enum, data.data)?;
let mut policy = match current_policy {
Some(p) => p,
None => OrgPolicy::new(org_id.clone(), pol_type_enum, false, "{}".to_owned()),
};
policy.enabled = data.enabled;
policy.data = serde_json::to_string(&data.data)?;
policy.data = serde_json::to_string(&policy_data)?;
policy.save(&conn).await?;
log_event(
@ -2549,6 +2584,8 @@ async fn put_policy(
)
.await;
OrgPolicy::sync_send_policies(&policy, &conn).await?;
Ok(Json(policy.to_json()))
}
@ -2987,8 +3024,11 @@ impl GroupRequest {
#[serde(rename_all = "camelCase")]
struct CollectionData {
id: CollectionId,
#[serde(default)]
read_only: bool,
#[serde(default)]
hide_passwords: bool,
#[serde(default)]
manage: bool,
}
@ -3707,12 +3747,13 @@ async fn put_reset_password_enrollment(
data: Json<OrganizationUserResetPasswordEnrollmentRequest>,
conn: DbConn,
) -> EmptyResult {
if user_id != headers.user.uuid {
let mut membership = headers.membership;
let mut user = headers.user;
if user_id != user.uuid {
err!("User to enroll isn't member of required organization", "The user_id and acting user do not match");
}
let mut membership = headers.membership;
check_reset_password_applicable(&org_id, &conn).await?;
let reset_request = data.into_inner();
@ -3727,7 +3768,7 @@ async fn put_reset_password_enrollment(
master_password_hash: reset_request.master_password_hash,
otp: reset_request.otp,
}
.validate(&headers.user, true, &conn)
.validate(&mut user, true, &conn)
.await?;
}
@ -3743,8 +3784,7 @@ async fn put_reset_password_enrollment(
EventType::OrganizationUserResetPasswordWithdraw
};
log_event(event_type, &membership.uuid, &org_id, &headers.user.uuid, headers.device.atype, &headers.ip.ip, &conn)
.await;
log_event(event_type, &membership.uuid, &org_id, &user.uuid, headers.device.atype, &headers.ip.ip, &conn).await;
Ok(())
}
@ -3778,10 +3818,10 @@ async fn api_key(
err!("Organization not found", "Organization id's do not match");
}
let data: PasswordOrOtpData = data.into_inner();
let user = headers.user;
let mut user = headers.user;
// Validate the owner users password/otp
data.validate(&user, true, &conn).await?;
data.validate(&mut user, true, &conn).await?;
let org_api_key = if let Some(mut org_api_key) = OrganizationApiKey::find_by_org_uuid(org_id, &conn).await {
if rotate {

59
src/api/core/sends.rs

@ -15,7 +15,7 @@ use crate::{
config::PathType,
db::{
DbConn, DbPool,
models::{Device, OrgPolicy, OrgPolicyType, Send, SendFileId, SendId, SendType, UserId},
models::{Device, OrgPolicy, Send, SendFileId, SendId, SendType, UserId},
},
util::{NumberOrString, save_temp_file},
};
@ -89,40 +89,16 @@ pub struct SendData {
pub id: Option<SendId>,
}
/// Enforces the `Disable Send` policy. A non-owner/admin user belonging to
/// an org with this policy enabled isn't allowed to create new Sends or
/// modify existing ones, but is allowed to delete them.
///
/// Ref: https://bitwarden.com/help/article/policies/#disable-send
/// Enforces the Send policies (`Send controls` and the legacy `Disable Send` and `Send Options` it
/// absorbs) on the Send as it would be saved. Deleting a Send is always allowed.
///
/// There is also a Vaultwarden-specific `sends_allowed` config setting that
/// controls this policy globally.
async fn enforce_disable_send_policy(headers: &Headers, conn: &DbConn) -> EmptyResult {
let user_id = &headers.user.uuid;
if !CONFIG.sends_allowed()
|| OrgPolicy::is_applicable_to_user(user_id, OrgPolicyType::DisableSend, None, conn).await
{
async fn enforce_send_policy(send: &Send, headers: &Headers, conn: &DbConn) -> EmptyResult {
if !CONFIG.sends_allowed() {
err!("Due to an Enterprise Policy, you are only able to delete an existing Send.")
}
Ok(())
}
/// Enforces the `DisableHideEmail` option of the `Send Options` policy.
/// A non-owner/admin user belonging to an org with this option enabled isn't
/// allowed to hide their email address from the recipient of a Bitwarden Send,
/// but is allowed to remove this option from an existing Send.
///
/// Ref: https://bitwarden.com/help/article/policies/#send-options
async fn enforce_disable_hide_email_policy(data: &SendData, headers: &Headers, conn: &DbConn) -> EmptyResult {
let user_id = &headers.user.uuid;
let hide_email = data.hide_email.unwrap_or(false);
if hide_email && OrgPolicy::is_hide_email_disabled(user_id, conn).await {
err!(
"Due to an Enterprise Policy, you are not allowed to hide your email address \
from recipients when creating or editing a Send."
)
}
Ok(())
OrgPolicy::check_send(&headers.user.uuid, send, conn).await
}
/// Stores a text Send that is already encrypted, as [`create_send`] does, for the test seeder (`unsafe_test_mode`).
@ -205,16 +181,14 @@ async fn get_send(send_id: SendId, headers: Headers, conn: DbConn) -> JsonResult
#[post("/sends", data = "<data>")]
async fn post_send(data: Json<SendData>, headers: Headers, conn: DbConn, nt: Notify<'_>) -> JsonResult {
enforce_disable_send_policy(&headers, &conn).await?;
let data: SendData = data.into_inner();
enforce_disable_hide_email_policy(&data, &headers, &conn).await?;
if data.r#type == SendType::File as i32 {
err!("File sends should use /api/sends/file/v2")
}
let mut send = create_send(data, headers.user.uuid)?;
let mut send = create_send(data, headers.user.uuid.clone())?;
enforce_send_policy(&send, &headers, &conn).await?;
send.save(&conn).await?;
nt.send_send_update(
UpdateType::SyncSendCreate,
@ -236,16 +210,12 @@ struct UploadDataV2<'f> {
// Upstream: https://github.com/bitwarden/server/blob/9ebe16587175b1c0e9208f84397bb75d0d595510/src/Api/Tools/Controllers/SendsController.cs#L165
#[post("/sends/file/v2", data = "<data>")]
async fn post_send_file_v2(data: Json<SendData>, headers: Headers, conn: DbConn) -> JsonResult {
enforce_disable_send_policy(&headers, &conn).await?;
let data = data.into_inner();
if data.r#type != SendType::File as i32 {
err!("Send content is not a file");
}
enforce_disable_hide_email_policy(&data, &headers, &conn).await?;
let file_length = if let Some(m) = &data.file_length {
m.into_i64()?
} else {
@ -276,7 +246,8 @@ async fn post_send_file_v2(data: Json<SendData>, headers: Headers, conn: DbConn)
err!("Send storage limit exceeded with this file");
}
let mut send = create_send(data, headers.user.uuid)?;
let mut send = create_send(data, headers.user.uuid.clone())?;
enforce_send_policy(&send, &headers, &conn).await?;
let file_id = crate::crypto::generate_send_file_id();
@ -316,8 +287,6 @@ async fn post_send_file_v2_data(
conn: DbConn,
nt: Notify<'_>,
) -> EmptyResult {
enforce_disable_send_policy(&headers, &conn).await?;
let data = data.into_inner();
let Some(send) = Send::find_by_uuid_and_user(&send_id, &headers.user.uuid, &conn).await else {
@ -327,6 +296,7 @@ async fn post_send_file_v2_data(
if send.atype != SendType::File as i32 {
err!("Send is not a file type send.");
}
enforce_send_policy(&send, &headers, &conn).await?;
let Ok(send_data) = serde_json::from_str::<SendFileData>(&send.data) else {
err!("Unable to decode send data as json.")
@ -475,10 +445,7 @@ async fn download_send(send_id: SendId, file_id: SendFileId, t: &str) -> Option<
#[put("/sends/<send_id>", data = "<data>")]
async fn put_send(send_id: SendId, data: Json<SendData>, headers: Headers, conn: DbConn, nt: Notify<'_>) -> JsonResult {
enforce_disable_send_policy(&headers, &conn).await?;
let data: SendData = data.into_inner();
enforce_disable_hide_email_policy(&data, &headers, &conn).await?;
let Some(mut send) = Send::find_by_uuid_and_user(&send_id, &headers.user.uuid, &conn).await else {
err!("Send not found", "Send send_id is invalid or does not belong to user")
@ -541,6 +508,7 @@ async fn update_send_from_data(
send.set_password(Some(&password));
}
enforce_send_policy(send, headers, conn).await?;
send.save(conn).await?;
if ut != UpdateType::None {
nt.send_send_update(ut, send, &send.update_users_revision(conn).await, &headers.device, conn).await;
@ -569,13 +537,12 @@ async fn delete_send(send_id: SendId, headers: Headers, conn: DbConn, nt: Notify
#[put("/sends/<send_id>/remove-password")]
async fn put_remove_password(send_id: SendId, headers: Headers, conn: DbConn, nt: Notify<'_>) -> JsonResult {
enforce_disable_send_policy(&headers, &conn).await?;
let Some(mut send) = Send::find_by_uuid_and_user(&send_id, &headers.user.uuid, &conn).await else {
err!("Send not found", "Invalid send uuid, or does not belong to user")
};
send.set_password(None);
enforce_send_policy(&send, &headers, &conn).await?;
send.save(&conn).await?;
nt.send_send_update(
UpdateType::SyncSendUpdate,

4
src/api/core/two_factor/authenticator.rs

@ -20,9 +20,9 @@ pub fn routes() -> Vec<Route> {
#[post("/two-factor/get-authenticator", data = "<data>")]
async fn generate_authenticator(data: Json<PasswordOrOtpData>, headers: Headers, conn: DbConn) -> JsonResult {
let user = headers.user;
let mut user = headers.user;
data.validate(&user, false, &conn).await?;
data.validate(&mut user, false, &conn).await?;
let twofactor = TwoFactor::find_by_user_and_type(&user.uuid, TwoFactorType::Authenticator, &conn).await;

4
src/api/core/two_factor/duo.rs

@ -43,9 +43,9 @@ const DISABLED_MESSAGE_DEFAULT: &str = "<To use the global Duo keys, please leav
#[post("/two-factor/get-duo", data = "<data>")]
async fn get_duo(data: Json<PasswordOrOtpData>, headers: Headers, conn: DbConn) -> JsonResult {
let data: PasswordOrOtpData = data.into_inner();
let user = headers.user;
let mut user = headers.user;
data.validate(&user, false, &conn).await?;
data.validate(&mut user, false, &conn).await?;
let (enabled, duo) = match get_user_duo_data(&user.uuid, &conn).await {
DuoStatus::Global(_) => (true, Some(DuoData::secret())),

4
src/api/core/two_factor/email.rs

@ -154,9 +154,9 @@ pub async fn send_token(user_id: &UserId, conn: &DbConn) -> EmptyResult {
#[post("/two-factor/get-email", data = "<data>")]
async fn get_email(data: Json<PasswordOrOtpData>, headers: Headers, conn: DbConn) -> JsonResult {
let data: PasswordOrOtpData = data.into_inner();
let user = headers.user;
let mut user = headers.user;
data.validate(&user, false, &conn).await?;
data.validate(&mut user, false, &conn).await?;
let (enabled, mfa_email) =
if let Some(x) = TwoFactor::find_by_user_and_type(&user.uuid, TwoFactorType::Email, &conn).await {

5
src/api/core/two_factor/mod.rs

@ -104,9 +104,9 @@ async fn get_twofactor(headers: Headers, conn: DbConn) -> Json<Value> {
#[post("/two-factor/get-recover", data = "<data>")]
async fn get_recover(data: Json<PasswordOrOtpData>, headers: Headers, conn: DbConn) -> JsonResult {
let data: PasswordOrOtpData = data.into_inner();
let user = headers.user;
let mut user = headers.user;
data.validate(&user, true, &conn).await?;
data.validate(&mut user, true, &conn).await?;
Ok(Json(json!({
"code": user.totp_recover,
@ -129,6 +129,7 @@ pub async fn check_2fa_state(user: &User, device_type: i32, ip: &std::net::IpAdd
if TwoFactor::find_by_user(&user.uuid, conn).await.is_empty() {
enforce_2fa_policy(user, &user.uuid, device_type, ip, true, conn).await?;
}
Ok(())
}

22
src/api/core/two_factor/webauthn.rs

@ -46,6 +46,14 @@ static WEBAUTHN: LazyLock<Webauthn> = LazyLock::new(|| {
webauthn.build().expect("Building Webauthn failed")
});
fn user_verification_policy() -> UserVerificationPolicy {
if CONFIG.webauthn_2fa_prefer_user_verification() {
UserVerificationPolicy::Preferred
} else {
UserVerificationPolicy::Discouraged_DO_NOT_USE
}
}
pub fn routes() -> Vec<Route> {
routes![
get_webauthn,
@ -123,9 +131,9 @@ async fn get_webauthn(data: Json<PasswordOrOtpData>, headers: Headers, conn: DbC
}
let data: PasswordOrOtpData = data.into_inner();
let user = headers.user;
let mut user = headers.user;
data.validate(&user, false, &conn).await?;
data.validate(&mut user, false, &conn).await?;
let (enabled, registrations) = get_webauthn_registrations(&user.uuid, &conn).await?;
let keys: Vec<i32> = registrations.iter().map(|r| r.id).collect();
@ -161,7 +169,8 @@ async fn generate_webauthn_challenge(data: Json<VerificationTokenData>, headers:
)?;
let mut state = serde_json::to_value(&state)?;
state["rs"]["policy"] = Value::String("discouraged".to_owned());
let user_verification_policy = user_verification_policy();
state["rs"]["policy"] = serde_json::to_value(user_verification_policy)?;
state["rs"]["extensions"].as_object_mut().unwrap().clear();
let type_ = TwoFactorType::WebauthnRegisterChallenge;
@ -171,7 +180,7 @@ async fn generate_webauthn_challenge(data: Json<VerificationTokenData>, headers:
// we need to modify some of the default settings defined by `start_passkey_registration()`.
challenge.public_key.extensions = None;
if let Some(asc) = challenge.public_key.authenticator_selection.as_mut() {
asc.user_verification = UserVerificationPolicy::Discouraged_DO_NOT_USE;
asc.user_verification = user_verification_policy;
}
let mut challenge_value = serde_json::to_value(challenge.public_key)?;
@ -425,13 +434,14 @@ pub async fn generate_webauthn_login(user_id: &UserId, conn: &DbConn) -> JsonRes
// Modify to discourage user verification
let mut state = serde_json::to_value(&state)?;
state["ast"]["policy"] = Value::String("discouraged".to_owned());
let user_verification_policy = user_verification_policy();
state["ast"]["policy"] = serde_json::to_value(user_verification_policy)?;
// Add appid, this is only needed for U2F compatibility, so maybe it can be removed as well
let app_id = format!("{}/app-id.json", CONFIG.domain());
state["ast"]["appid"] = Value::String(app_id.clone());
response.public_key.user_verification = UserVerificationPolicy::Discouraged_DO_NOT_USE;
response.public_key.user_verification = user_verification_policy;
response
.public_key
.extensions

5
src/api/core/two_factor/yubikey.rs

@ -122,9 +122,9 @@ async fn generate_yubikey(data: Json<PasswordOrOtpData>, headers: Headers, conn:
get_yubico_credentials()?;
let data: PasswordOrOtpData = data.into_inner();
let user = headers.user;
let mut user = headers.user;
data.validate(&user, false, &conn).await?;
data.validate(&mut user, false, &conn).await?;
let user_id = &user.uuid;
@ -148,6 +148,7 @@ async fn generate_yubikey(data: Json<PasswordOrOtpData>, headers: Headers, conn:
#[post("/two-factor/yubikey", data = "<data>")]
async fn activate_yubikey(data: Json<EnableYubikeyData>, headers: Headers, conn: DbConn) -> JsonResult {
let data: EnableYubikeyData = data.into_inner();
let yubikeys = parse_yubikeys(&data);
let mut user = headers.user;

14
src/api/core/webauthn_login.rs

@ -258,8 +258,8 @@ async fn get_api_webauthn(headers: Headers, conn: DbConn) -> Json<Value> {
async fn post_attestation_options(data: Json<PasswordOrOtpData>, headers: Headers, conn: DbConn) -> JsonResult {
check_passkey_creation_allowed()?;
let data: PasswordOrOtpData = data.into_inner();
let user = headers.user;
data.validate(&user, true, &conn).await?;
let mut user = headers.user;
data.validate(&mut user, true, &conn).await?;
let exclude = WebauthnCredential::find_by_user(&user.uuid, &conn)
.await
@ -299,9 +299,10 @@ async fn post_attestation_options(data: Json<PasswordOrOtpData>, headers: Header
async fn post_assertion_options(data: Json<PasswordOrOtpData>, headers: Headers, conn: DbConn) -> JsonResult {
check_webauthn_supported()?;
let data: PasswordOrOtpData = data.into_inner();
data.validate(&headers.user, true, &conn).await?;
let mut user = headers.user;
data.validate(&mut user, true, &conn).await?;
assertion_options(TokenScope::UpdateKeySet, Some(&headers.user.uuid))
assertion_options(TokenScope::UpdateKeySet, Some(&user.uuid))
}
#[derive(Deserialize)]
@ -401,9 +402,10 @@ async fn delete_credential(
conn: DbConn,
) -> EmptyResult {
let data: PasswordOrOtpData = data.into_inner();
data.validate(&headers.user, true, &conn).await?;
let mut user = headers.user;
data.validate(&mut user, true, &conn).await?;
if !WebauthnCredential::delete_by_uuid_and_user(&id, &headers.user.uuid, &conn).await? {
if !WebauthnCredential::delete_by_uuid_and_user(&id, &user.uuid, &conn).await? {
err_code!("Credential not found.", Status::NotFound.code)
}
Ok(())

30
src/api/icons.rs

@ -13,7 +13,11 @@ use reqwest::{
Client, Response,
header::{self, HeaderMap, HeaderValue},
};
use rocket::{Route, http::ContentType, response::Redirect};
use rocket::{
Route,
http::ContentType,
response::{Redirect, status::NotFound},
};
use svg_hush::{Filter, data_url_filter};
use crate::{
@ -106,33 +110,21 @@ fn icon_external(host: &str) -> Cached<Option<Redirect>> {
}
#[get("/<host>/icon.png")]
async fn icon_internal(host: &str) -> Cached<(ContentType, Vec<u8>)> {
const FALLBACK_ICON: &[u8] = include_bytes!("../static/images/fallback-icon.png");
async fn icon_internal(host: &str) -> Result<Cached<(ContentType, Vec<u8>)>, Cached<NotFound<()>>> {
let not_found = || Cached::ttl(NotFound(()), CONFIG.icon_cache_negttl(), true);
let Ok(host) = get_valid_host(host) else {
warn!("Invalid host: {}", host.escape_debug());
return Cached::ttl(
(ContentType::new("image", "png"), FALLBACK_ICON.to_vec()),
CONFIG.icon_cache_negttl(),
true,
);
return Err(not_found());
};
if should_block_host(&host).is_err() {
warn!("Blocked address: {host}");
return Cached::ttl(
(ContentType::new("image", "png"), FALLBACK_ICON.to_vec()),
CONFIG.icon_cache_negttl(),
true,
);
return Err(not_found());
}
match get_icon(&host.to_string()).await {
Some((icon, icon_type)) => {
Cached::ttl((ContentType::new("image", icon_type), icon), CONFIG.icon_cache_ttl(), true)
}
_ => Cached::ttl((ContentType::new("image", "png"), FALLBACK_ICON.to_vec()), CONFIG.icon_cache_negttl(), true),
}
let (icon, icon_type) = get_icon(&host.to_string()).await.ok_or_else(not_found)?;
Ok(Cached::ttl((ContentType::new("image", icon_type), icon), CONFIG.icon_cache_ttl(), true))
}
async fn get_icon(domain: &str) -> Option<(Vec<u8>, String)> {

64
src/api/identity.rs

@ -14,7 +14,7 @@ use crate::{
api::{
ApiResult, EmptyResult, JsonResult,
core::{
accounts::{PreloginData, RegisterData, kdf_upgrade, prelogin, register},
accounts::{PreloginData, RegisterData, prelogin, register},
log_user_event,
two_factor::{
authenticator, duo_oidc, email, enforce_2fa_policy, is_twofactor_provider_usable, webauthn, yubikey,
@ -475,32 +475,11 @@ async fn password_login(
// Change the KDF Iterations (only when not logging in with an auth request)
if data.auth_request.is_none() {
kdf_upgrade(&mut user, password, conn).await?;
user.check_persist_kdf_upgrade(password, conn).await?;
}
let now = Utc::now().naive_utc();
if user.verified_at.is_none() && CONFIG.mail_enabled() && CONFIG.signups_verify() {
if user
.last_verifying_at
.is_none_or(|d| now.signed_duration_since(d).num_seconds() > i64::from(CONFIG.signups_verify_resend_time()))
{
let resend_limit = i32::from(CONFIG.signups_verify_resend_limit());
if resend_limit == 0 || user.login_verify_count < resend_limit {
// We want to send another email verification if we require signups to verify
// their email address, and we haven't sent them a reminder in a while...
user.last_verifying_at = Some(now);
user.login_verify_count += 1;
if let Err(e) = user.save(conn).await {
error!("Error updating user: {e:#?}");
}
if let Err(e) = mail::send_verify_email(&user.email, &user.uuid).await {
error!("Error auto-sending email verification email: {e:#?}");
}
}
}
resend_verify_email(&mut user, conn).await;
// We still want the login to fail until they actually verified the email address
err!(
@ -548,7 +527,7 @@ async fn passkey_login(
err!("Passkey login is not available")
}
let (user, credential) = webauthn_login::assert_login(
let (mut user, credential) = webauthn_login::assert_login(
data.token.as_deref().unwrap_or_default(),
data.device_response.as_deref().unwrap_or_default(),
&ip.ip,
@ -573,9 +552,11 @@ async fn passkey_login(
check_client_version(&user, client_header)?;
if user.verified_at.is_none() && CONFIG.mail_enabled() && CONFIG.signups_verify() {
resend_verify_email(&mut user, conn).await;
err!(
"Please verify your email before trying again.",
format!("IP: {}. Username: {log_username}.", ip.ip),
format!("IP: {}. Username: {}.", ip.ip, user.email.escape_debug()),
ErrorEvent {
event: EventType::UserFailedLogIn
}
@ -598,6 +579,30 @@ async fn passkey_login(
Ok(result)
}
/// For a login refused because the email isn't verified yet: sends another verification email, at most once per
/// `SIGNUPS_VERIFY_RESEND_TIME` and `SIGNUPS_VERIFY_RESEND_LIMIT` times in all (0 for no limit).
async fn resend_verify_email(user: &mut User, conn: &DbConn) {
let now = Utc::now().naive_utc();
if user
.last_verifying_at
.is_none_or(|d| now.signed_duration_since(d).num_seconds() > i64::from(CONFIG.signups_verify_resend_time()))
{
let resend_limit = i32::from(CONFIG.signups_verify_resend_limit());
if resend_limit == 0 || user.login_verify_count < resend_limit {
user.last_verifying_at = Some(now);
user.login_verify_count += 1;
if let Err(e) = user.save(conn).await {
error!("Error updating user: {e:#?}");
}
if let Err(e) = mail::send_verify_email(&user.email, &user.uuid).await {
error!("Error auto-sending email verification email: {e:#?}");
}
}
}
}
/// Like upstream's `ClientVersionValidator`, every login needs the `Bitwarden-Client-Version` header, and a V2 account
/// ([`User::has_v2_encryption`]) a client of at least 2026.10.1 (2026.10.2 for the desktop app). Called right after the
/// credentials are checked, like upstream, so that it doesn't tell anyone else which accounts are V2.
@ -684,7 +689,12 @@ async fn authenticated_response(
// register push device
if !device.is_new() {
register_push_device(device, conn).await?;
// Registering the device for push is best-effort: a failure talking to the
// push relay/identity server must not turn a successful authentication into
// an error (see #7371). This mirrors the new-device email handling above.
if let Err(e) = register_push_device(device, conn).await {
error!("An error occurred while registering the device for push notifications: {e}");
}
}
// Save to update `device.updated_at` to track usage and toggle new status

4
src/api/mod.rs

@ -63,7 +63,7 @@ impl PasswordOrOtpData {
/// Tokens used via this struct can be used multiple times during the process
/// First for the validation to continue, after that to enable or validate the following actions
/// This is different per caller, so it can be adjusted to delete the token or not
pub async fn validate(&self, user: &User, delete_if_valid: bool, conn: &DbConn) -> EmptyResult {
pub async fn validate(&self, user: &mut User, delete_if_valid: bool, conn: &DbConn) -> EmptyResult {
use crate::api::core::two_factor::protected_actions::validate_protected_action_otp;
match (self.master_password_hash.as_deref(), self.otp.as_deref()) {
@ -71,6 +71,8 @@ impl PasswordOrOtpData {
if !user.check_valid_password(pw_hash) {
err!("Invalid password");
}
user.check_persist_kdf_upgrade(pw_hash, conn).await?;
}
(None, Some(otp)) => {
validate_protected_action_otp(otp, &user.uuid, delete_if_valid, conn).await?;

69
src/config.rs

@ -71,9 +71,16 @@ macro_rules! make_config {
( @type $ty:ty, option) => { Option<$ty> };
( @type $ty:ty, $id:ident) => { $ty };
// Options that only builds with the `unsafe_test_mode` feature read
( @test_only test_def ) => { true };
( @test_only $none_action:ident ) => { false };
// Generate the values depending on none_action
( @build $value:expr, $config:expr, option, ) => { $value };
( @build $value:expr, $config:expr, def, $default:expr ) => { $value.unwrap_or($default) };
( @build $value:expr, $config:expr, test_def, $default:expr ) => {
if cfg!(feature = "unsafe_test_mode") { $value.unwrap_or($default) } else { $default }
};
( @build $value:expr, $config:expr, auto, $default_fn:expr ) => {{
match $value {
Some(v) => v,
@ -286,6 +293,22 @@ macro_rules! make_config {
)+)+
}
/// Warns about each set `test_def` option in a build without the `unsafe_test_mode` feature, which ignores them.
fn warn_test_only_options(&self) {
if cfg!(feature = "unsafe_test_mode") {
return;
}
$($(
if make_config! { @test_only $none_action } && self.$name.is_some() {
// We can't use warn! here because logging isn't setup yet.
println!(
"[WARNING] {} is only read by builds with the `unsafe_test_mode` feature, ignoring it.",
pastey::paste!(stringify!([<$name:upper>]))
);
}
)+)+
}
/// Merges the values of both builders into a new builder.
/// If both have the same element, `other` wins.
fn merge(&self, other: &Self, show_overrides: bool, overrides: &mut Vec<&str>) -> Self {
@ -352,6 +375,8 @@ macro_rules! make_config {
r#type: &'static str,
doc: ElementDoc,
overridden: bool,
#[serde(skip)]
test_only: bool,
}
#[derive(Serialize)]
@ -411,10 +436,20 @@ macro_rules! make_config {
r#type: get_form_type(stringify!($ty)),
doc: get_doc(concat!($($doc),+)),
overridden: overridden.contains(&pastey::paste!(stringify!([<$name:upper>]))),
test_only: make_config! { @test_only $none_action },
},
)+], // End of elements repetition
},
)+]; // End of groups repetition
// Options only test builds read aren't shown in the others
let data: Vec<GroupData> = data
.into_iter()
.map(|mut group| {
group.elements.retain(|e| !e.test_only || cfg!(feature = "unsafe_test_mode"));
group
})
.collect();
serde_json::to_value(data).unwrap()
}
@ -513,6 +548,8 @@ macro_rules! make_config {
//
// Where action applied when the value wasn't provided and can be:
// def: Use a default value
// test_def: Use a default value, which only builds with the `unsafe_test_mode` feature let you change. Other builds
// warn at startup when it's set, ignore it, and don't show it in the admin panel
// auto: Value is auto generated based on other values
// option: Value is optional
// generated: Value is always autogenerated and it's original value ignored
@ -682,6 +719,8 @@ make_config! {
client {
/// Control whether clients onboarding interstitials are suppressed |> post-login welcome dialogs, extension install prompts, setup extension redirects, and premium upsell modals
client_suppress_onboarding: bool, true, def, false;
/// In most cases this value is set by the client |> Will block clients from setting too low of a value in `accounts::post_kdf`
client_kdf_iter: i32, false, test_def, 600_000;
},
/// Advanced settings
@ -697,6 +736,7 @@ make_config! {
/// running on the same host or container network), the string "all" to accept it from anywhere,
/// or a comma separated list of IPs and CIDR ranges. For a list header like X-Forwarded-For, the
/// client IP is the rightmost address that isn't a trusted proxy, so list every proxy in the chain.
/// "local" also trusts 6to4, Teredo and local-use NAT64 addresses, which can carry clients from anywhere.
ip_header_trusted_proxies: String, true, def, "local".to_owned();
/// Icon service |> The predefined icon services are: internal, bitwarden, duckduckgo, google.
/// To specify a custom icon service, set a URL template with exactly one instance of `{}`,
@ -731,7 +771,8 @@ make_config! {
/// Useful to hide other servers in the local network. Check the WIKI for more details
http_request_block_regex: String, true, option;
/// Block non global IPs |> Enabling this will cause the internal HTTP client to refuse to connect to any non global IP address.
/// Useful to secure your internal environment: See https://en.wikipedia.org/wiki/Reserved_IP_addresses for a list of IPs which it will block
/// Useful to secure your internal environment: See https://en.wikipedia.org/wiki/Reserved_IP_addresses for a list of IPs which it will block.
/// Requests through an outbound proxy (HTTP_PROXY, HTTPS_PROXY or ALL_PROXY) aren't checked, because the proxy resolves the names.
http_request_block_non_global_ips: bool, true, auto, |c| c.icon_blacklist_non_global_ips;
/// Disable Two-Factor remember |> Enabling this would force the users to use a second factor to login every time.
@ -740,6 +781,9 @@ make_config! {
/// Two-Factor remember duration |> Number of days before a remembered Two-Factor login expires (min: 1, max: 90).
two_factor_remember_days: i64, true, def, 30;
/// Enable WebAuthn 2FA prefer user verification |> Sets user verification to preferred instead of discouraged, improving compatibility with some security keys.
webauthn_2fa_prefer_user_verification: bool, true, def, false;
/// Disable authenticator time drifted codes to be valid |> Enabling this only allows the current TOTP code to be valid
/// TOTP codes of the previous and next 30 seconds will be invalid.
authenticator_disable_time_drift: bool, true, def, false;
@ -836,7 +880,7 @@ make_config! {
/// Enforce Single Org with Reset Password Policy |> Enforce that the Single Org policy is enabled before setting the Reset Password policy
/// Bitwarden enforces this by default. In Vaultwarden we encouraged to use multiple organizations because groups were not available.
/// Setting this to true will enforce the Single Org Policy to be enabled before you can enable the Reset Password policy.
enforce_single_org_with_reset_pw_policy: bool, false, def, false;
enforce_single_org_with_reset_pw_policy: bool, false, def, true;
/// Prefer IPv6 (AAAA) resolving |> This settings configures the DNS resolver to resolve IPv6 first, and if not available try IPv4
/// This could be useful in IPv6 only environments.
@ -966,6 +1010,17 @@ make_config! {
},
}
fn check_iterations(iterations: i32, key: &str) -> Result<(), Error> {
if iterations < 100_000 {
#[cfg(feature = "unsafe_test_mode")]
println!("[WARNING] {key} should be at least 100000 or higher. The default is 600000!");
#[cfg(not(feature = "unsafe_test_mode"))]
err!(format!("{key} should be at least 100000 or higher. The default is 600000!"));
}
Ok(())
}
fn validate_config(cfg: &ConfigItems, on_update: bool) -> Result<(), Error> {
// Validate connection URL is valid and DB feature is enabled
#[cfg(sqlite)]
@ -1000,9 +1055,8 @@ fn validate_config(cfg: &ConfigItems, on_update: bool) -> Result<(), Error> {
}
}
if cfg.password_iterations < 100_000 {
err!("PASSWORD_ITERATIONS should be at least 100000 or higher. The default is 600000!");
}
check_iterations(cfg.password_iterations, "PASSWORD_ITERATIONS")?;
check_iterations(cfg.client_kdf_iter, "CLIENT_KDF_ITER")?;
let limit = 256;
if !(1..=limit).contains(&cfg.database_max_conns) {
@ -1519,6 +1573,7 @@ pub const SUPPORTED_FEATURE_FLAGS: &[&str] = &[
"windows-desktop-autotype",
"windows-desktop-autotype-ga",
// Key Management Team
"innovation-sprint-shared-unlock-part-2",
"biometrics-sdk-ipc",
"windows-native-credential-sync",
"macos-native-credential-sync",
@ -1528,6 +1583,9 @@ pub const SUPPORTED_FEATURE_FLAGS: &[&str] = &[
"pm-34171-card-scanner",
// Platform Team
"pm-30529-webauthn-related-origins",
"content-script-ipc-channel-framework",
// Tools Team: read by the clients up to 2026.10 and by the Android and iOS apps
"pm-31885-send-controls",
// Vault Team
"pm-32009-new-item-types",
];
@ -1568,6 +1626,7 @@ impl Config {
// Fill any missing with defaults
let config = builder.build();
if !SKIP_CONFIG_VALIDATION.load(Ordering::Relaxed) {
builder.warn_test_only_options();
validate_config(&config, false)?;
}

21
src/db/models/auth_request.rs

@ -4,6 +4,7 @@ use diesel::prelude::*;
use serde_json::Value;
use crate::{
CONFIG,
api::{ApiResult, EmptyResult},
crypto::ct_eq,
db::{DbConn, schema::auth_requests},
@ -12,7 +13,7 @@ use crate::{
};
use macros::UuidFromParam;
use super::{DeviceId, OrganizationId, UserId};
use super::{DeviceId, DeviceType, OrganizationId, UserId};
#[derive(Identifiable, Queryable, Insertable, AsChangeset, Deserialize, Serialize)]
#[diesel(table_name = auth_requests)]
@ -73,6 +74,24 @@ impl AuthRequest {
}
}
pub fn to_json(&self) -> Value {
json!({
"id": self.uuid,
"publicKey": self.public_key,
"requestDeviceIdentifier": self.request_device_identifier,
"requestDeviceTypeValue": self.device_type,
"requestDeviceType": DeviceType::from_i32(self.device_type).to_string(),
"requestIpAddress": self.request_ip,
"key": self.enc_key,
"masterPasswordHash": self.master_password_hash,
"creationDate": format_date(&self.creation_date),
"responseDate": self.response_date.as_ref().map(format_date),
"requestApproved": self.approved.unwrap_or(false),
"origin": CONFIG.domain_origin(),
"object": "auth-request"
})
}
pub fn to_json_for_pending_device(&self) -> Value {
json!({
"id": self.uuid,

6
src/db/models/collection.rs

@ -995,11 +995,7 @@ impl CollectionMembership {
"id": self.membership_uuid,
"readOnly": self.read_only,
"hidePasswords": self.hide_passwords,
"manage": membership_type >= MembershipType::Admin
|| self.manage
|| (membership_type == MembershipType::Manager
&& !self.read_only
&& !self.hide_passwords),
"manage": membership_type >= MembershipType::Admin || self.manage,
})
}
}

56
src/db/models/org_policy.rs

@ -17,7 +17,9 @@ use crate::{
use super::{Membership, MembershipId, MembershipStatus, MembershipType, OrganizationId, TwoFactor, UserId};
#[derive(Identifiable, Queryable, Insertable, AsChangeset)]
mod send_controls;
#[derive(Clone, Identifiable, Queryable, Insertable, AsChangeset)]
#[diesel(table_name = org_policies)]
#[diesel(primary_key(uuid))]
pub struct OrgPolicy {
@ -29,7 +31,7 @@ pub struct OrgPolicy {
pub revision_date: NaiveDateTime,
}
// https://github.com/bitwarden/server/blob/9ebe16587175b1c0e9208f84397bb75d0d595510/src/Core/AdminConsole/Enums/PolicyType.cs
// https://github.com/bitwarden/server/blob/b0f5bc64436a2457e1e8898e65c7e9e40ba94d7a/src/Core/AdminConsole/Enums/PolicyType.cs
#[derive(Copy, Clone, Eq, PartialEq, num_derive::FromPrimitive)]
pub enum OrgPolicyType {
TwoFactorAuthentication = 0,
@ -53,13 +55,14 @@ pub enum OrgPolicyType {
// AutoConfirm = 18, // Not supported (not implemented yet)
// BlockClaimedDomainAccountCreation = 19, // Not supported (Not AGPLv3 Licensed)
OrganizationUserNotification = 20,
// SendControls = 21, // Not supported yet
SendControls = 21,
FillAssist = 22,
AutotypeGaPolicy = 23,
}
// https://github.com/bitwarden/server/blob/9ebe16587175b1c0e9208f84397bb75d0d595510/src/Core/AdminConsole/Models/Data/Organizations/Policies/SendOptionsPolicyData.cs#L5
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Default, Deserialize, Serialize)]
#[serde(default, rename_all = "camelCase")]
pub struct SendOptionsPolicyData {
#[serde(rename = "disableHideEmail", alias = "DisableHideEmail")]
pub disable_hide_email: bool,
@ -270,28 +273,6 @@ impl OrgPolicy {
.await
}
pub async fn find_confirmed_by_user_and_active_policy(
user_uuid: &UserId,
policy_type: OrgPolicyType,
conn: &DbConn,
) -> Vec<Self> {
conn.run(move |conn| {
org_policies::table
.inner_join(
users_organizations::table.on(users_organizations::org_uuid
.eq(org_policies::org_uuid)
.and(users_organizations::user_uuid.eq(user_uuid))),
)
.filter(users_organizations::status.eq(MembershipStatus::Confirmed as i32))
.filter(org_policies::atype.eq(policy_type as i32))
.filter(org_policies::enabled.eq(true))
.select(org_policies::all_columns)
.load::<Self>(conn)
.expect("Error loading org_policy")
})
.await
}
/// Returns true if the user belongs to an org that has enabled the specified policy type,
/// and the user is not an owner or admin of that org. This is only useful for checking
/// applicability of policy types that have these particular semantics.
@ -381,27 +362,6 @@ impl OrgPolicy {
false
}
/// Returns true if the user belongs to an org that has enabled the `DisableHideEmail`
/// option of the `Send Options` policy, and the user is not an owner or admin of that org.
pub async fn is_hide_email_disabled(user_uuid: &UserId, conn: &DbConn) -> bool {
for policy in Self::find_confirmed_by_user_and_active_policy(user_uuid, OrgPolicyType::SendOptions, conn).await
{
if let Some(user) = Membership::find_confirmed_by_user_and_org(user_uuid, &policy.org_uuid, conn).await
&& user.atype < MembershipType::Admin
{
match serde_json::from_str::<SendOptionsPolicyData>(&policy.data) {
Ok(opts) => {
if opts.disable_hide_email {
return true;
}
}
_ => error!("Failed to deserialize SendOptionsPolicyData: {}", policy.data),
}
}
}
false
}
pub async fn is_enabled_for_member(member_uuid: &MembershipId, policy_type: OrgPolicyType, conn: &DbConn) -> bool {
if let Some(member) = Membership::find_by_uuid(member_uuid, conn).await
&& let Some(policy) = Self::find_by_org_and_type(&member.org_uuid, policy_type, conn).await

289
src/db/models/org_policy/send_controls.rs

@ -0,0 +1,289 @@
//! The Send controls policy (21) absorbs the legacy `Disable Send` (6) and `Send Options` (7) policies.
//! Like upstream, the three are kept in sync in both directions, so clients that only know the legacy
//! policies keep enforcing the same rules, and Sends are checked against all of them.
//!
//! https://github.com/bitwarden/server/tree/04a4d7548b07d18ab7327ddaae81a05fd893a820/src/Core/AdminConsole/OrganizationFeatures/Policies
use chrono::TimeDelta;
use diesel::prelude::*;
use num_traits::FromPrimitive;
use serde::Deserialize;
use serde_json::Value;
use super::{OrgPolicy, OrgPolicyType, SendOptionsPolicyData};
use crate::{
api::{ApiResult, EmptyResult},
db::{
DbConn,
models::{MembershipStatus, MembershipType, OrganizationId, Send, SendType, UserId},
schema::{org_policies, users_organizations},
},
};
const SEND_POLICIES: [i32; 3] =
[OrgPolicyType::DisableSend as i32, OrgPolicyType::SendOptions as i32, OrgPolicyType::SendControls as i32];
// SendWhoCanAccessType. Specific people requires Sends with email verification, which are not supported.
const ACCESS_ANY: i32 = 0;
const ACCESS_PASSWORD: i32 = 1;
const ACCESS_SPECIFIC_PEOPLE: i32 = 2;
// https://github.com/bitwarden/server/blob/04a4d7548b07d18ab7327ddaae81a05fd893a820/src/Core/AdminConsole/Models/Data/Organizations/Policies/SendControlsPolicyData.cs
#[derive(Default, Deserialize, Serialize)]
#[serde(default, rename_all = "camelCase")]
struct SendControlsPolicyData {
#[serde(alias = "DisableSend")]
disable_send: bool,
#[serde(alias = "DisableHideEmail")]
disable_hide_email: bool,
#[serde(alias = "WhoCanAccess")]
who_can_access: Option<i32>,
#[serde(alias = "AllowedDomains")]
allowed_domains: Option<String>,
#[serde(alias = "DeletionHours")]
deletion_hours: Option<i32>,
#[serde(alias = "AllowedSendTypes")]
allowed_send_types: Option<Vec<i32>>,
}
impl SendControlsPolicyData {
/// Validates the data an organization saves. Requiring email verification, which allowed domains
/// depend on, would leave members unable to create any Send, so it is refused.
fn parse(data: Option<&Value>) -> ApiResult<Self> {
let data = match Option::<Self>::deserialize(data.unwrap_or(&Value::Null)) {
Ok(data) => data.unwrap_or_default(),
Err(e) => err!(format!("Invalid Send controls policy data: {e}")),
};
match data.who_can_access {
None | Some(ACCESS_ANY | ACCESS_PASSWORD) => (),
Some(ACCESS_SPECIFIC_PEOPLE) => {
err!("Sends with email verification are not supported, so that access type cannot be required")
}
Some(_) => err!("Invalid Send controls access type"),
}
if data.allowed_domains.is_some() {
err!("Allowed domains require Sends with email verification, which are not supported")
}
if data.deletion_hours.is_some_and(|hours| hours < 1) {
err!("The maximum lifetime of a Send has to be at least one hour")
}
// Current clients may also list Item Sends (2), which can not be created here.
if let Some(types) = &data.allowed_send_types
&& (types.iter().any(|t| !(0..=2).contains(t))
|| !types.iter().any(|t| *t == SendType::Text as i32 || *t == SendType::File as i32))
{
err!("The allowed Send types have to include Text or File")
}
Ok(data)
}
/// Every organization's restrictions apply, so a less strict organization never relaxes a stricter
/// one, independent of the order the policies are loaded in.
fn merge(&mut self, other: Self) {
self.disable_send |= other.disable_send;
self.disable_hide_email |= other.disable_hide_email;
self.who_can_access = self.who_can_access.max(other.who_can_access);
self.deletion_hours = match (self.deletion_hours, other.deletion_hours) {
(Some(a), Some(b)) => Some(a.min(b)),
(a, b) => a.or(b),
};
self.allowed_send_types = match (self.allowed_send_types.take(), other.allowed_send_types) {
(Some(a), Some(b)) => Some(a.into_iter().filter(|t| b.contains(t)).collect()),
(a, b) => a.or(b),
};
}
/// Checks the Send as it would be saved, like upstream's `SendValidationService`.
fn check_send(&self, send: &Send) -> EmptyResult {
if self.disable_send {
err!("Due to an Enterprise Policy, you are only able to delete an existing Send.")
}
if self.disable_hide_email && send.hide_email.unwrap_or(false) {
err!(
"Due to an Enterprise Policy, you are not allowed to hide your email address \
from recipients when creating or editing a Send."
)
}
if self.who_can_access == Some(ACCESS_PASSWORD) && send.password_hash.is_none() {
err!("Due to an Enterprise policy your Sends must be protected by password")
}
if let Some(types) = &self.allowed_send_types
&& !types.contains(&send.atype)
{
let names: Vec<&str> = types
.iter()
.map(|t| match *t {
0 => "Text",
1 => "File",
_ => "Unknown",
})
.collect();
err!(format!("Due to an Enterprise policy your Sends must be of the following types: {}", names.join(", ")))
}
// Upstream allows for up to a minute of skew between the deletion and the creation date.
if let Some(hours) = self.deletion_hours
&& send.deletion_date - send.creation_date - TimeDelta::minutes(1) > TimeDelta::hours(i64::from(hours))
{
let (duration, unit) = if hours >= 24 {
(hours / 24, "day")
} else {
(hours, "hour")
};
let plural = if duration > 1 {
"s"
} else {
""
};
err!(format!(
"Due to an Enterprise policy your Sends must have deletion dates no more than {duration} {unit}{plural} from their creation dates"
))
}
Ok(())
}
}
/// Whether an enabled `Send Options` policy disables hiding the email. Unreadable data keeps the option on.
fn hide_email_disabled(policy: &OrgPolicy) -> bool {
policy.enabled
&& serde_json::from_str::<Option<SendOptionsPolicyData>>(&policy.data).map_or_else(
|_| {
error!("Failed to deserialize SendOptionsPolicyData: {}", policy.data);
true
},
|data| data.is_some_and(|d| d.disable_hide_email),
)
}
/// The options of the legacy policies, as Send controls holds them. A disabled `Send Options` policy
/// counts as off, so a later save of Send controls does not switch its stored option back on.
fn legacy_send_options(policies: &[OrgPolicy]) -> (bool, bool) {
let disable_send = policies.iter().any(|p| p.has_type(OrgPolicyType::DisableSend) && p.enabled);
let disable_hide_email = policies.iter().any(|p| p.has_type(OrgPolicyType::SendOptions) && hide_email_disabled(p));
(disable_send, disable_hide_email)
}
/// Mirrors a saved Send policy into the others, like upstream's `SendControlsSyncPolicyEvent`,
/// `DisableSendSyncPolicyEvent` and `SendOptionsSyncPolicyEvent`, and returns the policies to save.
/// `policies` are the organization's policies, including the saved one.
fn mirror_send_policies(saved: &OrgPolicy, policies: &[OrgPolicy]) -> ApiResult<Vec<OrgPolicy>> {
let find_or_new = |policy_type| {
policies
.iter()
.find(|p| p.has_type(policy_type))
.cloned()
.unwrap_or_else(|| OrgPolicy::new(saved.org_uuid.clone(), policy_type, false, String::from("null")))
};
if saved.has_type(OrgPolicyType::SendControls) {
let data = saved.send_controls_data();
let mut disable_send = find_or_new(OrgPolicyType::DisableSend);
disable_send.enabled = saved.enabled && data.disable_send;
let mut send_options = find_or_new(OrgPolicyType::SendOptions);
send_options.enabled = saved.enabled && data.disable_hide_email;
send_options.data = serde_json::to_string(&SendOptionsPolicyData {
disable_hide_email: data.disable_hide_email,
})?;
return Ok(vec![disable_send, send_options]);
}
let mut controls = find_or_new(OrgPolicyType::SendControls);
let mut data = controls.send_controls_data();
(data.disable_send, data.disable_hide_email) = legacy_send_options(policies);
// Turning a legacy policy off must not switch off the restrictions only Send controls has.
controls.enabled |= data.disable_send || data.disable_hide_email;
controls.data = serde_json::to_string(&data)?;
Ok(vec![controls])
}
impl OrgPolicy {
/// Stored data was validated when saved; data that can not be read blocks Sends instead of allowing them.
fn send_controls_data(&self) -> SendControlsPolicyData {
let data = serde_json::from_str::<Value>(&self.data).ok();
data.and_then(|data| SendControlsPolicyData::parse(Some(&data)).ok()).unwrap_or_else(|| {
error!("Invalid Send controls policy data, blocking Sends: {}", self.data);
SendControlsPolicyData {
disable_send: true,
..Default::default()
}
})
}
/// Validates the data of a Send policy before it is saved and returns the data to store.
pub fn send_policy_data(policy_type: OrgPolicyType, data: Option<Value>) -> ApiResult<Option<Value>> {
match policy_type {
OrgPolicyType::SendControls => {
Ok(Some(serde_json::to_value(SendControlsPolicyData::parse(data.as_ref())?)?))
}
OrgPolicyType::SendOptions => {
if let Some(value) = &data
&& let Err(e) = Option::<SendOptionsPolicyData>::deserialize(value)
{
err!(format!("Invalid Send options policy data: {e}"))
}
Ok(data)
}
_ => Ok(data),
}
}
/// Keeps Send controls and the legacy Send policies in sync after one of them was saved.
pub async fn sync_send_policies(saved: &Self, conn: &DbConn) -> EmptyResult {
if !SEND_POLICIES.contains(&saved.atype) {
return Ok(());
}
for mut policy in mirror_send_policies(saved, &Self::find_by_org(&saved.org_uuid, conn).await)? {
policy.save(conn).await?;
}
Ok(())
}
/// Upstream's `PolicyQuery`: until Send controls is saved, it is derived from the legacy policies, so the
/// current policy editor shows what is enforced instead of turning it off on the next save.
pub fn synthesize_send_controls(org_id: &OrganizationId, policies: &[Self]) -> Self {
let (disable_send, disable_hide_email) = legacy_send_options(policies);
let data = SendControlsPolicyData {
disable_send,
disable_hide_email,
..Default::default()
};
Self::new(
org_id.clone(),
OrgPolicyType::SendControls,
disable_send || disable_hide_email,
json!(data).to_string(),
)
}
/// Enforces the Send policies of every organization in which the user is an accepted or confirmed
/// member below Admin on the Send as it would be saved. Deleting a Send stays possible.
pub async fn check_send(user_id: &UserId, send: &Send, conn: &DbConn) -> EmptyResult {
let policies = conn
.run(move |conn| {
org_policies::table
.inner_join(users_organizations::table.on(users_organizations::org_uuid.eq(org_policies::org_uuid)))
.filter(users_organizations::user_uuid.eq(user_id))
.filter(
users_organizations::status
.eq_any([MembershipStatus::Accepted as i32, MembershipStatus::Confirmed as i32]),
)
// Owners and admins are exempt. The numbers of MembershipType are not its order.
.filter(users_organizations::atype.ne(MembershipType::Owner as i32))
.filter(users_organizations::atype.ne(MembershipType::Admin as i32))
.filter(org_policies::enabled.eq(true))
.filter(org_policies::atype.eq_any(SEND_POLICIES))
.select(org_policies::all_columns)
.load::<Self>(conn)
})
.await?;
let mut controls = SendControlsPolicyData::default();
for policy in policies {
match OrgPolicyType::from_i32(policy.atype) {
Some(OrgPolicyType::DisableSend) => controls.disable_send = true,
Some(OrgPolicyType::SendOptions) => controls.disable_hide_email |= hide_email_disabled(&policy),
_ => controls.merge(policy.send_controls_data()),
}
}
controls.check_send(send)
}
}

6
src/db/models/organization.rs

@ -811,6 +811,7 @@ impl Membership {
"useResetPassword": CONFIG.mail_enabled(),
"ssoBound": false, // Not supported
"useSso": false, // Not supported
"ssoEnabled": false,
"useKeyConnector": false,
"useSecretsManager": false, // Not supported (Not AGPLv3 Licensed)
"usePasswordManager": true,
@ -824,6 +825,7 @@ impl Membership {
"useOrganizationDomains": false, // Not supported (Linked to SSO)
"usePam": false, // Not supported
"usePhishingBlocker": false,
"useAutomaticUserConfirmation": false,
"organizationUserId": self.uuid,
"providerId": null,
@ -831,6 +833,7 @@ impl Membership {
"providerType": null,
"familySponsorshipFriendlyName": null,
"familySponsorshipAvailable": false,
"isAdminInitiated": false,
"productTierType": 3, // Enterprise tier
"keyConnectorEnabled": false,
"keyConnectorUrl": null,
@ -838,6 +841,7 @@ impl Membership {
"familySponsorshipValidUntil": null,
"familySponsorshipToDelete": null,
"accessSecretsManager": false,
"accessPam": false,
// limit collection creation to managers with access_all permission to prevent issues
"limitCollectionCreation": self.atype < MembershipType::Manager || !self.access_all,
"limitCollectionDeletion": true,
@ -905,7 +909,7 @@ impl Membership {
"id": cu.collection_uuid,
"readOnly": cu.read_only,
"hidePasswords": cu.hide_passwords,
"manage": cu.manage || (self.atype == MembershipType::Manager && !cu.read_only && !cu.hide_passwords),
"manage": cu.manage,
})
})
.collect()

33
src/db/models/user.rs

@ -2,6 +2,7 @@ use chrono::{NaiveDateTime, TimeDelta, Utc};
use derive_more::{AsRef, Deref, Display, From};
use diesel::prelude::*;
use serde_json::Value;
use std::cmp;
use crate::{
CONFIG,
@ -133,7 +134,6 @@ impl UserStampException {
/// Local methods
impl User {
pub const CLIENT_KDF_TYPE_DEFAULT: i32 = UserKdfType::Pbkdf2 as i32;
pub const CLIENT_KDF_ITER_DEFAULT: i32 = 600_000;
pub fn new(email: &str, name: Option<String>) -> Self {
let now = Utc::now().naive_utc();
@ -171,7 +171,7 @@ impl User {
excluded_globals: "[]".to_owned(),
client_kdf_type: Self::CLIENT_KDF_TYPE_DEFAULT,
client_kdf_iter: Self::CLIENT_KDF_ITER_DEFAULT,
client_kdf_iter: CONFIG.client_kdf_iter(),
client_kdf_memory: None,
client_kdf_parallelism: None,
@ -248,6 +248,7 @@ impl User {
allow_next_route: Option<Vec<String>>,
conn: &DbConn,
) -> EmptyResult {
self.password_iterations = cmp::max(self.password_iterations, CONFIG.password_iterations());
self.password_hash =
crypto::hash_password(password.as_bytes(), &self.salt, self.password_iterations.cast_unsigned());
@ -477,6 +478,34 @@ impl User {
}
}
pub async fn check_persist_kdf_upgrade(&mut self, pwd_hash: &str, conn: &DbConn) -> EmptyResult {
if self.password_iterations < CONFIG.password_iterations() {
let old_iteration = self.password_iterations;
let old_hash = self.password_hash.clone();
self.set_password(pwd_hash, None, false, None, conn).await?;
conn.run(move |conn| {
diesel::update(
users::table
.filter(users::uuid.eq(&self.uuid))
.filter(users::password_iterations.eq(old_iteration))
.filter(users::password_hash.eq(old_hash)),
)
.set((
users::updated_at.eq(Utc::now().naive_utc()),
users::password_iterations.eq(&self.password_iterations),
users::password_hash.eq(&self.password_hash),
))
.execute(conn)
.map_res("Error updating user KDF iterations")
})
.await
} else {
Ok(())
}
}
pub async fn delete(&self, conn: &DbConn) -> EmptyResult {
for member in Membership::find_confirmed_by_user(&self.uuid, conn).await {
if member.atype == MembershipType::Owner

5
src/sso_client.rs

@ -246,14 +246,13 @@ impl Client {
let mut exchange = self.core_client.exchange_code(oidc_code);
Self::check_client_verifier(&client_verifier, sso_auth)?;
if CONFIG.sso_pkce() {
exchange = exchange.set_pkce_verifier(PkceCodeVerifier::new(client_verifier.into()));
} else {
Self::check_client_verifier(&client_verifier, sso_auth)?;
}
match exchange.request_async(&self.http_client).await {
Err(err) => err!(format!("Failed to contact token endpoint: {:?}", err)),
Err(err) => err!(format!("Failed to contact token endpoint: {err}")),
Ok(token_response) => {
let oidc_nonce = Nonce::new(sso_auth.nonce.clone());

664
src/static/global_domains.json

@ -1,31 +1,4 @@
[
{
"type": 2,
"domains": [
"ameritrade.com",
"tdameritrade.com"
],
"excluded": false
},
{
"type": 3,
"domains": [
"bankofamerica.com",
"bofa.com",
"mbna.com",
"usecfo.com"
],
"excluded": false
},
{
"type": 4,
"domains": [
"sprint.com",
"sprintpcs.com",
"nextel.com"
],
"excluded": false
},
{
"type": 0,
"domains": [
@ -43,15 +16,6 @@
],
"excluded": false
},
{
"type": 5,
"domains": [
"wellsfargo.com",
"wf.com",
"wellsfargoadvisors.com"
],
"excluded": false
},
{
"type": 6,
"domains": [
@ -61,40 +25,6 @@
],
"excluded": false
},
{
"type": 7,
"domains": [
"accountonline.com",
"citi.com",
"citibank.com",
"citicards.com",
"citibankonline.com"
],
"excluded": false
},
{
"type": 8,
"domains": [
"cnet.com",
"cnettv.com",
"com.com",
"download.com",
"news.com",
"search.com",
"upload.com"
],
"excluded": false
},
{
"type": 9,
"domains": [
"bananarepublic.com",
"gap.com",
"oldnavy.com",
"piperlime.com"
],
"excluded": false
},
{
"type": 10,
"domains": [
@ -116,32 +46,6 @@
],
"excluded": false
},
{
"type": 11,
"domains": [
"ua2go.com",
"ual.com",
"united.com",
"unitedwifi.com"
],
"excluded": false
},
{
"type": 12,
"domains": [
"overture.com",
"yahoo.com"
],
"excluded": false
},
{
"type": 13,
"domains": [
"zonealarm.com",
"zonelabs.com"
],
"excluded": false
},
{
"type": 14,
"domains": [
@ -150,39 +54,6 @@
],
"excluded": false
},
{
"type": 15,
"domains": [
"avon.com",
"youravon.com"
],
"excluded": false
},
{
"type": 16,
"domains": [
"diapers.com",
"soap.com",
"wag.com",
"yoyo.com",
"beautybar.com",
"casa.com",
"afterschool.com",
"vine.com",
"bookworm.com",
"look.com",
"vinemarket.com"
],
"excluded": false
},
{
"type": 17,
"domains": [
"1800contacts.com",
"800contacts.com"
],
"excluded": false
},
{
"type": 18,
"domains": [
@ -208,149 +79,6 @@
],
"excluded": false
},
{
"type": 19,
"domains": [
"cox.com",
"cox.net",
"coxbusiness.com"
],
"excluded": false
},
{
"type": 20,
"domains": [
"mynortonaccount.com",
"norton.com"
],
"excluded": false
},
{
"type": 21,
"domains": [
"verizon.com",
"verizon.net"
],
"excluded": false
},
{
"type": 22,
"domains": [
"rakuten.com",
"buy.com"
],
"excluded": false
},
{
"type": 23,
"domains": [
"siriusxm.com",
"sirius.com"
],
"excluded": false
},
{
"type": 24,
"domains": [
"ea.com",
"origin.com",
"play4free.com",
"tiberiumalliance.com"
],
"excluded": false
},
{
"type": 25,
"domains": [
"37signals.com",
"basecamp.com",
"basecamphq.com",
"highrisehq.com"
],
"excluded": false
},
{
"type": 26,
"domains": [
"steampowered.com",
"steamcommunity.com",
"steamgames.com"
],
"excluded": false
},
{
"type": 27,
"domains": [
"chart.io",
"chartio.com"
],
"excluded": false
},
{
"type": 28,
"domains": [
"gotomeeting.com",
"citrixonline.com"
],
"excluded": false
},
{
"type": 29,
"domains": [
"gogoair.com",
"gogoinflight.com"
],
"excluded": false
},
{
"type": 30,
"domains": [
"mysql.com",
"oracle.com"
],
"excluded": false
},
{
"type": 31,
"domains": [
"discover.com",
"discovercard.com"
],
"excluded": false
},
{
"type": 32,
"domains": [
"dcu.org",
"dcu-online.org"
],
"excluded": false
},
{
"type": 33,
"domains": [
"healthcare.gov",
"cuidadodesalud.gov",
"cms.gov"
],
"excluded": false
},
{
"type": 34,
"domains": [
"pepco.com",
"pepcoholdings.com"
],
"excluded": false
},
{
"type": 35,
"domains": [
"century21.com",
"21online.com"
],
"excluded": false
},
{
"type": 36,
"domains": [
@ -360,38 +88,6 @@
],
"excluded": false
},
{
"type": 37,
"domains": [
"cricketwireless.com",
"aiowireless.com"
],
"excluded": false
},
{
"type": 38,
"domains": [
"mandtbank.com",
"mtb.com"
],
"excluded": false
},
{
"type": 39,
"domains": [
"dropbox.com",
"getdropbox.com"
],
"excluded": false
},
{
"type": 40,
"domains": [
"snapfish.com",
"snapfish.ca"
],
"excluded": false
},
{
"type": 41,
"domains": [
@ -402,33 +98,6 @@
],
"excluded": false
},
{
"type": 42,
"domains": [
"playstation.com",
"sonyentertainmentnetwork.com"
],
"excluded": false
},
{
"type": 43,
"domains": [
"mercadolivre.com",
"mercadolivre.com.br",
"mercadolibre.com",
"mercadolibre.com.ar",
"mercadolibre.com.mx"
],
"excluded": false
},
{
"type": 44,
"domains": [
"zendesk.com",
"zopim.com"
],
"excluded": false
},
{
"type": 45,
"domains": [
@ -437,60 +106,6 @@
],
"excluded": false
},
{
"type": 46,
"domains": [
"railnation.ru",
"railnation.de",
"rail-nation.com",
"railnation.gr",
"railnation.us",
"trucknation.de",
"traviangames.com"
],
"excluded": false
},
{
"type": 47,
"domains": [
"wpcu.coop",
"wpcuonline.com"
],
"excluded": false
},
{
"type": 48,
"domains": [
"mathletics.com",
"mathletics.com.au",
"mathletics.co.uk"
],
"excluded": false
},
{
"type": 49,
"domains": [
"discountbank.co.il",
"telebank.co.il"
],
"excluded": false
},
{
"type": 50,
"domains": [
"mi.com",
"xiaomi.com"
],
"excluded": false
},
{
"type": 52,
"domains": [
"postepay.it",
"poste.it"
],
"excluded": false
},
{
"type": 51,
"domains": [
@ -499,15 +114,6 @@
],
"excluded": false
},
{
"type": 53,
"domains": [
"skysports.com",
"skybet.com",
"skyvegas.com"
],
"excluded": false
},
{
"type": 54,
"domains": [
@ -519,62 +125,6 @@
],
"excluded": false
},
{
"type": 55,
"domains": [
"pokemon-gl.com",
"pokemon.com"
],
"excluded": false
},
{
"type": 56,
"domains": [
"myuv.com",
"uvvu.com"
],
"excluded": false
},
{
"type": 58,
"domains": [
"mdsol.com",
"imedidata.com"
],
"excluded": false
},
{
"type": 57,
"domains": [
"bank-yahav.co.il",
"bankhapoalim.co.il"
],
"excluded": false
},
{
"type": 59,
"domains": [
"sears.com",
"shld.net"
],
"excluded": false
},
{
"type": 60,
"domains": [
"xiami.com",
"alipay.com"
],
"excluded": false
},
{
"type": 61,
"domains": [
"belkin.com",
"seedonk.com"
],
"excluded": false
},
{
"type": 62,
"domains": [
@ -583,14 +133,6 @@
],
"excluded": false
},
{
"type": 63,
"domains": [
"shopify.com",
"myshopify.com"
],
"excluded": false
},
{
"type": 64,
"domains": [
@ -620,30 +162,6 @@
],
"excluded": false
},
{
"type": 65,
"domains": [
"techdata.com",
"techdata.ch"
],
"excluded": false
},
{
"type": 66,
"domains": [
"schwab.com",
"schwabplan.com"
],
"excluded": false
},
{
"type": 68,
"domains": [
"tesla.com",
"teslamotors.com"
],
"excluded": false
},
{
"type": 69,
"domains": [
@ -654,31 +172,6 @@
],
"excluded": false
},
{
"type": 70,
"domains": [
"taxact.com",
"taxactonline.com"
],
"excluded": false
},
{
"type": 71,
"domains": [
"mediawiki.org",
"wikibooks.org",
"wikidata.org",
"wikimedia.org",
"wikinews.org",
"wikipedia.org",
"wikiquote.org",
"wikisource.org",
"wikiversity.org",
"wikivoyage.org",
"wiktionary.org"
],
"excluded": false
},
{
"type": 72,
"domains": [
@ -738,38 +231,6 @@
],
"excluded": false
},
{
"type": 73,
"domains": [
"eventbrite.at",
"eventbrite.be",
"eventbrite.ca",
"eventbrite.ch",
"eventbrite.cl",
"eventbrite.co",
"eventbrite.co.nz",
"eventbrite.co.uk",
"eventbrite.com",
"eventbrite.com.ar",
"eventbrite.com.au",
"eventbrite.com.br",
"eventbrite.com.mx",
"eventbrite.com.pe",
"eventbrite.de",
"eventbrite.dk",
"eventbrite.es",
"eventbrite.fi",
"eventbrite.fr",
"eventbrite.hk",
"eventbrite.ie",
"eventbrite.it",
"eventbrite.nl",
"eventbrite.pt",
"eventbrite.se",
"eventbrite.sg"
],
"excluded": false
},
{
"type": 74,
"domains": [
@ -791,56 +252,6 @@
],
"excluded": false
},
{
"type": 76,
"domains": [
"envato.com",
"themeforest.net",
"codecanyon.net",
"videohive.net",
"audiojungle.net",
"graphicriver.net",
"photodune.net",
"3docean.net"
],
"excluded": false
},
{
"type": 77,
"domains": [
"x10hosting.com",
"x10premium.com"
],
"excluded": false
},
{
"type": 78,
"domains": [
"dnsomatic.com",
"opendns.com",
"umbrella.com"
],
"excluded": false
},
{
"type": 79,
"domains": [
"cagreatamerica.com",
"canadaswonderland.com",
"carowinds.com",
"cedarfair.com",
"cedarpoint.com",
"dorneypark.com",
"kingsdominion.com",
"knotts.com",
"miadventure.com",
"schlitterbahn.com",
"valleyfair.com",
"visitkingsisland.com",
"worldsoffun.com"
],
"excluded": false
},
{
"type": 80,
"domains": [
@ -849,23 +260,6 @@
],
"excluded": false
},
{
"type": 81,
"domains": [
"discordapp.com",
"discord.com"
],
"excluded": false
},
{
"type": 82,
"domains": [
"netcup.de",
"netcup.eu",
"customercontrolpanel.de"
],
"excluded": false
},
{
"type": 83,
"domains": [
@ -894,14 +288,6 @@
],
"excluded": false
},
{
"type": 84,
"domains": [
"sonyentertainmentnetwork.com",
"sony.com"
],
"excluded": false
},
{
"type": 85,
"domains": [
@ -911,37 +297,6 @@
],
"excluded": false
},
{
"type": 86,
"domains": [
"ubisoft.com",
"ubi.com"
],
"excluded": false
},
{
"type": 87,
"domains": [
"transferwise.com",
"wise.com"
],
"excluded": false
},
{
"type": 88,
"domains": [
"takeaway.com",
"just-eat.dk",
"just-eat.no",
"just-eat.fr",
"just-eat.ch",
"lieferando.de",
"lieferando.at",
"thuisbezorgd.nl",
"pyszne.pl"
],
"excluded": false
},
{
"type": 89,
"domains": [
@ -954,25 +309,6 @@
],
"excluded": false
},
{
"type": 90,
"domains": [
"pinterest.com",
"pinterest.com.au",
"pinterest.cl",
"pinterest.de",
"pinterest.dk",
"pinterest.es",
"pinterest.fr",
"pinterest.co.uk",
"pinterest.jp",
"pinterest.co.kr",
"pinterest.nz",
"pinterest.pt",
"pinterest.se"
],
"excluded": false
},
{
"type": 91,
"domains": [

BIN
src/static/images/fallback-icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 483 B

4
src/static/scripts/datatables.css

@ -4,10 +4,10 @@
*
* To rebuild or modify this file with the latest versions of the included
* software please visit:
* https://datatables.net/download/#bs5/dt-3.1.4
* https://datatables.net/download/#bs5/dt-3.1.5
*
* Included libraries:
* DataTables 3.1.4
* DataTables 3.1.5
*/
/*! DataTables Bootstrap 5 integration

80
src/static/scripts/datatables.js

@ -4,13 +4,13 @@
*
* To rebuild or modify this file with the latest versions of the included
* software please visit:
* https://datatables.net/download/#bs5/dt-3.1.4
* https://datatables.net/download/#bs5/dt-3.1.5
*
* Included libraries:
* DataTables 3.1.4
* DataTables 3.1.5
*/
/*! DataTables 3.1.4
/*! DataTables 3.1.5
* Copyright (c) SpryMedia Ltd - datatables.net/license
*/
@ -22,9 +22,6 @@
});
}
else if (typeof exports === 'object') {
// CommonJS
var cjsRequires = function (root) { };
if (typeof window === 'undefined') {
module.exports = function (root) {
if (! root) {
@ -33,12 +30,10 @@
root = window;
}
cjsRequires(root);
return factory(root, root.document);
};
}
else {
cjsRequires(window);
module.exports = factory(window, window.document);
}
}
@ -276,7 +271,7 @@ function dom(input) {
* @returns true if an HTML element was passed in
*/
function element(input) {
return typeof input === 'object' && input.nodeName;
return input && typeof input === 'object' && input.nodeName;
}
/**
* Check if a value is empty or not. Note that a string with `-` is considered
@ -767,7 +762,7 @@ function ajax(optionsIn) {
// noop
}
}
if (statusText === 'success') {
if (statusText === 'success' || statusText === 'nocontent') {
callback(options.success, responseData, statusText, xhr);
}
else {
@ -8720,7 +8715,7 @@ const ext = {
/**
* DataTables build type (expanded by the download builder)
*/
builder: 'bs5/dt-3.1.4',
builder: 'bs5/dt-3.1.5',
/**
* Buttons. For use with the Buttons extension for DataTables. This is
* defined here so other extensions can define buttons regardless of load
@ -8866,7 +8861,7 @@ const ext = {
* Software version
* @type string
*/
version: '3.1.4'
version: '3.1.5'
};
//
// Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
@ -9535,8 +9530,10 @@ register('ready()', function (fn) {
fn.call(api);
}
else {
this.on('init.dt.DT', function () {
fn.call(api);
this.on('init.dt.DT', function (e, s) {
if (ctx.includes(s)) {
fn.call(api);
}
});
}
});
@ -10803,14 +10800,12 @@ function selectRows(settings, selector, opts) {
}
}
// ID selector. Want to always be able to select rows by id, regardless
// of if the tr element has been created or not, so can't rely upon
// jQuery here - hence a custom implementation. This does not match
// Sizzle's fast selector or HTML4 - in HTML5 the ID can be anything,
// but to select it using a CSS selector engine (like Sizzle or
// querySelect) it would need to need to be escaped for some characters.
// DataTables simplifies this for row selectors since you can select
// only a row. A # indicates an id any anything that follows is the id -
// unescaped.
// of if the tr element has been created or not, so can't rely upon the
// DOM here - hence a custom implementation. In HTML5 the ID can be
// anything, but to select it using a CSS selector engine it would need
// to need to be escaped for some characters. DataTables simplifies this
// for row selectors since you can select only a row. A # indicates an
// id any anything that follows is the id - unescaped.
if (typeof sel === 'string') {
if (sel.charAt(0) === '#') {
// get row index from id
@ -10818,6 +10813,13 @@ function selectRows(settings, selector, opts) {
if (rowObj !== undefined) {
return [rowObj.idx];
}
// If it was a basic ID selector, and it didn't match, in the
// above, then return here, as it won't match at all. Note that
// this check is slightly less restrictive than CSS IDs, in that
// it allows a leading digit or dash to be used.
if (sel.match(/^#[a-zA-Z0-9_-]*$/)) {
return [];
}
// need to fall through to selector in case there is DOM id that
// matches
}
@ -12506,19 +12508,22 @@ const DataTable = function (selector, options) {
if (factory(selector, options)) {
return DataTable;
}
// Allow access to the API from the core class
this.api = () => {
return new Api(selector);
};
// Backwards compatibility with this "class" being exposed as
// `$().dataTable()`. We can't simply provide that as a wrapper, as there
// are properties on this class which are expected to be exposed.
if (typeof this.jquery === 'string') {
let els = this.toArray();
// Typescript doesn't like the `return api` from the constructor, but is
// it valid Javascript, and allows backwards compatibility, hence the any
new DataTable(this.toArray(), selector); // note argument shift
new DataTable(els, selector); // note argument shift
// jQuery specific api method
this.api = () => new Api(els);
return this;
}
// Allow access to the API from the core class
this.api = () => {
return new Api(selector);
};
var emptyInit = options === undefined;
let tableEls = Dom.s(selector);
let len = tableEls.count();
@ -12963,13 +12968,6 @@ return DataTable;
});
}
else if (typeof exports === 'object') {
// CommonJS
var cjsRequires = function (root) {
if (! root.DataTable) {
require('datatables.net')(root);
}
};
if (typeof window === 'undefined') {
module.exports = function (root) {
if (! root) {
@ -12978,13 +12976,19 @@ return DataTable;
root = window;
}
cjsRequires(root);
return factory(root, root.document, root.DataTable);
var DataTable = root.DataTable ?
root.DataTable :
require('datatables.net')(root);
return factory(root, root.document, DataTable);
};
}
else {
cjsRequires(window);
module.exports = factory(window, window.document, window.DataTable);
var DataTable = window.DataTable ?
window.DataTable :
require('datatables.net');
module.exports = factory(window, window.document, DataTable);
}
}
else {

8
src/util.rs

@ -147,7 +147,7 @@ impl Cors {
// Check a request's `Origin` header against the list of allowed origins.
// If a match exists, return it. Otherwise, return None.
fn get_allowed_origin(headers: &HeaderMap<'_>) -> Option<String> {
fn get_allowed_origin(headers: &HeaderMap<'_>, allow_sso: bool) -> Option<String> {
let origin = Self::get_header(headers, "Origin");
let safari_extension_origin = "file://";
let desktop_custom_file_origin = "bw-desktop-file://bundle";
@ -155,7 +155,7 @@ impl Cors {
if origin == CONFIG.domain_origin()
|| origin == safari_extension_origin
|| origin == desktop_custom_file_origin
|| (CONFIG.sso_enabled() && origin == CONFIG.sso_authority())
|| (allow_sso && CONFIG.sso_enabled() && origin == CONFIG.sso_authority())
{
Some(origin)
} else {
@ -175,8 +175,10 @@ impl Fairing for Cors {
async fn on_response<'r>(&self, request: &'r Request<'_>, response: &mut Response<'r>) {
let req_headers = request.headers();
// The admin panel authenticates with a cookie, so the SSO provider's pages must not reach it
let allow_sso = !request.uri().path().as_str().starts_with(&format!("{}/admin", CONFIG.domain_path()));
if let Some(origin) = Self::get_allowed_origin(req_headers) {
if let Some(origin) = Self::get_allowed_origin(req_headers, allow_sso) {
response.set_header(Header::new("Access-Control-Allow-Origin", origin));
}

Loading…
Cancel
Save