mirror of
https://github.com/dani-garcia/vaultwarden.wiki.git
synced 2026-08-01 10:13:44 +03:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f03e74feb | ||
|
|
94a798e9dd | ||
|
|
5a02e80a5a |
@@ -62,7 +62,7 @@ jobs:
|
||||
|
||||
# Checkout the repo
|
||||
- name: "Checkout"
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
steps:
|
||||
# Checkout the repo
|
||||
- name: "Checkout"
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
# End Checkout the repo
|
||||
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
|
||||
# Checkout the repo
|
||||
- name: Checkout
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
# End Checkout the repo
|
||||
|
||||
@@ -77,7 +77,7 @@ jobs:
|
||||
|
||||
# Checkout the repo
|
||||
- name: Checkout
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
# We need fetch-depth of 0 so we also get all the tag metadata
|
||||
with:
|
||||
persist-credentials: false
|
||||
@@ -106,7 +106,7 @@ jobs:
|
||||
|
||||
# Login to Docker Hub
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
|
||||
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.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@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
|
||||
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.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@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
|
||||
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0
|
||||
with:
|
||||
registry: quay.io
|
||||
username: ${{ secrets.QUAY_USERNAME }}
|
||||
@@ -237,7 +237,7 @@ jobs:
|
||||
|
||||
# Upload artifacts to Github Actions and Attest the binaries
|
||||
- name: Attest binaries
|
||||
uses: actions/attest@f7c74d28b9d84cb8768d0b8ca14a4bac6ef463e6 # v4.2.0
|
||||
uses: actions/attest@a1948c3f048ba23858d222213b7c278aabede763 # v4.1.1
|
||||
with:
|
||||
subject-path: vaultwarden-${{ env.NORMALIZED_ARCH }}
|
||||
|
||||
@@ -272,7 +272,7 @@ jobs:
|
||||
|
||||
# Login to Docker Hub
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
|
||||
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.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@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
|
||||
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.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@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
|
||||
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0
|
||||
with:
|
||||
registry: quay.io
|
||||
username: ${{ secrets.QUAY_USERNAME }}
|
||||
@@ -365,7 +365,7 @@ jobs:
|
||||
# Attest container images
|
||||
- name: Attest - docker.io - ${{ matrix.base_image }}
|
||||
if: ${{ vars.DOCKERHUB_REPO != '' && env.DIGEST_SHA != ''}}
|
||||
uses: actions/attest@f7c74d28b9d84cb8768d0b8ca14a4bac6ef463e6 # v4.2.0
|
||||
uses: actions/attest@a1948c3f048ba23858d222213b7c278aabede763 # v4.1.1
|
||||
with:
|
||||
subject-name: ${{ vars.DOCKERHUB_REPO }}
|
||||
subject-digest: ${{ env.DIGEST_SHA }}
|
||||
@@ -373,7 +373,7 @@ jobs:
|
||||
|
||||
- name: Attest - ghcr.io - ${{ matrix.base_image }}
|
||||
if: ${{ vars.GHCR_REPO != '' && env.DIGEST_SHA != ''}}
|
||||
uses: actions/attest@f7c74d28b9d84cb8768d0b8ca14a4bac6ef463e6 # v4.2.0
|
||||
uses: actions/attest@a1948c3f048ba23858d222213b7c278aabede763 # v4.1.1
|
||||
with:
|
||||
subject-name: ${{ vars.GHCR_REPO }}
|
||||
subject-digest: ${{ env.DIGEST_SHA }}
|
||||
@@ -381,7 +381,7 @@ jobs:
|
||||
|
||||
- name: Attest - quay.io - ${{ matrix.base_image }}
|
||||
if: ${{ vars.QUAY_REPO != '' && env.DIGEST_SHA != ''}}
|
||||
uses: actions/attest@f7c74d28b9d84cb8768d0b8ca14a4bac6ef463e6 # v4.2.0
|
||||
uses: actions/attest@a1948c3f048ba23858d222213b7c278aabede763 # v4.1.1
|
||||
with:
|
||||
subject-name: ${{ vars.QUAY_REPO }}
|
||||
subject-digest: ${{ env.DIGEST_SHA }}
|
||||
|
||||
@@ -33,7 +33,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
@@ -50,6 +50,6 @@ jobs:
|
||||
severity: CRITICAL,HIGH
|
||||
|
||||
- name: Upload Trivy scan results to GitHub Security tab
|
||||
uses: github/codeql-action/upload-sarif@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
|
||||
uses: github/codeql-action/upload-sarif@99df26d4f13ea111d4ec1a7dddef6063f76b97e9 # v4.37.0
|
||||
with:
|
||||
sarif_file: 'trivy-results.sarif'
|
||||
|
||||
@@ -16,7 +16,7 @@ jobs:
|
||||
steps:
|
||||
# Checkout the repo
|
||||
- name: Checkout
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
# End Checkout the repo
|
||||
|
||||
@@ -19,12 +19,12 @@ jobs:
|
||||
security-events: write # To write the security report
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Run zizmor
|
||||
uses: zizmorcore/zizmor-action@6fc4b006235f201fdab3722e17240ab420d580e5 # v0.6.1
|
||||
uses: zizmorcore/zizmor-action@192e21d79ab29983730a13d1382995c2307fbcaa # v0.5.7
|
||||
with:
|
||||
# intentionally not scanning the entire repository,
|
||||
# since it contains integration tests.
|
||||
|
||||
@@ -15,7 +15,6 @@ extend-ignore-re = [
|
||||
"(?i)helo_name",
|
||||
"Server name sent during.+HELO",
|
||||
# COSE Is short for CBOR Object Signing and Encryption, ignore these specific items
|
||||
"COSE",
|
||||
"COSEKey",
|
||||
"COSEAlgorithm",
|
||||
# Ignore this specific string as it's valid
|
||||
|
||||
Generated
+392
-324
File diff suppressed because it is too large
Load Diff
+20
-20
@@ -1,6 +1,6 @@
|
||||
[workspace.package]
|
||||
edition = "2024"
|
||||
rust-version = "1.95.0"
|
||||
rust-version = "1.94.1"
|
||||
license = "AGPL-3.0-only"
|
||||
repository = "https://github.com/dani-garcia/vaultwarden"
|
||||
publish = false
|
||||
@@ -75,7 +75,7 @@ dotenvy = { version = "0.15.7", default-features = false }
|
||||
|
||||
# Numerical libraries
|
||||
num-traits = "0.2.19"
|
||||
num-derive = "0.5.1"
|
||||
num-derive = "0.4.2"
|
||||
bigdecimal = "0.4.10"
|
||||
|
||||
# Web framework
|
||||
@@ -89,8 +89,8 @@ rmpv = "1.3.1" # MessagePack library
|
||||
dashmap = "6.2.1"
|
||||
|
||||
# Async futures
|
||||
futures = "0.3.33"
|
||||
tokio = { version = "1.53.1", features = [
|
||||
futures = "0.3.32"
|
||||
tokio = { version = "1.52.3", features = [
|
||||
"fs",
|
||||
"io-util",
|
||||
"net",
|
||||
@@ -99,14 +99,14 @@ tokio = { version = "1.53.1", features = [
|
||||
"signal",
|
||||
"time",
|
||||
] }
|
||||
tokio-util = { version = "0.7.19", features = ["compat"] }
|
||||
tokio-util = { version = "0.7.18", features = ["compat"] }
|
||||
|
||||
# A generic serialization/deserialization framework
|
||||
serde = { version = "1.0.229", features = ["derive"] }
|
||||
serde_json = "1.0.151"
|
||||
serde = { version = "1.0.228", features = ["derive"] }
|
||||
serde_json = "1.0.150"
|
||||
|
||||
# A safe, extensible ORM and Query builder
|
||||
diesel = { version = "2.3.11", features = ["chrono", "r2d2", "numeric", "64-column-tables"] }
|
||||
diesel = { version = "2.3.10", features = ["chrono", "r2d2", "numeric"] }
|
||||
diesel_migrations = "2.3.2"
|
||||
|
||||
derive_more = { version = "2.1.1", features = [
|
||||
@@ -124,16 +124,16 @@ libsqlite3-sys = { version = "0.37.0", optional = true }
|
||||
# Crypto-related libraries
|
||||
rand = "0.10.2"
|
||||
ring = "0.17.14"
|
||||
rustls = { version = "0.23.42", features = ["ring", "std"], default-features = false }
|
||||
rustls = { version = "0.23.41", features = ["ring", "std"], default-features = false }
|
||||
subtle = "2.6.1"
|
||||
|
||||
# UUID generation
|
||||
uuid = { version = "1.24.0", features = ["v4"] }
|
||||
uuid = { version = "1.23.4", features = ["v4"] }
|
||||
|
||||
# Date and time libraries
|
||||
chrono = { version = "0.4.45", default-features = false, features = ["clock", "serde"] }
|
||||
chrono-tz = "0.10.4"
|
||||
time = "0.3.54"
|
||||
time = "0.3.53"
|
||||
|
||||
# Job scheduler
|
||||
job_scheduler_ng = "2.4.0"
|
||||
@@ -142,7 +142,7 @@ job_scheduler_ng = "2.4.0"
|
||||
data-encoding = "2.11.0"
|
||||
|
||||
# JWT library
|
||||
jsonwebtoken = { version = "11.0.0", default-features = false, features = ["rust_crypto", "use_pem"] }
|
||||
jsonwebtoken = { version = "10.4.0", default-features = false, features = ["rust_crypto", "use_pem"] }
|
||||
|
||||
# TOTP library
|
||||
totp-lite = "2.0.1"
|
||||
@@ -179,7 +179,7 @@ percent-encoding = "2.3.2" # URL encoding library used for URL's in the emails
|
||||
email_address = "0.2.9"
|
||||
|
||||
# HTML Template library
|
||||
handlebars = { version = "6.4.3", features = ["dir_source"] }
|
||||
handlebars = { version = "6.4.2", features = ["dir_source"] }
|
||||
|
||||
# HTTP client (Used for favicons, version check, DUO and HIBP API)
|
||||
reqwest = { version = "0.13.4", default-features = false, features = [
|
||||
@@ -204,7 +204,7 @@ hickory-resolver = "0.26.1"
|
||||
|
||||
# Favicon extraction libraries
|
||||
html5gum = "0.8.4"
|
||||
regex = { version = "1.13.1", default-features = false, features = [
|
||||
regex = { version = "1.12.4", default-features = false, features = [
|
||||
"perf",
|
||||
"std",
|
||||
"unicode-perl",
|
||||
@@ -244,7 +244,7 @@ semver = "1.0.28"
|
||||
# Mainly used for the musl builds, since the default musl malloc is very slow
|
||||
mimalloc = { version = "0.1.52", optional = true, default-features = false, features = ["secure"] }
|
||||
|
||||
which = "8.0.5"
|
||||
which = "8.0.4"
|
||||
|
||||
# Argon2 library with support for the PHC format
|
||||
argon2 = "0.5.3"
|
||||
@@ -259,17 +259,17 @@ grass_compiler = { version = "0.13.4", default-features = false }
|
||||
opendal = { version = "0.57.0", default-features = false, features = ["services-fs"] }
|
||||
|
||||
# For retrieving AWS credentials, including temporary SSO credentials
|
||||
aws-config = { version = "1.10.0", optional = true, default-features = false, features = [
|
||||
aws-config = { version = "1.8.18", optional = true, default-features = false, features = [
|
||||
"behavior-version-latest",
|
||||
"credentials-process",
|
||||
"rt-tokio",
|
||||
"sso",
|
||||
] }
|
||||
aws-credential-types = { version = "1.3.0", optional = true }
|
||||
aws-smithy-runtime-api = { version = "1.14.0", optional = true }
|
||||
aws-credential-types = { version = "1.2.14", optional = true }
|
||||
aws-smithy-runtime-api = { version = "1.13.0", optional = true }
|
||||
http = { version = "1.4.2", optional = true }
|
||||
reqsign-aws-v4 = { version = "3.0.2", optional = true }
|
||||
reqsign-core = { version = "3.1.0", optional = true }
|
||||
reqsign-aws-v4 = { version = "3.0.1", optional = true }
|
||||
reqsign-core = { version = "3.0.1", optional = true }
|
||||
|
||||
# Strip debuginfo from the release builds
|
||||
# The debug symbols are to provide better panic traces
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
---
|
||||
vault_version: "v2026.6.4"
|
||||
vault_image_digest: "sha256:e7d3b31ec6a991a6bf447721ea341b4192ce5d3b920929211672fd4f3f891427"
|
||||
vault_version: "v2026.6.2"
|
||||
vault_image_digest: "sha256:f004f72a5d357b87483839500a517da3d1b4ea0a57b9731989d298cccea7d02a"
|
||||
# Cross Compile Docker Helper Scripts v1.9.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
|
||||
xx_image_digest: "sha256:c64defb9ed5a91eacb37f96ccc3d4cd72521c4bd18d5442905b95e2226b0e707"
|
||||
rust_version: 1.97.1 # Rust version to be used
|
||||
rust_version: 1.96.1 # Rust version to be used
|
||||
debian_version: trixie # Debian release name to be used
|
||||
alpine_version: "3.24" # Alpine version to be used
|
||||
# For which platforms/architectures will we try to build images
|
||||
|
||||
+11
-11
@@ -19,23 +19,23 @@
|
||||
# - 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.6.4
|
||||
# $ docker image inspect --format "{{.RepoDigests}}" docker.io/vaultwarden/web-vault:v2026.6.4
|
||||
# [docker.io/vaultwarden/web-vault@sha256:e7d3b31ec6a991a6bf447721ea341b4192ce5d3b920929211672fd4f3f891427]
|
||||
# $ docker pull docker.io/vaultwarden/web-vault:v2026.6.2
|
||||
# $ docker image inspect --format "{{.RepoDigests}}" docker.io/vaultwarden/web-vault:v2026.6.2
|
||||
# [docker.io/vaultwarden/web-vault@sha256:f004f72a5d357b87483839500a517da3d1b4ea0a57b9731989d298cccea7d02a]
|
||||
#
|
||||
# - Conversely, to get the tag name from the digest:
|
||||
# $ docker image inspect --format "{{.RepoTags}}" docker.io/vaultwarden/web-vault@sha256:e7d3b31ec6a991a6bf447721ea341b4192ce5d3b920929211672fd4f3f891427
|
||||
# [docker.io/vaultwarden/web-vault:v2026.6.4]
|
||||
# $ docker image inspect --format "{{.RepoTags}}" docker.io/vaultwarden/web-vault@sha256:f004f72a5d357b87483839500a517da3d1b4ea0a57b9731989d298cccea7d02a
|
||||
# [docker.io/vaultwarden/web-vault:v2026.6.2]
|
||||
#
|
||||
FROM --platform=linux/amd64 docker.io/vaultwarden/web-vault@sha256:e7d3b31ec6a991a6bf447721ea341b4192ce5d3b920929211672fd4f3f891427 AS vault
|
||||
FROM --platform=linux/amd64 docker.io/vaultwarden/web-vault@sha256:f004f72a5d357b87483839500a517da3d1b4ea0a57b9731989d298cccea7d02a AS vault
|
||||
|
||||
########################## ALPINE BUILD IMAGES ##########################
|
||||
## NOTE: The Alpine Base Images do not support other platforms then linux/amd64 and linux/arm64
|
||||
## And for Alpine we define all build images here, they will only be loaded when actually used
|
||||
FROM --platform=$BUILDPLATFORM ghcr.io/blackdex/rust-musl:x86_64-musl-stable-1.97.1 AS build_amd64
|
||||
FROM --platform=$BUILDPLATFORM ghcr.io/blackdex/rust-musl:aarch64-musl-stable-1.97.1 AS build_arm64
|
||||
FROM --platform=$BUILDPLATFORM ghcr.io/blackdex/rust-musl:armv7-musleabihf-stable-1.97.1 AS build_armv7
|
||||
FROM --platform=$BUILDPLATFORM ghcr.io/blackdex/rust-musl:arm-musleabi-stable-1.97.1 AS build_armv6
|
||||
FROM --platform=$BUILDPLATFORM ghcr.io/blackdex/rust-musl:x86_64-musl-stable-1.96.1 AS build_amd64
|
||||
FROM --platform=$BUILDPLATFORM ghcr.io/blackdex/rust-musl:aarch64-musl-stable-1.96.1 AS build_arm64
|
||||
FROM --platform=$BUILDPLATFORM ghcr.io/blackdex/rust-musl:armv7-musleabihf-stable-1.96.1 AS build_armv7
|
||||
FROM --platform=$BUILDPLATFORM ghcr.io/blackdex/rust-musl:arm-musleabi-stable-1.96.1 AS build_armv6
|
||||
|
||||
########################## BUILD IMAGE ##########################
|
||||
# hadolint ignore=DL3006
|
||||
@@ -66,7 +66,7 @@ RUN USER=root cargo new --bin /app
|
||||
WORKDIR /app
|
||||
|
||||
# Environment variables for Cargo on Alpine based builds
|
||||
RUN echo "export CARGO_TARGET=${CARGO_BUILD_TARGET}" >> /env-cargo && \
|
||||
RUN echo "export CARGO_TARGET=${RUST_MUSL_CROSS_TARGET}" >> /env-cargo && \
|
||||
# Output the current contents of the file
|
||||
cat /env-cargo
|
||||
|
||||
|
||||
@@ -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.6.4
|
||||
# $ docker image inspect --format "{{.RepoDigests}}" docker.io/vaultwarden/web-vault:v2026.6.4
|
||||
# [docker.io/vaultwarden/web-vault@sha256:e7d3b31ec6a991a6bf447721ea341b4192ce5d3b920929211672fd4f3f891427]
|
||||
# $ docker pull docker.io/vaultwarden/web-vault:v2026.6.2
|
||||
# $ docker image inspect --format "{{.RepoDigests}}" docker.io/vaultwarden/web-vault:v2026.6.2
|
||||
# [docker.io/vaultwarden/web-vault@sha256:f004f72a5d357b87483839500a517da3d1b4ea0a57b9731989d298cccea7d02a]
|
||||
#
|
||||
# - Conversely, to get the tag name from the digest:
|
||||
# $ docker image inspect --format "{{.RepoTags}}" docker.io/vaultwarden/web-vault@sha256:e7d3b31ec6a991a6bf447721ea341b4192ce5d3b920929211672fd4f3f891427
|
||||
# [docker.io/vaultwarden/web-vault:v2026.6.4]
|
||||
# $ docker image inspect --format "{{.RepoTags}}" docker.io/vaultwarden/web-vault@sha256:f004f72a5d357b87483839500a517da3d1b4ea0a57b9731989d298cccea7d02a
|
||||
# [docker.io/vaultwarden/web-vault:v2026.6.2]
|
||||
#
|
||||
FROM --platform=linux/amd64 docker.io/vaultwarden/web-vault@sha256:e7d3b31ec6a991a6bf447721ea341b4192ce5d3b920929211672fd4f3f891427 AS vault
|
||||
FROM --platform=linux/amd64 docker.io/vaultwarden/web-vault@sha256:f004f72a5d357b87483839500a517da3d1b4ea0a57b9731989d298cccea7d02a AS vault
|
||||
|
||||
########################## Cross Compile Docker Helper Scripts ##########################
|
||||
## We use the linux/amd64 no matter which Build Platform, since these are all bash scripts
|
||||
@@ -36,7 +36,7 @@ FROM --platform=linux/amd64 docker.io/tonistiigi/xx@sha256:c64defb9ed5a91eacb37f
|
||||
|
||||
########################## BUILD IMAGE ##########################
|
||||
# hadolint ignore=DL3006
|
||||
FROM --platform=$BUILDPLATFORM docker.io/library/rust:1.97.1-slim-trixie AS build
|
||||
FROM --platform=$BUILDPLATFORM docker.io/library/rust:1.96.1-slim-trixie AS build
|
||||
COPY --from=xx / /
|
||||
ARG TARGETARCH
|
||||
ARG TARGETVARIANT
|
||||
|
||||
@@ -106,7 +106,7 @@ WORKDIR /app
|
||||
|
||||
{% if base == "alpine" %}
|
||||
# Environment variables for Cargo on Alpine based builds
|
||||
RUN echo "export CARGO_TARGET=${CARGO_BUILD_TARGET}" >> /env-cargo && \
|
||||
RUN echo "export CARGO_TARGET=${RUST_MUSL_CROSS_TARGET}" >> /env-cargo && \
|
||||
# Output the current contents of the file
|
||||
cat /env-cargo
|
||||
|
||||
|
||||
+2
-2
@@ -13,8 +13,8 @@ path = "src/lib.rs"
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
quote = "1.0.47"
|
||||
syn = "3.0.3"
|
||||
quote = "1.0.46"
|
||||
syn = "2.0.118"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
DROP TABLE IF EXISTS user_signature_key_pairs;
|
||||
|
||||
ALTER TABLE users DROP COLUMN signed_public_key;
|
||||
ALTER TABLE users DROP COLUMN security_state;
|
||||
ALTER TABLE users DROP COLUMN security_version;
|
||||
ALTER TABLE users DROP COLUMN v2_upgrade_token;
|
||||
@@ -1,17 +0,0 @@
|
||||
ALTER TABLE users ADD COLUMN signed_public_key TEXT;
|
||||
ALTER TABLE users ADD COLUMN security_state TEXT;
|
||||
ALTER TABLE users ADD COLUMN security_version INTEGER;
|
||||
ALTER TABLE users ADD COLUMN v2_upgrade_token TEXT;
|
||||
|
||||
DROP TABLE IF EXISTS user_signature_key_pairs;
|
||||
|
||||
CREATE TABLE user_signature_key_pairs (
|
||||
uuid CHAR(36) NOT NULL PRIMARY KEY,
|
||||
user_uuid CHAR(36) NOT NULL UNIQUE,
|
||||
signature_algorithm INTEGER NOT NULL, -- 0 = ed25519, 1 = mldsa44
|
||||
signing_key TEXT NOT NULL,
|
||||
verifying_key TEXT NOT NULL,
|
||||
created_at DATETIME NOT NULL,
|
||||
updated_at DATETIME NOT NULL,
|
||||
FOREIGN KEY (user_uuid) REFERENCES users (uuid) ON DELETE CASCADE
|
||||
);
|
||||
@@ -1,6 +0,0 @@
|
||||
DROP TABLE IF EXISTS user_signature_key_pairs;
|
||||
|
||||
ALTER TABLE users DROP COLUMN signed_public_key;
|
||||
ALTER TABLE users DROP COLUMN security_state;
|
||||
ALTER TABLE users DROP COLUMN security_version;
|
||||
ALTER TABLE users DROP COLUMN v2_upgrade_token;
|
||||
@@ -1,16 +0,0 @@
|
||||
ALTER TABLE users ADD COLUMN signed_public_key TEXT;
|
||||
ALTER TABLE users ADD COLUMN security_state TEXT;
|
||||
ALTER TABLE users ADD COLUMN security_version INTEGER;
|
||||
ALTER TABLE users ADD COLUMN v2_upgrade_token TEXT;
|
||||
|
||||
DROP TABLE IF EXISTS user_signature_key_pairs;
|
||||
|
||||
CREATE TABLE user_signature_key_pairs (
|
||||
uuid CHAR(36) NOT NULL PRIMARY KEY,
|
||||
user_uuid CHAR(36) NOT NULL UNIQUE REFERENCES users (uuid) ON DELETE CASCADE,
|
||||
signature_algorithm INTEGER NOT NULL, -- 0 = ed25519, 1 = mldsa44
|
||||
signing_key TEXT NOT NULL,
|
||||
verifying_key TEXT NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL,
|
||||
updated_at TIMESTAMP NOT NULL
|
||||
);
|
||||
@@ -1,6 +0,0 @@
|
||||
DROP TABLE IF EXISTS user_signature_key_pairs;
|
||||
|
||||
ALTER TABLE users DROP COLUMN signed_public_key;
|
||||
ALTER TABLE users DROP COLUMN security_state;
|
||||
ALTER TABLE users DROP COLUMN security_version;
|
||||
ALTER TABLE users DROP COLUMN v2_upgrade_token;
|
||||
@@ -1,16 +0,0 @@
|
||||
ALTER TABLE users ADD COLUMN signed_public_key TEXT;
|
||||
ALTER TABLE users ADD COLUMN security_state TEXT;
|
||||
ALTER TABLE users ADD COLUMN security_version INTEGER;
|
||||
ALTER TABLE users ADD COLUMN v2_upgrade_token TEXT;
|
||||
|
||||
DROP TABLE IF EXISTS user_signature_key_pairs;
|
||||
|
||||
CREATE TABLE user_signature_key_pairs (
|
||||
uuid TEXT NOT NULL PRIMARY KEY,
|
||||
user_uuid TEXT NOT NULL UNIQUE REFERENCES users (uuid) ON DELETE CASCADE,
|
||||
signature_algorithm INTEGER NOT NULL, -- 0 = ed25519, 1 = mldsa44
|
||||
signing_key TEXT NOT NULL,
|
||||
verifying_key TEXT NOT NULL,
|
||||
created_at DATETIME NOT NULL,
|
||||
updated_at DATETIME NOT NULL
|
||||
);
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
[toolchain]
|
||||
channel = "1.97.1"
|
||||
channel = "1.96.1"
|
||||
components = [ "rustfmt", "clippy" ]
|
||||
profile = "minimal"
|
||||
|
||||
+54
-284
@@ -22,8 +22,7 @@ use crate::{
|
||||
models::{
|
||||
AuthRequest, AuthRequestId, Cipher, CipherId, Device, DeviceId, DeviceType, DeviceWithAuthRequest,
|
||||
EmergencyAccess, EmergencyAccessId, EventType, Folder, FolderId, Invitation, Membership, MembershipId,
|
||||
OrgPolicy, OrgPolicyType, Organization, OrganizationId, Send, SendId, SignatureAlgorithm, User, UserId,
|
||||
UserKdfType, UserSignatureKeyPair,
|
||||
OrgPolicy, OrgPolicyType, Organization, OrganizationId, Send, SendId, User, UserId, UserKdfType,
|
||||
},
|
||||
},
|
||||
mail,
|
||||
@@ -42,8 +41,6 @@ pub fn routes() -> Vec<rocket::Route> {
|
||||
post_profile,
|
||||
put_avatar,
|
||||
get_public_keys,
|
||||
get_account_public_keys,
|
||||
get_keys,
|
||||
post_keys,
|
||||
post_password,
|
||||
post_set_password,
|
||||
@@ -105,9 +102,6 @@ pub struct RegisterData {
|
||||
#[serde(alias = "userAsymmetricKeys")]
|
||||
keys: Option<KeysData>,
|
||||
|
||||
// Supersedes `keys`, and the only way a v2 account can be registered.
|
||||
account_keys: Option<AccountKeysData>,
|
||||
|
||||
master_password_hint: Option<String>,
|
||||
|
||||
name: Option<String>,
|
||||
@@ -122,6 +116,36 @@ pub struct RegisterData {
|
||||
org_invite_token: Option<String>,
|
||||
}
|
||||
|
||||
impl RegisterData {
|
||||
fn hash(&self) -> String {
|
||||
self.compat.fold(|rdc| &rdc.master_password_hash, |rdcu| &rdcu.master_password_authentication.hash).to_owned()
|
||||
}
|
||||
|
||||
fn kdf(&self) -> &KDFData {
|
||||
self.compat.fold(|rdc| &rdc.kdf, |rdcu| &rdcu.master_password_authentication.kdf)
|
||||
}
|
||||
|
||||
fn key(&self) -> String {
|
||||
self.compat.fold(|rdc| &rdc.key, |rdcu| &rdcu.master_password_unlock.key).to_owned()
|
||||
}
|
||||
|
||||
// When comparing with salt, email need to be normalized:
|
||||
// - https://github.com/bitwarden/clients/blob/web-v2026.5.0/libs/common/src/key-management/master-password/services/master-password.service.ts#L171
|
||||
fn unprocessable(&self) -> bool {
|
||||
let mut unprocessable = false;
|
||||
*self.compat.fold(
|
||||
|_| &false,
|
||||
|rdcu| {
|
||||
let email = self.email.trim().to_lowercase();
|
||||
unprocessable = rdcu.master_password_authentication.kdf != rdcu.master_password_unlock.kdf
|
||||
|| rdcu.master_password_authentication.salt != email
|
||||
|| rdcu.master_password_unlock.salt != email;
|
||||
&unprocessable
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct RegisterDataOld {
|
||||
#[serde(flatten)]
|
||||
@@ -159,34 +183,6 @@ impl RegisterDataCompat {
|
||||
RegisterDataCompat::RegisterDataCur(rdcu) => fcu(rdcu),
|
||||
}
|
||||
}
|
||||
|
||||
fn hash(&self) -> String {
|
||||
self.fold(|rdc| &rdc.master_password_hash, |rdcu| &rdcu.master_password_authentication.hash).to_owned()
|
||||
}
|
||||
|
||||
fn kdf(&self) -> &KDFData {
|
||||
self.fold(|rdc| &rdc.kdf, |rdcu| &rdcu.master_password_authentication.kdf)
|
||||
}
|
||||
|
||||
fn key(&self) -> String {
|
||||
self.fold(|rdc| &rdc.key, |rdcu| &rdcu.master_password_unlock.key).to_owned()
|
||||
}
|
||||
|
||||
// When comparing with salt, email need to be normalized:
|
||||
// - https://github.com/bitwarden/clients/blob/web-v2026.5.0/libs/common/src/key-management/master-password/services/master-password.service.ts#L171
|
||||
fn unprocessable(&self, email: &str) -> bool {
|
||||
let mut unprocessable = false;
|
||||
*self.fold(
|
||||
|_| &false,
|
||||
|rdcu| {
|
||||
let email = email.trim().to_lowercase();
|
||||
unprocessable = rdcu.master_password_authentication.kdf != rdcu.master_password_unlock.kdf
|
||||
|| rdcu.master_password_authentication.salt != email
|
||||
|| rdcu.master_password_unlock.salt != email;
|
||||
&unprocessable
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
@@ -196,167 +192,6 @@ struct KeysData {
|
||||
public_key: String,
|
||||
}
|
||||
|
||||
/// The `accountKeys` payload, which replaces the flat `keys`/`userAsymmetricKeys` object.
|
||||
///
|
||||
/// It carries either a "v1" state (just the encryption key pair) or a "v2" one, which adds a
|
||||
/// signature key pair, a signed public key, and a signed security state. The two deprecated
|
||||
/// top-level fields are still sent by the SDK alongside the nested ones and are only used as a
|
||||
/// fallback for clients that don't send `publicKeyEncryptionKeyPair` yet.
|
||||
///
|
||||
/// Ref: <https://github.com/bitwarden/server/blob/main/src/Core/KeyManagement/Models/Api/Request/AccountKeysRequestModel.cs>
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AccountKeysData {
|
||||
user_key_encrypted_account_private_key: Option<String>,
|
||||
account_public_key: Option<String>,
|
||||
|
||||
public_key_encryption_key_pair: Option<PublicKeyEncryptionKeyPairData>,
|
||||
signature_key_pair: Option<SignatureKeyPairData>,
|
||||
security_state: Option<SecurityStateData>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct PublicKeyEncryptionKeyPairData {
|
||||
wrapped_private_key: String,
|
||||
public_key: String,
|
||||
signed_public_key: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct SignatureKeyPairData {
|
||||
signature_algorithm: String,
|
||||
wrapped_signing_key: String,
|
||||
verifying_key: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct SecurityStateData {
|
||||
security_state: String,
|
||||
security_version: i32,
|
||||
}
|
||||
|
||||
pub struct ValidatedAccountKeys {
|
||||
private_key: String,
|
||||
public_key: String,
|
||||
v2: Option<ValidatedV2AccountKeys>,
|
||||
}
|
||||
|
||||
struct ValidatedV2AccountKeys {
|
||||
signed_public_key: String,
|
||||
signing_key: String,
|
||||
verifying_key: String,
|
||||
signature_algorithm: SignatureAlgorithm,
|
||||
security_state: String,
|
||||
security_version: i32,
|
||||
}
|
||||
|
||||
impl AccountKeysData {
|
||||
/// Checks that the payload describes a complete account cryptographic state.
|
||||
///
|
||||
/// The v2 fields have to be all present or all absent: a client that receives a COSE-wrapped
|
||||
/// private key without the matching signature key pair and security state refuses to unlock the
|
||||
/// vault, so storing half a state would produce an account nobody can log into.
|
||||
pub fn validate(self) -> ApiResult<ValidatedAccountKeys> {
|
||||
let (private_key, public_key, signed_public_key) = if let Some(key_pair) = self.public_key_encryption_key_pair {
|
||||
(key_pair.wrapped_private_key, key_pair.public_key, key_pair.signed_public_key)
|
||||
// Older clients only send the deprecated top-level fields, which are always v1.
|
||||
} else if let (Some(private_key), Some(public_key)) =
|
||||
(self.user_key_encrypted_account_private_key, self.account_public_key)
|
||||
{
|
||||
(private_key, public_key, None)
|
||||
} else {
|
||||
err!("The account keys are missing an encryption key pair")
|
||||
};
|
||||
|
||||
let v2 = match (signed_public_key, self.signature_key_pair, self.security_state) {
|
||||
(Some(signed_public_key), Some(signature_key_pair), Some(security_state)) => {
|
||||
let Some(signature_algorithm) = SignatureAlgorithm::from_str(&signature_key_pair.signature_algorithm)
|
||||
else {
|
||||
err!(format!("Unsupported signature algorithm: {}", signature_key_pair.signature_algorithm))
|
||||
};
|
||||
|
||||
Some(ValidatedV2AccountKeys {
|
||||
signed_public_key,
|
||||
signing_key: signature_key_pair.wrapped_signing_key,
|
||||
verifying_key: signature_key_pair.verifying_key,
|
||||
signature_algorithm,
|
||||
security_state: security_state.security_state,
|
||||
security_version: security_state.security_version,
|
||||
})
|
||||
}
|
||||
(None, None, None) => None,
|
||||
_ => err!(
|
||||
"Invalid account keys: the signed public key, signature key pair and security state must either all be present or all be absent"
|
||||
),
|
||||
};
|
||||
|
||||
Ok(ValidatedAccountKeys {
|
||||
private_key,
|
||||
public_key,
|
||||
v2,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl From<KeysData> for ValidatedAccountKeys {
|
||||
fn from(keys: KeysData) -> Self {
|
||||
Self {
|
||||
private_key: keys.encrypted_private_key,
|
||||
public_key: keys.public_key,
|
||||
v2: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ValidatedAccountKeys {
|
||||
/// Writes the parts of the state that live on the user itself. The user still needs saving, and
|
||||
/// [`Self::save_signature_key_pair`] still needs calling once it has been.
|
||||
///
|
||||
/// Rejects downgrading an account from v2 back to v1.
|
||||
pub fn apply(&self, user: &mut User) -> EmptyResult {
|
||||
if user.is_v2() && self.v2.is_none() {
|
||||
err!("Cannot downgrade an account from v2 to v1 encryption")
|
||||
}
|
||||
|
||||
user.private_key = Some(self.private_key.clone());
|
||||
user.public_key = Some(self.public_key.clone());
|
||||
|
||||
user.signed_public_key = self.v2.as_ref().map(|v2| v2.signed_public_key.clone());
|
||||
user.security_state = self.v2.as_ref().map(|v2| v2.security_state.clone());
|
||||
user.security_version = self.v2.as_ref().map(|v2| v2.security_version);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Persists the signature key pair. Separate from [`Self::apply`] because the row has a foreign
|
||||
/// key to the user, so it can only be written once the user exists.
|
||||
pub async fn save_signature_key_pair(&self, user_id: &UserId, conn: &DbConn) -> EmptyResult {
|
||||
// Skip if the account is v1, since v1 accounts don't have a signature key pair.
|
||||
let Some(v2) = &self.v2 else {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
let mut key_pair = match UserSignatureKeyPair::find_active_by_user(user_id, conn).await {
|
||||
Some(mut key_pair) => {
|
||||
key_pair.signature_algorithm = v2.signature_algorithm as i32;
|
||||
key_pair.signing_key.clone_from(&v2.signing_key);
|
||||
key_pair.verifying_key.clone_from(&v2.verifying_key);
|
||||
key_pair
|
||||
}
|
||||
None => UserSignatureKeyPair::new(
|
||||
user_id.clone(),
|
||||
v2.signature_algorithm,
|
||||
v2.signing_key.clone(),
|
||||
v2.verifying_key.clone(),
|
||||
),
|
||||
};
|
||||
key_pair.save(conn).await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct MasterPasswordAuthentication {
|
||||
@@ -381,12 +216,11 @@ pub struct MasterPasswordUnlock {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SetPasswordData {
|
||||
#[serde(flatten)]
|
||||
compat: RegisterDataCompat,
|
||||
kdf: KDFData,
|
||||
|
||||
key: String,
|
||||
keys: Option<KeysData>,
|
||||
// Supersedes `keys`, and the only way a v2 account can be initialized here.
|
||||
account_keys: Option<AccountKeysData>,
|
||||
|
||||
master_password_hash: String,
|
||||
master_password_hint: Option<String>,
|
||||
org_identifier: Option<String>,
|
||||
}
|
||||
@@ -429,7 +263,7 @@ pub async fn register(data: Json<RegisterData>, email_verification: bool, conn:
|
||||
|
||||
let mut pending_emergency_access = None;
|
||||
|
||||
if data.compat.unprocessable(&data.email) {
|
||||
if data.unprocessable() {
|
||||
err_code!("Unexpected RegisterData format", Status::UnprocessableEntity.code);
|
||||
}
|
||||
|
||||
@@ -552,9 +386,9 @@ pub async fn register(data: Json<RegisterData>, email_verification: bool, conn:
|
||||
// Make sure we don't leave a lingering invitation.
|
||||
Invitation::take(&email, &conn).await;
|
||||
|
||||
set_kdf_data(&mut user, data.compat.kdf())?;
|
||||
set_kdf_data(&mut user, data.kdf())?;
|
||||
|
||||
user.set_password(&data.compat.hash(), Some(data.compat.key()), true, None, &conn).await?;
|
||||
user.set_password(&data.hash(), Some(data.key()), true, None, &conn).await?;
|
||||
user.password_hint = password_hint;
|
||||
|
||||
// Add extra fields if present
|
||||
@@ -562,13 +396,9 @@ pub async fn register(data: Json<RegisterData>, email_verification: bool, conn:
|
||||
user.name = name;
|
||||
}
|
||||
|
||||
let account_keys = match (data.account_keys, data.keys) {
|
||||
(Some(account_keys), _) => Some(account_keys.validate()?),
|
||||
(None, Some(keys)) => Some(keys.into()),
|
||||
(None, None) => None,
|
||||
};
|
||||
if let Some(ref account_keys) = account_keys {
|
||||
account_keys.apply(&mut user)?;
|
||||
if let Some(keys) = data.keys {
|
||||
user.private_key = Some(keys.encrypted_private_key);
|
||||
user.public_key = Some(keys.public_key);
|
||||
}
|
||||
|
||||
if email_verified {
|
||||
@@ -592,10 +422,6 @@ pub async fn register(data: Json<RegisterData>, email_verification: bool, conn:
|
||||
|
||||
user.save(&conn).await?;
|
||||
|
||||
if let Some(account_keys) = account_keys {
|
||||
account_keys.save_signature_key_pair(&user.uuid, &conn).await?;
|
||||
}
|
||||
|
||||
// accept any open emergency access invitations
|
||||
if !CONFIG.mail_enabled() && CONFIG.emergency_access_allowed() {
|
||||
for mut emergency_invite in EmergencyAccess::find_all_invited_by_grantee_email(&user.email, &conn).await {
|
||||
@@ -618,26 +444,16 @@ async fn post_set_password(data: Json<SetPasswordData>, headers: Headers, conn:
|
||||
err!("Account already initialized, cannot set password")
|
||||
}
|
||||
|
||||
if data.compat.unprocessable(&user.email) {
|
||||
err_code!("Unexpected SetPasswordData format", Status::UnprocessableEntity.code);
|
||||
}
|
||||
|
||||
// Check against the password hint setting here so if it fails,
|
||||
// the user can retry without losing their invitation below.
|
||||
let password_hint = clean_password_hint(data.master_password_hint.as_ref());
|
||||
enforce_password_hint_setting(password_hint.as_ref())?;
|
||||
|
||||
let account_keys = match (data.account_keys, data.keys) {
|
||||
(Some(account_keys), _) => Some(account_keys.validate()?),
|
||||
(None, Some(keys)) => Some(keys.into()),
|
||||
(None, None) => None,
|
||||
};
|
||||
|
||||
set_kdf_data(&mut user, data.compat.kdf())?;
|
||||
set_kdf_data(&mut user, &data.kdf)?;
|
||||
|
||||
user.set_password(
|
||||
&data.compat.hash(),
|
||||
Some(data.compat.key()),
|
||||
&data.master_password_hash,
|
||||
Some(data.key),
|
||||
false,
|
||||
Some(vec![String::from("revision_date")]), // We need to allow revision-date to use the old security_timestamp
|
||||
&conn,
|
||||
@@ -645,8 +461,9 @@ async fn post_set_password(data: Json<SetPasswordData>, headers: Headers, conn:
|
||||
.await?;
|
||||
user.password_hint = password_hint;
|
||||
|
||||
if let Some(ref account_keys) = account_keys {
|
||||
account_keys.apply(&mut user)?;
|
||||
if let Some(keys) = data.keys {
|
||||
user.private_key = Some(keys.encrypted_private_key);
|
||||
user.public_key = Some(keys.public_key);
|
||||
}
|
||||
|
||||
if let Some(identifier) = data.org_identifier
|
||||
@@ -675,10 +492,6 @@ async fn post_set_password(data: Json<SetPasswordData>, headers: Headers, conn:
|
||||
|
||||
user.save(&conn).await?;
|
||||
|
||||
if let Some(account_keys) = account_keys {
|
||||
account_keys.save_signature_key_pair(&user.uuid, &conn).await?;
|
||||
}
|
||||
|
||||
Ok(Json(json!({
|
||||
"object": "set-password",
|
||||
"captchaBypassToken": "",
|
||||
@@ -760,60 +573,20 @@ async fn get_public_keys(user_id: UserId, _headers: Headers, conn: DbConn) -> Js
|
||||
})))
|
||||
}
|
||||
|
||||
#[get("/users/<user_id>/keys")]
|
||||
async fn get_account_public_keys(user_id: UserId, _headers: Headers, conn: DbConn) -> JsonResult {
|
||||
let user = match User::find_by_uuid(&user_id, &conn).await {
|
||||
Some(user) if user.public_key.is_some() => user,
|
||||
Some(_) => err_code!("User has no public_key", Status::NotFound.code),
|
||||
None => err_code!("User doesn't exist", Status::NotFound.code),
|
||||
};
|
||||
|
||||
Ok(Json(user.public_keys_json(&conn).await))
|
||||
}
|
||||
|
||||
#[get("/accounts/keys")]
|
||||
async fn get_keys(headers: Headers, conn: DbConn) -> JsonResult {
|
||||
let user = headers.user;
|
||||
|
||||
Ok(Json(json!({
|
||||
"key": user.akey,
|
||||
"privateKey": user.private_key,
|
||||
"publicKey": user.public_key,
|
||||
"accountKeys": user.account_keys_json(&conn).await,
|
||||
"object": "keys"
|
||||
})))
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct PostKeysData {
|
||||
#[serde(flatten)]
|
||||
keys: Option<KeysData>,
|
||||
account_keys: Option<AccountKeysData>,
|
||||
}
|
||||
|
||||
#[post("/accounts/keys", data = "<data>")]
|
||||
async fn post_keys(data: Json<PostKeysData>, headers: Headers, conn: DbConn) -> JsonResult {
|
||||
let data: PostKeysData = data.into_inner();
|
||||
async fn post_keys(data: Json<KeysData>, headers: Headers, conn: DbConn) -> JsonResult {
|
||||
let data: KeysData = data.into_inner();
|
||||
|
||||
let mut user = headers.user;
|
||||
|
||||
// `accountKeys` supersedes the flat `keys` object when both are sent.
|
||||
let account_keys = match (data.account_keys, data.keys) {
|
||||
(Some(account_keys), _) => account_keys.validate()?,
|
||||
(None, Some(keys)) => keys.into(),
|
||||
(None, None) => err!("No account keys provided"),
|
||||
};
|
||||
user.private_key = Some(data.encrypted_private_key);
|
||||
user.public_key = Some(data.public_key);
|
||||
|
||||
account_keys.apply(&mut user)?;
|
||||
user.save(&conn).await?;
|
||||
account_keys.save_signature_key_pair(&user.uuid, &conn).await?;
|
||||
|
||||
Ok(Json(json!({
|
||||
"key": user.akey,
|
||||
"privateKey": user.private_key,
|
||||
"publicKey": user.public_key,
|
||||
"accountKeys": user.account_keys_json(&conn).await,
|
||||
"object":"keys"
|
||||
})))
|
||||
}
|
||||
@@ -920,6 +693,10 @@ struct UnlockData {
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct ChangeKdfData {
|
||||
#[allow(dead_code)]
|
||||
new_master_password_hash: String,
|
||||
#[allow(dead_code)]
|
||||
key: String,
|
||||
authentication_data: AuthenticationData,
|
||||
unlock_data: UnlockData,
|
||||
master_password_hash: String,
|
||||
@@ -1561,13 +1338,6 @@ pub async fn prelogin(data: Json<PreloginData>, conn: DbConn) -> Json<Value> {
|
||||
"kdfIterations": kdf_iter,
|
||||
"kdfMemory": kdf_mem,
|
||||
"kdfParallelism": kdf_para,
|
||||
"kdfSettings": {
|
||||
"iterations": kdf_iter,
|
||||
"kdfType": kdf_type,
|
||||
"memory": kdf_mem,
|
||||
"parallelism": kdf_para
|
||||
},
|
||||
"salt": null,
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
@@ -198,7 +198,6 @@ async fn sync(data: SyncData, headers: Headers, client_version: Option<ClientVer
|
||||
"sends": sends_json,
|
||||
"userDecryption": {
|
||||
"masterPasswordUnlock": master_password_unlock,
|
||||
"v2UpgradeToken": headers.user.v2_upgrade_token_json(),
|
||||
},
|
||||
"object": "sync"
|
||||
})))
|
||||
@@ -451,9 +450,7 @@ pub async fn update_cipher_from_data(
|
||||
match Membership::find_confirmed_by_user_and_org(&headers.user.uuid, &org_id, conn).await {
|
||||
None => err!("You don't have permission to add item to organization"),
|
||||
Some(member) => {
|
||||
// A non-empty list of collections implies the caller already validated the user's write
|
||||
// access to them, so we can move the cipher into the organization on that basis.
|
||||
if shared_to_collections.as_ref().is_some_and(|cols| !cols.is_empty())
|
||||
if shared_to_collections.is_some()
|
||||
|| member.has_full_access()
|
||||
|| cipher.is_write_accessible_to_user(&headers.user.uuid, conn).await
|
||||
{
|
||||
|
||||
+2
-9
@@ -228,17 +228,14 @@ fn config() -> Json<Value> {
|
||||
// Version history:
|
||||
// - Individual cipher key encryption: 2024.2.0
|
||||
// - Mobile app support for MasterPasswordUnlockData: 2025.8.0
|
||||
"version": "2026.6.0",
|
||||
"version": "2025.12.0",
|
||||
"gitHash": option_env!("GIT_REV"),
|
||||
"server": {
|
||||
"name": "Vaultwarden",
|
||||
"url": "https://github.com/dani-garcia/vaultwarden"
|
||||
},
|
||||
"settings": {
|
||||
"disableUserRegistration": CONFIG.is_signup_disabled(),
|
||||
// When enabled, this setting signals to clients that onboarding interstitials
|
||||
// (post-login welcome dialogs, extension install prompts, setup extension redirects, and premium upsell modals) should be suppressed
|
||||
"suppressOnboardingInterstitials": false
|
||||
"disableUserRegistration": CONFIG.is_signup_disabled()
|
||||
},
|
||||
"environment": {
|
||||
"vault": domain,
|
||||
@@ -254,10 +251,6 @@ fn config() -> Json<Value> {
|
||||
"vapidPublicKey": null
|
||||
},
|
||||
"featureStates": feature_states,
|
||||
// Not supported right now
|
||||
// Used for by clients to learn if the server requires extra work to establish a connection.
|
||||
// See: https://github.com/bitwarden/server/pull/6892 | https://github.com/bitwarden/server/commit/52955d1860b4dfb905f67bbe39d9b10bbd61ded0
|
||||
"communication": null,
|
||||
"object": "config",
|
||||
}))
|
||||
}
|
||||
|
||||
+22
-8
@@ -453,9 +453,6 @@ async fn post_access(headers: SendHeaders, conn: DbConn, nt: Notify<'_>) -> Json
|
||||
let Some(send) = Send::find_by_uuid(&headers.send_id, &conn).await else {
|
||||
err_code!(SEND_INACCESSIBLE_MSG, 404)
|
||||
};
|
||||
if !send.is_accessible() {
|
||||
err_code!(SEND_INACCESSIBLE_MSG, 404)
|
||||
}
|
||||
process_access(send, conn, nt).await
|
||||
}
|
||||
|
||||
@@ -486,7 +483,17 @@ async fn post_access_legacy(
|
||||
err_code!(SEND_INACCESSIBLE_MSG, 404);
|
||||
}
|
||||
|
||||
if !send.is_accessible() {
|
||||
if let Some(expiration) = send.expiration_date
|
||||
&& Utc::now().naive_utc() >= expiration
|
||||
{
|
||||
err_code!(SEND_INACCESSIBLE_MSG, 404)
|
||||
}
|
||||
|
||||
if Utc::now().naive_utc() >= send.deletion_date {
|
||||
err_code!(SEND_INACCESSIBLE_MSG, 404)
|
||||
}
|
||||
|
||||
if send.disabled {
|
||||
err_code!(SEND_INACCESSIBLE_MSG, 404)
|
||||
}
|
||||
|
||||
@@ -534,9 +541,6 @@ async fn post_access_file(
|
||||
let Some(send) = Send::find_by_uuid(&headers.send_id, &conn).await else {
|
||||
err_code!(SEND_INACCESSIBLE_MSG, 404)
|
||||
};
|
||||
if !send.is_accessible() {
|
||||
err_code!(SEND_INACCESSIBLE_MSG, 404)
|
||||
}
|
||||
process_access_file(send, file_id, host, conn, nt).await
|
||||
}
|
||||
|
||||
@@ -563,7 +567,17 @@ async fn post_access_file_legacy(
|
||||
err_code!(SEND_INACCESSIBLE_MSG, 404)
|
||||
}
|
||||
|
||||
if !send.is_accessible() {
|
||||
if let Some(expiration) = send.expiration_date
|
||||
&& Utc::now().naive_utc() >= expiration
|
||||
{
|
||||
err_code!(SEND_INACCESSIBLE_MSG, 404)
|
||||
}
|
||||
|
||||
if Utc::now().naive_utc() >= send.deletion_date {
|
||||
err_code!(SEND_INACCESSIBLE_MSG, 404)
|
||||
}
|
||||
|
||||
if send.disabled {
|
||||
err_code!(SEND_INACCESSIBLE_MSG, 404)
|
||||
}
|
||||
|
||||
|
||||
+24
-2
@@ -534,7 +534,18 @@ async fn authenticated_response(
|
||||
Value::Null
|
||||
};
|
||||
|
||||
let account_keys = user.account_keys_json(conn).await;
|
||||
let account_keys = if user.private_key.is_some() {
|
||||
json!({
|
||||
"publicKeyEncryptionKeyPair": {
|
||||
"wrappedPrivateKey": user.private_key,
|
||||
"publicKey": user.public_key,
|
||||
"Object": "publicKeyEncryptionKeyPair"
|
||||
},
|
||||
"Object": "privateKeys"
|
||||
})
|
||||
} else {
|
||||
Value::Null
|
||||
};
|
||||
|
||||
let mut result = json!({
|
||||
"access_token": auth_tokens.access_token(),
|
||||
@@ -674,7 +685,18 @@ async fn user_api_key_login(
|
||||
Value::Null
|
||||
};
|
||||
|
||||
let account_keys = user.account_keys_json(conn).await;
|
||||
let account_keys = if user.private_key.is_some() {
|
||||
json!({
|
||||
"publicKeyEncryptionKeyPair": {
|
||||
"wrappedPrivateKey": user.private_key,
|
||||
"publicKey": user.public_key,
|
||||
"Object": "publicKeyEncryptionKeyPair"
|
||||
},
|
||||
"Object": "privateKeys"
|
||||
})
|
||||
} else {
|
||||
Value::Null
|
||||
};
|
||||
|
||||
// Note: No refresh_token is returned. The CLI just repeats the
|
||||
// client_credentials login flow when the existing token expires.
|
||||
|
||||
+12
-2
@@ -85,8 +85,18 @@ impl SendTokens {
|
||||
return Self::invalid_error(&format!("Send {send_id}, max access reached"), "send_id_invalid", true);
|
||||
}
|
||||
|
||||
if !send.is_accessible() {
|
||||
return Self::invalid_error(&format!("Send {send_id}, not accessible"), "send_id_invalid", true);
|
||||
if let Some(expiration) = send.expiration_date
|
||||
&& Utc::now().naive_utc() >= expiration
|
||||
{
|
||||
return Self::invalid_error(&format!("Send {send_id}, expired"), "send_id_invalid", true);
|
||||
}
|
||||
|
||||
if Utc::now().naive_utc() >= send.deletion_date {
|
||||
return Self::invalid_error(&format!("Send {send_id}, past deletion"), "send_id_invalid", true);
|
||||
}
|
||||
|
||||
if send.disabled {
|
||||
return Self::invalid_error(&format!("Send {send_id}, disabled"), "send_id_invalid", true);
|
||||
}
|
||||
|
||||
if send.password_hash.is_some() {
|
||||
|
||||
+19
-15
@@ -42,15 +42,13 @@ pub struct Cipher {
|
||||
|
||||
pub key: Option<String>,
|
||||
|
||||
// See (v2026.7.0): https://github.com/bitwarden/server/blob/5d4461aa42cadbacfef8fe2166c5453a5c52773a/src/Core/Vault/Enums/CipherType.cs
|
||||
// Login = 1,
|
||||
// SecureNote = 2,
|
||||
// Card = 3,
|
||||
// Identity = 4,
|
||||
// SSHKey = 5
|
||||
// BankAccount = 6,
|
||||
// DriversLicense = 7,
|
||||
// Passport = 8,
|
||||
/*
|
||||
Login = 1,
|
||||
SecureNote = 2,
|
||||
Card = 3,
|
||||
Identity = 4,
|
||||
SshKey = 5
|
||||
*/
|
||||
pub atype: i32,
|
||||
pub name: String,
|
||||
pub notes: Option<String>,
|
||||
@@ -308,6 +306,16 @@ impl Cipher {
|
||||
type_data_json = Value::Null;
|
||||
}
|
||||
|
||||
// Clone the type_data and add some default value.
|
||||
let mut data_json = type_data_json.clone();
|
||||
|
||||
// NOTE: This was marked as *Backwards Compatibility Code*, but as of January 2021 this is still being used by upstream
|
||||
// data_json should always contain the following keys with every atype
|
||||
data_json["fields"] = json!(fields_json);
|
||||
data_json["name"] = json!(self.name);
|
||||
data_json["notes"] = json!(self.notes);
|
||||
data_json["passwordHistory"] = Value::Array(password_history_json.clone());
|
||||
|
||||
let collection_ids = if let Some(cipher_sync_data) = cipher_sync_data {
|
||||
if let Some(cipher_collections) = cipher_sync_data.cipher_collections.get(&self.uuid) {
|
||||
Cow::from(cipher_collections)
|
||||
@@ -347,6 +355,8 @@ impl Cipher {
|
||||
"notes": self.notes,
|
||||
"fields": fields_json,
|
||||
|
||||
"data": data_json,
|
||||
|
||||
"passwordHistory": password_history_json,
|
||||
|
||||
// All Cipher types are included by default as null, but only the matching one will be populated
|
||||
@@ -355,9 +365,6 @@ impl Cipher {
|
||||
"card": null,
|
||||
"identity": null,
|
||||
"sshKey": null,
|
||||
"bankAccount": null,
|
||||
"driversLicense": null,
|
||||
"passport": null,
|
||||
});
|
||||
|
||||
// These values are only needed for user/default syncs
|
||||
@@ -397,9 +404,6 @@ impl Cipher {
|
||||
3 => "card",
|
||||
4 => "identity",
|
||||
5 => "sshKey",
|
||||
6 => "bankAccount",
|
||||
7 => "driversLicense",
|
||||
8 => "passport",
|
||||
_ => err!(format!("Cipher {} has an invalid type {}", self.uuid, self.atype)),
|
||||
};
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ use super::{
|
||||
User, UserId,
|
||||
};
|
||||
|
||||
// See (v2026.7.0): https://github.com/bitwarden/server/blob/5d4461aa42cadbacfef8fe2166c5453a5c52773a/src/Core/AdminConsole/Entities/Collection.cs
|
||||
#[derive(Identifiable, Queryable, Insertable, AsChangeset)]
|
||||
#[diesel(table_name = collections)]
|
||||
#[diesel(treat_none_as_null = true)]
|
||||
@@ -72,11 +71,6 @@ impl Collection {
|
||||
"id": self.uuid,
|
||||
"organizationId": self.org_uuid,
|
||||
"name": self.name,
|
||||
// Collection types are either 0: SharedCollection or 1: DefaultUserCollection, of which we do not yet support DefaultUserCollection.
|
||||
// See (v2026.7.0): https://github.com/bitwarden/server/blob/5d4461aa42cadbacfef8fe2166c5453a5c52773a/src/Core/AdminConsole/Enums/CollectionType.cs
|
||||
"type": 0,
|
||||
// This is only used together with MyItems/DefaultUserCollection, which we do not yet support.
|
||||
"defaultUserCollectionEmail": null,
|
||||
"object": "collection",
|
||||
})
|
||||
}
|
||||
@@ -660,7 +654,9 @@ impl Collection {
|
||||
.filter(collections::org_uuid.eq(&org_uuid))
|
||||
.filter(
|
||||
// Manage permission on a collection assigned directly or via a group.
|
||||
users_collections::manage.eq(true).or(collections_groups::manage.eq(true)),
|
||||
users_collections::manage
|
||||
.eq(true)
|
||||
.or(collections_groups::manage.eq(true)),
|
||||
)
|
||||
.count()
|
||||
.first::<i64>(conn)
|
||||
|
||||
@@ -17,7 +17,6 @@ mod two_factor;
|
||||
mod two_factor_duo_context;
|
||||
mod two_factor_incomplete;
|
||||
mod user;
|
||||
mod user_signature_key_pair;
|
||||
|
||||
pub use self::archive::Archive;
|
||||
pub use self::attachment::{Attachment, AttachmentId};
|
||||
@@ -41,4 +40,3 @@ pub use self::two_factor::{TwoFactor, TwoFactorType};
|
||||
pub use self::two_factor_duo_context::TwoFactorDuoContext;
|
||||
pub use self::two_factor_incomplete::TwoFactorIncomplete;
|
||||
pub use self::user::{Invitation, SsoUser, User, UserId, UserKdfType, UserStampException};
|
||||
pub use self::user_signature_key_pair::{SignatureAlgorithm, UserSignatureKeyPair};
|
||||
|
||||
@@ -217,18 +217,11 @@ impl Organization {
|
||||
"useSecretsManager": false, // Not supported (Not AGPLv3 Licensed)
|
||||
"selfHost": true,
|
||||
"useApi": true,
|
||||
"useDisableSMAdsForUsers": true, // Hide Secrets Manager ads
|
||||
"useInviteLinks": false, // Not (yet) supported
|
||||
"useMyItems": false, // Not (yet) supported
|
||||
"useOrganizationDomains": false, // Not supported (Linked to SSO)
|
||||
"usePam": false, // Not supported
|
||||
"usePhishingBlocker": false,
|
||||
"hasPublicAndPrivateKeys": self.private_key.is_some() && self.public_key.is_some(),
|
||||
"useResetPassword": CONFIG.mail_enabled(),
|
||||
"allowAdminAccessToAllCollectionItems": true,
|
||||
"limitCollectionCreation": true,
|
||||
"limitCollectionDeletion": true,
|
||||
"limitItemDeletion": false,
|
||||
|
||||
"businessName": self.name,
|
||||
"businessAddress1": null,
|
||||
@@ -502,12 +495,6 @@ impl Membership {
|
||||
"useActivateAutofillPolicy": false,
|
||||
"useAdminSponsoredFamilies": false,
|
||||
"useRiskInsights": false, // Not supported (Not AGPLv3 Licensed)
|
||||
"useDisableSMAdsForUsers": true, // Hide Secrets Manager ads
|
||||
"useInviteLinks": false, // Not (yet) supported
|
||||
"useMyItems": false, // Not (yet) supported
|
||||
"useOrganizationDomains": false, // Not supported (Linked to SSO)
|
||||
"usePam": false, // Not supported
|
||||
"usePhishingBlocker": false,
|
||||
|
||||
"organizationUserId": self.uuid,
|
||||
"providerId": null,
|
||||
|
||||
@@ -262,22 +262,6 @@ impl Send {
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
/// Whether the Send is currently within its validity window: not disabled, not past its
|
||||
/// expiration date, and not past its deletion date. Does not consider `max_access_count`
|
||||
/// (consumed at token issuance) or the password.
|
||||
pub fn is_accessible(&self) -> bool {
|
||||
let now = Utc::now().naive_utc();
|
||||
if self.disabled {
|
||||
return false;
|
||||
}
|
||||
if let Some(expiration) = self.expiration_date
|
||||
&& now >= expiration
|
||||
{
|
||||
return false;
|
||||
}
|
||||
now < self.deletion_date
|
||||
}
|
||||
|
||||
pub async fn delete(&self, conn: &DbConn) -> EmptyResult {
|
||||
self.update_users_revision(conn).await;
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ use macros::UuidFromParam;
|
||||
|
||||
use super::{
|
||||
Cipher, Device, EmergencyAccess, Favorite, Folder, Membership, MembershipType, TwoFactor, TwoFactorIncomplete,
|
||||
UserSignatureKeyPair,
|
||||
};
|
||||
|
||||
#[derive(Identifiable, Queryable, Insertable, AsChangeset, Selectable)]
|
||||
@@ -70,15 +69,6 @@ pub struct User {
|
||||
pub avatar_color: Option<String>,
|
||||
|
||||
pub external_id: Option<String>, // Todo: Needs to be removed in the future, this is not used anymore.
|
||||
|
||||
// "v2" account cryptographic state. Either all of these are set (together with a row in
|
||||
// `user_signature_key_pairs`) or none of them are; see `User::is_v2`.
|
||||
pub signed_public_key: Option<String>,
|
||||
pub security_state: Option<String>,
|
||||
pub security_version: Option<i32>,
|
||||
/// JSON `{"wrappedUserKey1": ..., "wrappedUserKey2": ...}`, letting clients that still hold the
|
||||
/// v1 user key obtain the v2 one after another client performed the upgrade. Opaque to us.
|
||||
pub v2_upgrade_token: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Identifiable, Queryable, Insertable)]
|
||||
@@ -164,18 +154,9 @@ impl User {
|
||||
avatar_color: None,
|
||||
|
||||
external_id: None, // Todo: Needs to be removed in the future, this is not used anymore.
|
||||
|
||||
signed_public_key: None,
|
||||
security_state: None,
|
||||
security_version: None,
|
||||
v2_upgrade_token: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_v2(&self) -> bool {
|
||||
self.signed_public_key.is_some() && self.security_state.is_some() && self.security_version.is_some()
|
||||
}
|
||||
|
||||
pub fn check_valid_password(&self, password: &str) -> bool {
|
||||
crypto::verify_password_hash(
|
||||
password.as_bytes(),
|
||||
@@ -272,61 +253,6 @@ impl User {
|
||||
|
||||
/// Database methods
|
||||
impl User {
|
||||
async fn v2_signature_key_pair(&self, conn: &DbConn) -> Option<UserSignatureKeyPair> {
|
||||
if !self.is_v2() {
|
||||
return None;
|
||||
}
|
||||
UserSignatureKeyPair::find_active_by_user(&self.uuid, conn).await
|
||||
}
|
||||
|
||||
pub async fn account_keys_json(&self, conn: &DbConn) -> Value {
|
||||
if self.private_key.is_none() {
|
||||
return Value::Null;
|
||||
}
|
||||
|
||||
let (signed_public_key, signature_key_pair, security_state) = match self.v2_signature_key_pair(conn).await {
|
||||
Some(key_pair) => (
|
||||
json!(self.signed_public_key),
|
||||
key_pair.to_json(),
|
||||
json!({
|
||||
"securityState": self.security_state,
|
||||
"securityVersion": self.security_version,
|
||||
}),
|
||||
),
|
||||
None => (Value::Null, Value::Null, Value::Null),
|
||||
};
|
||||
|
||||
json!({
|
||||
"publicKeyEncryptionKeyPair": {
|
||||
"wrappedPrivateKey": self.private_key,
|
||||
"publicKey": self.public_key,
|
||||
"signedPublicKey": signed_public_key,
|
||||
"object": "publicKeyEncryptionKeyPair",
|
||||
},
|
||||
"signatureKeyPair": signature_key_pair,
|
||||
"securityState": security_state,
|
||||
"object": "privateKeys"
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn public_keys_json(&self, conn: &DbConn) -> Value {
|
||||
let (signed_public_key, verifying_key) = match self.v2_signature_key_pair(conn).await {
|
||||
Some(key_pair) => (json!(self.signed_public_key), json!(key_pair.verifying_key)),
|
||||
None => (Value::Null, Value::Null),
|
||||
};
|
||||
|
||||
json!({
|
||||
"publicKey": self.public_key,
|
||||
"signedPublicKey": signed_public_key,
|
||||
"verifyingKey": verifying_key,
|
||||
"object": "publicKeys"
|
||||
})
|
||||
}
|
||||
|
||||
pub fn v2_upgrade_token_json(&self) -> Value {
|
||||
self.v2_upgrade_token.as_ref().and_then(|token| serde_json::from_str(token).ok()).unwrap_or(Value::Null)
|
||||
}
|
||||
|
||||
pub async fn to_json(&self, conn: &DbConn) -> Value {
|
||||
let mut orgs_json = Vec::new();
|
||||
for c in Membership::find_confirmed_by_user(&self.uuid, conn).await {
|
||||
@@ -342,11 +268,8 @@ impl User {
|
||||
UserStatus::Enabled
|
||||
};
|
||||
|
||||
let account_keys = self.account_keys_json(conn).await;
|
||||
|
||||
json!({
|
||||
"_status": status as i32,
|
||||
"accountKeys": account_keys,
|
||||
"id": self.uuid,
|
||||
"name": self.name,
|
||||
"email": self.email,
|
||||
@@ -417,7 +340,6 @@ impl User {
|
||||
Device::delete_all_by_user(&self.uuid, conn).await?;
|
||||
TwoFactor::delete_all_by_user(&self.uuid, conn).await?;
|
||||
TwoFactorIncomplete::delete_all_by_user(&self.uuid, conn).await?;
|
||||
UserSignatureKeyPair::delete_all_by_user(&self.uuid, conn).await?;
|
||||
Invitation::take(&self.email, conn).await; // Delete invitation if any
|
||||
|
||||
conn.run(move |conn| {
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
use chrono::{NaiveDateTime, Utc};
|
||||
use derive_more::{AsRef, Deref, Display, From};
|
||||
use diesel::prelude::*;
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::{
|
||||
api::EmptyResult,
|
||||
db::{DbConn, schema::user_signature_key_pairs},
|
||||
error::MapResult,
|
||||
util::get_uuid,
|
||||
};
|
||||
use macros::UuidFromParam;
|
||||
|
||||
use super::UserId;
|
||||
|
||||
/// A user's signature key pair, part of the "v2" account cryptographic state.
|
||||
///
|
||||
/// Upstream keeps this in its own table rather than as columns on the user, with a unique index on
|
||||
/// the user id. The stated intent is to eventually keep superseded key pairs around (an `active`
|
||||
/// flag was sketched but not shipped), which is why this is modelled as a row with its own identity
|
||||
/// instead of a set of user attributes.
|
||||
///
|
||||
/// Ref: <https://github.com/bitwarden/server/blob/main/src/Sql/dbo/KeyManagement/Tables/UserSignatureKeyPair.sql>
|
||||
#[derive(Identifiable, Queryable, Insertable, AsChangeset, Selectable)]
|
||||
#[diesel(table_name = user_signature_key_pairs)]
|
||||
#[diesel(treat_none_as_null = true)]
|
||||
#[diesel(primary_key(uuid))]
|
||||
pub struct UserSignatureKeyPair {
|
||||
pub uuid: UserSignatureKeyPairId,
|
||||
pub user_uuid: UserId,
|
||||
|
||||
pub signature_algorithm: i32,
|
||||
/// The signing (private) key, wrapped by the user key.
|
||||
pub signing_key: String,
|
||||
/// The COSE-encoded public verifying key.
|
||||
pub verifying_key: String,
|
||||
|
||||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
}
|
||||
|
||||
/// https://github.com/bitwarden/server/blob/main/src/Core/KeyManagement/Enums/SignatureAlgorithm.cs
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum SignatureAlgorithm {
|
||||
Ed25519 = 0,
|
||||
MlDsa44 = 1,
|
||||
}
|
||||
|
||||
impl SignatureAlgorithm {
|
||||
pub fn from_str(algorithm: &str) -> Option<Self> {
|
||||
match algorithm {
|
||||
"ed25519" => Some(Self::Ed25519),
|
||||
"mldsa44" => Some(Self::MlDsa44),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_i32(algorithm: i32) -> Option<Self> {
|
||||
match algorithm {
|
||||
0 => Some(Self::Ed25519),
|
||||
1 => Some(Self::MlDsa44),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
Self::Ed25519 => "ed25519",
|
||||
Self::MlDsa44 => "mldsa44",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Local methods
|
||||
impl UserSignatureKeyPair {
|
||||
pub fn new(
|
||||
user_uuid: UserId,
|
||||
signature_algorithm: SignatureAlgorithm,
|
||||
signing_key: String,
|
||||
verifying_key: String,
|
||||
) -> Self {
|
||||
let now = Utc::now().naive_utc();
|
||||
|
||||
Self {
|
||||
uuid: UserSignatureKeyPairId(get_uuid()),
|
||||
user_uuid,
|
||||
signature_algorithm: signature_algorithm as i32,
|
||||
signing_key,
|
||||
verifying_key,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_json(&self) -> Value {
|
||||
json!({
|
||||
"wrappedSigningKey": self.signing_key,
|
||||
"verifyingKey": self.verifying_key,
|
||||
"object": "signatureKeyPair",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Database methods
|
||||
impl UserSignatureKeyPair {
|
||||
pub async fn save(&mut self, conn: &DbConn) -> EmptyResult {
|
||||
self.updated_at = Utc::now().naive_utc();
|
||||
|
||||
db_run! { conn:
|
||||
mysql {
|
||||
diesel::insert_into(user_signature_key_pairs::table)
|
||||
.values(&*self)
|
||||
.on_conflict(diesel::dsl::DuplicatedKeys)
|
||||
.do_update()
|
||||
.set(&*self)
|
||||
.execute(conn)
|
||||
.map_res("Error saving user signature key pair")
|
||||
}
|
||||
postgresql, sqlite {
|
||||
diesel::insert_into(user_signature_key_pairs::table)
|
||||
.values(&*self)
|
||||
.on_conflict(user_signature_key_pairs::user_uuid)
|
||||
.do_update()
|
||||
.set(&*self)
|
||||
.execute(conn)
|
||||
.map_res("Error saving user signature key pair")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The key pair currently in use by the user. There is at most one today, enforced by a unique
|
||||
/// index on `user_uuid`.
|
||||
pub async fn find_active_by_user(user_uuid: &UserId, conn: &DbConn) -> Option<Self> {
|
||||
conn.run(move |conn| {
|
||||
user_signature_key_pairs::table
|
||||
.filter(user_signature_key_pairs::user_uuid.eq(user_uuid))
|
||||
.first::<Self>(conn)
|
||||
.ok()
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn delete_all_by_user(user_uuid: &UserId, conn: &DbConn) -> EmptyResult {
|
||||
conn.run(move |conn| {
|
||||
diesel::delete(user_signature_key_pairs::table.filter(user_signature_key_pairs::user_uuid.eq(user_uuid)))
|
||||
.execute(conn)
|
||||
.map_res("Error deleting user signature key pairs")
|
||||
})
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
AsRef,
|
||||
Deref,
|
||||
DieselNewType,
|
||||
Display,
|
||||
From,
|
||||
FromForm,
|
||||
Hash,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
UuidFromParam,
|
||||
)]
|
||||
pub struct UserSignatureKeyPairId(String);
|
||||
@@ -217,22 +217,6 @@ table! {
|
||||
api_key -> Nullable<Text>,
|
||||
avatar_color -> Nullable<Text>,
|
||||
external_id -> Nullable<Text>,
|
||||
signed_public_key -> Nullable<Text>,
|
||||
security_state -> Nullable<Text>,
|
||||
security_version -> Nullable<Integer>,
|
||||
v2_upgrade_token -> Nullable<Text>,
|
||||
}
|
||||
}
|
||||
|
||||
table! {
|
||||
user_signature_key_pairs (uuid) {
|
||||
uuid -> Text,
|
||||
user_uuid -> Text,
|
||||
signature_algorithm -> Integer,
|
||||
signing_key -> Text,
|
||||
verifying_key -> Text,
|
||||
created_at -> Timestamp,
|
||||
updated_at -> Timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,7 +382,6 @@ joinable!(collections_groups -> groups (groups_uuid));
|
||||
joinable!(event -> users_organizations (uuid));
|
||||
joinable!(auth_requests -> users (user_uuid));
|
||||
joinable!(sso_users -> users (user_uuid));
|
||||
joinable!(user_signature_key_pairs -> users (user_uuid));
|
||||
|
||||
allow_tables_to_appear_in_same_query!(
|
||||
archives,
|
||||
@@ -425,5 +408,4 @@ allow_tables_to_appear_in_same_query!(
|
||||
collections_groups,
|
||||
event,
|
||||
auth_requests,
|
||||
user_signature_key_pairs,
|
||||
);
|
||||
|
||||
+3
-12
@@ -307,18 +307,9 @@ pub async fn send_invite(
|
||||
if CONFIG.sso_enabled() && CONFIG.sso_only() {
|
||||
query_params.append_pair("orgSsoIdentifier", &org_id);
|
||||
}
|
||||
|
||||
// The web vault requires both of these parameters to be present.
|
||||
// If either is missing it rejects the invite client-side, before any
|
||||
// request reaches the server, showing only "Unable to accept invitation".
|
||||
query_params.append_pair("initOrganization", "false");
|
||||
|
||||
let org_user_has_existing_user = if user.private_key.is_some() {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
};
|
||||
query_params.append_pair("orgUserHasExistingUser", org_user_has_existing_user);
|
||||
if user.private_key.is_some() {
|
||||
query_params.append_pair("orgUserHasExistingUser", "true");
|
||||
}
|
||||
}
|
||||
|
||||
let Some(query_string) = query.query() else {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// The recursion_limit is mainly triggered by the json!() macro.
|
||||
// The more key/value pairs there are the more recursion occurs.
|
||||
// We want to keep this as low as possible!
|
||||
#![recursion_limit = "192"]
|
||||
#![recursion_limit = "165"]
|
||||
|
||||
// When enabled use MiMalloc as malloc instead of the default malloc
|
||||
#[cfg(feature = "enable_mimalloc")]
|
||||
|
||||
@@ -116,8 +116,8 @@ app-security > app-two-factor-setup > form {
|
||||
}
|
||||
|
||||
/* Hide unsupported Custom Role options */
|
||||
:is(bit-dialog, [bit-dialog]) div.tw-ml-4:has(bit-form-control input),
|
||||
:is(bit-dialog, [bit-dialog]) div.tw-col-span-4:has(input[formcontrolname*="access"], input[formcontrolname*="manage"]) {
|
||||
bit-dialog div.tw-ml-4:has(bit-form-control input),
|
||||
bit-dialog div.tw-col-span-4:has(input[formcontrolname*="access"], input[formcontrolname*="manage"]) {
|
||||
@extend %vw-hide;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user