mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-03-17 03:13:34 +02:00
Compare commits
3 Commits
cached-con
...
1.35.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e2cef7e8b | ||
|
|
2af9d21158 | ||
|
|
c4f6c4e63b |
38
.github/workflows/release.yml
vendored
38
.github/workflows/release.yml
vendored
@@ -313,45 +313,43 @@ jobs:
|
|||||||
# Determine Base Tags
|
# Determine Base Tags
|
||||||
- name: Determine Base Tags
|
- name: Determine Base Tags
|
||||||
env:
|
env:
|
||||||
|
BASE_IMAGE_TAG: "${{ matrix.base_image != 'debian' && format('-{0}', matrix.base_image) || '' }}"
|
||||||
REF_TYPE: ${{ github.ref_type }}
|
REF_TYPE: ${{ github.ref_type }}
|
||||||
run: |
|
run: |
|
||||||
# Check which main tag we are going to build determined by ref_type
|
# Check which main tag we are going to build determined by ref_type
|
||||||
if [[ "${REF_TYPE}" == "tag" ]]; then
|
if [[ "${REF_TYPE}" == "tag" ]]; then
|
||||||
echo "BASE_TAGS=latest,${GITHUB_REF#refs/*/}" | tee -a "${GITHUB_ENV}"
|
echo "BASE_TAGS=latest${BASE_IMAGE_TAG},${GITHUB_REF#refs/*/}${BASE_IMAGE_TAG}${BASE_IMAGE_TAG//-/,}" | tee -a "${GITHUB_ENV}"
|
||||||
elif [[ "${REF_TYPE}" == "branch" ]]; then
|
elif [[ "${REF_TYPE}" == "branch" ]]; then
|
||||||
echo "BASE_TAGS=testing" | tee -a "${GITHUB_ENV}"
|
echo "BASE_TAGS=testing${BASE_IMAGE_TAG}" | tee -a "${GITHUB_ENV}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Create manifest list, push it and extract digest SHA
|
- name: Create manifest list, push it and extract digest SHA
|
||||||
working-directory: ${{ runner.temp }}/digests
|
working-directory: ${{ runner.temp }}/digests
|
||||||
env:
|
env:
|
||||||
BASE_IMAGE_TAG: "${{ matrix.base_image != 'debian' && format('-{0}', matrix.base_image) || '' }}"
|
|
||||||
BASE_TAGS: "${{ env.BASE_TAGS }}"
|
BASE_TAGS: "${{ env.BASE_TAGS }}"
|
||||||
CONTAINER_REGISTRIES: "${{ env.CONTAINER_REGISTRIES }}"
|
CONTAINER_REGISTRIES: "${{ env.CONTAINER_REGISTRIES }}"
|
||||||
run: |
|
run: |
|
||||||
set +e
|
|
||||||
IFS=',' read -ra IMAGES <<< "${CONTAINER_REGISTRIES}"
|
IFS=',' read -ra IMAGES <<< "${CONTAINER_REGISTRIES}"
|
||||||
IFS=',' read -ra TAGS <<< "${BASE_TAGS}"
|
IFS=',' read -ra TAGS <<< "${BASE_TAGS}"
|
||||||
|
|
||||||
|
TAG_ARGS=()
|
||||||
for img in "${IMAGES[@]}"; do
|
for img in "${IMAGES[@]}"; do
|
||||||
for tag in "${TAGS[@]}"; do
|
for tag in "${TAGS[@]}"; do
|
||||||
echo "Creating manifest for ${img}:${tag}${BASE_IMAGE_TAG}"
|
TAG_ARGS+=("-t" "${img}:${tag}")
|
||||||
|
|
||||||
OUTPUT=$(docker buildx imagetools create \
|
|
||||||
-t "${img}:${tag}${BASE_IMAGE_TAG}" \
|
|
||||||
$(printf "${img}@sha256:%s " *) 2>&1)
|
|
||||||
STATUS=$?
|
|
||||||
|
|
||||||
if [ ${STATUS} -ne 0 ]; then
|
|
||||||
echo "Manifest creation failed for ${img}:${tag}${BASE_IMAGE_TAG}"
|
|
||||||
echo "${OUTPUT}"
|
|
||||||
exit ${STATUS}
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Manifest created for ${img}:${tag}${BASE_IMAGE_TAG}"
|
|
||||||
echo "${OUTPUT}"
|
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
set -e
|
|
||||||
|
echo "Creating manifest"
|
||||||
|
if ! OUTPUT=$(docker buildx imagetools create \
|
||||||
|
"${TAG_ARGS[@]}" \
|
||||||
|
$(printf "${IMAGES[0]}@sha256:%s " *) 2>&1); then
|
||||||
|
echo "Manifest creation failed"
|
||||||
|
echo "${OUTPUT}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Manifest created successfully"
|
||||||
|
echo "${OUTPUT}"
|
||||||
|
|
||||||
# Extract digest SHA for subsequent steps
|
# Extract digest SHA for subsequent steps
|
||||||
GET_DIGEST_SHA="$(echo "${OUTPUT}" | grep -oE 'sha256:[a-f0-9]{64}' | tail -1)"
|
GET_DIGEST_SHA="$(echo "${OUTPUT}" | grep -oE 'sha256:[a-f0-9]{64}' | tail -1)"
|
||||||
|
|||||||
2
.github/workflows/typos.yml
vendored
2
.github/workflows/typos.yml
vendored
@@ -19,4 +19,4 @@ jobs:
|
|||||||
|
|
||||||
# When this version is updated, do not forget to update this in `.pre-commit-config.yaml` too
|
# When this version is updated, do not forget to update this in `.pre-commit-config.yaml` too
|
||||||
- name: Spell Check Repo
|
- name: Spell Check Repo
|
||||||
uses: crate-ci/typos@2d0ce569feab1f8752f1dde43cc2f2aa53236e06 # v1.40.0
|
uses: crate-ci/typos@1a319b54cc9e3b333fed6a5c88ba1a90324da514 # v1.40.1
|
||||||
|
|||||||
@@ -53,6 +53,6 @@ repos:
|
|||||||
- "cd docker && make"
|
- "cd docker && make"
|
||||||
# When this version is updated, do not forget to update this in `.github/workflows/typos.yaml` too
|
# When this version is updated, do not forget to update this in `.github/workflows/typos.yaml` too
|
||||||
- repo: https://github.com/crate-ci/typos
|
- repo: https://github.com/crate-ci/typos
|
||||||
rev: 2d0ce569feab1f8752f1dde43cc2f2aa53236e06 # v1.40.0
|
rev: 1a319b54cc9e3b333fed6a5c88ba1a90324da514 # v1.40.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: typos
|
- id: typos
|
||||||
|
|||||||
26
Cargo.lock
generated
26
Cargo.lock
generated
@@ -718,9 +718,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bigdecimal"
|
name = "bigdecimal"
|
||||||
version = "0.4.9"
|
version = "0.4.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "560f42649de9fa436b73517378a147ec21f6c997a546581df4b4b31677828934"
|
checksum = "4d6867f1565b3aad85681f1015055b087fcfd840d6aeee6eee7f2da317603695"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"libm",
|
"libm",
|
||||||
@@ -2660,9 +2660,9 @@ checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iri-string"
|
name = "iri-string"
|
||||||
version = "0.7.9"
|
version = "0.7.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4f867b9d1d896b67beb18518eda36fdb77a32ea590de864f1325b294a6d14397"
|
checksum = "c91338f0783edbd6195decb37bae672fd3b165faffb89bf7b9e6942f8b1a731a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -3126,7 +3126,7 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"openssl",
|
"openssl",
|
||||||
"openssl-probe",
|
"openssl-probe 0.1.6",
|
||||||
"openssl-sys",
|
"openssl-sys",
|
||||||
"schannel",
|
"schannel",
|
||||||
"security-framework 2.11.1",
|
"security-framework 2.11.1",
|
||||||
@@ -3415,6 +3415,12 @@ version = "0.1.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e"
|
checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "openssl-probe"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9f50d9b3dabb09ecd771ad0aa242ca6894994c130308ca3d7684634df8037391"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl-src"
|
name = "openssl-src"
|
||||||
version = "300.5.4+3.5.4"
|
version = "300.5.4+3.5.4"
|
||||||
@@ -4520,11 +4526,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls-native-certs"
|
name = "rustls-native-certs"
|
||||||
version = "0.8.2"
|
version = "0.8.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9980d917ebb0c0536119ba501e90834767bffc3d60641457fd84a1f3fd337923"
|
checksum = "612460d5f7bea540c490b2b6395d8e34a953e52b491accd6c86c8164c5932a63"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"openssl-probe",
|
"openssl-probe 0.2.0",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
"schannel",
|
"schannel",
|
||||||
"security-framework 3.5.1",
|
"security-framework 3.5.1",
|
||||||
@@ -6624,9 +6630,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zmij"
|
name = "zmij"
|
||||||
version = "1.0.0"
|
version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e6d6085d62852e35540689d1f97ad663e3971fc19cf5eceab364d62c646ea167"
|
checksum = "0f4a4e8e9dc5c62d159f04fcdbe07f4c3fb710415aab4754bf11505501e3251d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zstd"
|
name = "zstd"
|
||||||
|
|||||||
@@ -65,14 +65,14 @@ dotenvy = { version = "0.15.7", default-features = false }
|
|||||||
# Numerical libraries
|
# Numerical libraries
|
||||||
num-traits = "0.2.19"
|
num-traits = "0.2.19"
|
||||||
num-derive = "0.4.2"
|
num-derive = "0.4.2"
|
||||||
bigdecimal = "0.4.9"
|
bigdecimal = "0.4.10"
|
||||||
|
|
||||||
# Web framework
|
# Web framework
|
||||||
rocket = { version = "0.5.1", features = ["tls", "json"], default-features = false }
|
rocket = { version = "0.5.1", features = ["tls", "json"], default-features = false }
|
||||||
rocket_ws = { version ="0.1.1" }
|
rocket_ws = { version ="0.1.1" }
|
||||||
|
|
||||||
# WebSockets libraries
|
# WebSockets libraries
|
||||||
rmpv = "1.3.0" # MessagePack library
|
rmpv = "1.3.1" # MessagePack library
|
||||||
|
|
||||||
# Concurrent HashMap used for WebSocket messaging and favicons
|
# Concurrent HashMap used for WebSocket messaging and favicons
|
||||||
dashmap = "6.1.0"
|
dashmap = "6.1.0"
|
||||||
@@ -84,7 +84,7 @@ tokio-util = { version = "0.7.17", features = ["compat"]}
|
|||||||
|
|
||||||
# A generic serialization/deserialization framework
|
# A generic serialization/deserialization framework
|
||||||
serde = { version = "1.0.228", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
serde_json = "1.0.145"
|
serde_json = "1.0.148"
|
||||||
|
|
||||||
# A safe, extensible ORM and Query builder
|
# A safe, extensible ORM and Query builder
|
||||||
# Currently pinned diesel to v2.3.3 as newer version break MySQL/MariaDB compatibility
|
# Currently pinned diesel to v2.3.3 as newer version break MySQL/MariaDB compatibility
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
vault_version: "v2025.12.0"
|
vault_version: "v2025.12.1"
|
||||||
vault_image_digest: "sha256:bb7303efafdb7e2b41bee2c772e14f67676ae2c9047bd7bba80d3544d4162613"
|
vault_image_digest: "sha256:dc718ffec13eccab8a849d65dd436b38730577b9b46be4672d97debc88e2c0ad"
|
||||||
# Cross Compile Docker Helper Scripts v1.9.0
|
# 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
|
# 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
|
# https://github.com/tonistiigi/xx | https://hub.docker.com/r/tonistiigi/xx/tags
|
||||||
|
|||||||
@@ -19,15 +19,15 @@
|
|||||||
# - From https://hub.docker.com/r/vaultwarden/web-vault/tags,
|
# - 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.
|
# click the tag name to view the digest of the image it currently points to.
|
||||||
# - From the command line:
|
# - From the command line:
|
||||||
# $ docker pull docker.io/vaultwarden/web-vault:v2025.12.0
|
# $ docker pull docker.io/vaultwarden/web-vault:v2025.12.1
|
||||||
# $ docker image inspect --format "{{.RepoDigests}}" docker.io/vaultwarden/web-vault:v2025.12.0
|
# $ docker image inspect --format "{{.RepoDigests}}" docker.io/vaultwarden/web-vault:v2025.12.1
|
||||||
# [docker.io/vaultwarden/web-vault@sha256:bb7303efafdb7e2b41bee2c772e14f67676ae2c9047bd7bba80d3544d4162613]
|
# [docker.io/vaultwarden/web-vault@sha256:dc718ffec13eccab8a849d65dd436b38730577b9b46be4672d97debc88e2c0ad]
|
||||||
#
|
#
|
||||||
# - Conversely, to get the tag name from the digest:
|
# - Conversely, to get the tag name from the digest:
|
||||||
# $ docker image inspect --format "{{.RepoTags}}" docker.io/vaultwarden/web-vault@sha256:bb7303efafdb7e2b41bee2c772e14f67676ae2c9047bd7bba80d3544d4162613
|
# $ docker image inspect --format "{{.RepoTags}}" docker.io/vaultwarden/web-vault@sha256:dc718ffec13eccab8a849d65dd436b38730577b9b46be4672d97debc88e2c0ad
|
||||||
# [docker.io/vaultwarden/web-vault:v2025.12.0]
|
# [docker.io/vaultwarden/web-vault:v2025.12.1]
|
||||||
#
|
#
|
||||||
FROM --platform=linux/amd64 docker.io/vaultwarden/web-vault@sha256:bb7303efafdb7e2b41bee2c772e14f67676ae2c9047bd7bba80d3544d4162613 AS vault
|
FROM --platform=linux/amd64 docker.io/vaultwarden/web-vault@sha256:dc718ffec13eccab8a849d65dd436b38730577b9b46be4672d97debc88e2c0ad AS vault
|
||||||
|
|
||||||
########################## ALPINE BUILD IMAGES ##########################
|
########################## ALPINE BUILD IMAGES ##########################
|
||||||
## NOTE: The Alpine Base Images do not support other platforms then linux/amd64 and linux/arm64
|
## NOTE: The Alpine Base Images do not support other platforms then linux/amd64 and linux/arm64
|
||||||
|
|||||||
@@ -19,15 +19,15 @@
|
|||||||
# - From https://hub.docker.com/r/vaultwarden/web-vault/tags,
|
# - 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.
|
# click the tag name to view the digest of the image it currently points to.
|
||||||
# - From the command line:
|
# - From the command line:
|
||||||
# $ docker pull docker.io/vaultwarden/web-vault:v2025.12.0
|
# $ docker pull docker.io/vaultwarden/web-vault:v2025.12.1
|
||||||
# $ docker image inspect --format "{{.RepoDigests}}" docker.io/vaultwarden/web-vault:v2025.12.0
|
# $ docker image inspect --format "{{.RepoDigests}}" docker.io/vaultwarden/web-vault:v2025.12.1
|
||||||
# [docker.io/vaultwarden/web-vault@sha256:bb7303efafdb7e2b41bee2c772e14f67676ae2c9047bd7bba80d3544d4162613]
|
# [docker.io/vaultwarden/web-vault@sha256:dc718ffec13eccab8a849d65dd436b38730577b9b46be4672d97debc88e2c0ad]
|
||||||
#
|
#
|
||||||
# - Conversely, to get the tag name from the digest:
|
# - Conversely, to get the tag name from the digest:
|
||||||
# $ docker image inspect --format "{{.RepoTags}}" docker.io/vaultwarden/web-vault@sha256:bb7303efafdb7e2b41bee2c772e14f67676ae2c9047bd7bba80d3544d4162613
|
# $ docker image inspect --format "{{.RepoTags}}" docker.io/vaultwarden/web-vault@sha256:dc718ffec13eccab8a849d65dd436b38730577b9b46be4672d97debc88e2c0ad
|
||||||
# [docker.io/vaultwarden/web-vault:v2025.12.0]
|
# [docker.io/vaultwarden/web-vault:v2025.12.1]
|
||||||
#
|
#
|
||||||
FROM --platform=linux/amd64 docker.io/vaultwarden/web-vault@sha256:bb7303efafdb7e2b41bee2c772e14f67676ae2c9047bd7bba80d3544d4162613 AS vault
|
FROM --platform=linux/amd64 docker.io/vaultwarden/web-vault@sha256:dc718ffec13eccab8a849d65dd436b38730577b9b46be4672d97debc88e2c0ad AS vault
|
||||||
|
|
||||||
########################## Cross Compile Docker Helper Scripts ##########################
|
########################## Cross Compile Docker Helper Scripts ##########################
|
||||||
## We use the linux/amd64 no matter which Build Platform, since these are all bash scripts
|
## We use the linux/amd64 no matter which Build Platform, since these are all bash scripts
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ use serde_json::Value;
|
|||||||
use crate::{
|
use crate::{
|
||||||
api::{core::now, ApiResult, EmptyResult},
|
api::{core::now, ApiResult, EmptyResult},
|
||||||
auth::decode_file_download,
|
auth::decode_file_download,
|
||||||
config::CachedConfigOperation,
|
|
||||||
db::models::{AttachmentId, CipherId},
|
db::models::{AttachmentId, CipherId},
|
||||||
error::Error,
|
error::Error,
|
||||||
util::Cached,
|
util::Cached,
|
||||||
@@ -53,18 +52,19 @@ fn not_found() -> ApiResult<Html<String>> {
|
|||||||
Ok(Html(text))
|
Ok(Html(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
static VAULTWARDEN_CSS_CACHE: CachedConfigOperation<String> = CachedConfigOperation::new(|config| {
|
#[get("/css/vaultwarden.css")]
|
||||||
|
fn vaultwarden_css() -> Cached<Css<String>> {
|
||||||
let css_options = json!({
|
let css_options = json!({
|
||||||
"emergency_access_allowed": config.emergency_access_allowed(),
|
"emergency_access_allowed": CONFIG.emergency_access_allowed(),
|
||||||
"load_user_scss": true,
|
"load_user_scss": true,
|
||||||
"mail_2fa_enabled": config._enable_email_2fa(),
|
"mail_2fa_enabled": CONFIG._enable_email_2fa(),
|
||||||
"mail_enabled": config.mail_enabled(),
|
"mail_enabled": CONFIG.mail_enabled(),
|
||||||
"sends_allowed": config.sends_allowed(),
|
"sends_allowed": CONFIG.sends_allowed(),
|
||||||
"signup_disabled": config.is_signup_disabled(),
|
"signup_disabled": CONFIG.is_signup_disabled(),
|
||||||
"sso_enabled": config.sso_enabled(),
|
"sso_enabled": CONFIG.sso_enabled(),
|
||||||
"sso_only": config.sso_enabled() && config.sso_only(),
|
"sso_only": CONFIG.sso_enabled() && CONFIG.sso_only(),
|
||||||
"yubico_enabled": config._enable_yubico() && config.yubico_client_id().is_some() && config.yubico_secret_key().is_some(),
|
"yubico_enabled": CONFIG._enable_yubico() && CONFIG.yubico_client_id().is_some() && CONFIG.yubico_secret_key().is_some(),
|
||||||
"webauthn_2fa_supported": config.is_webauthn_2fa_supported(),
|
"webauthn_2fa_supported": CONFIG.is_webauthn_2fa_supported(),
|
||||||
});
|
});
|
||||||
|
|
||||||
let scss = match CONFIG.render_template("scss/vaultwarden.scss", &css_options) {
|
let scss = match CONFIG.render_template("scss/vaultwarden.scss", &css_options) {
|
||||||
@@ -78,7 +78,7 @@ static VAULTWARDEN_CSS_CACHE: CachedConfigOperation<String> = CachedConfigOperat
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
match grass_compiler::from_string(
|
let css = match grass_compiler::from_string(
|
||||||
scss,
|
scss,
|
||||||
&grass_compiler::Options::default().style(grass_compiler::OutputStyle::Compressed),
|
&grass_compiler::Options::default().style(grass_compiler::OutputStyle::Compressed),
|
||||||
) {
|
) {
|
||||||
@@ -97,12 +97,10 @@ static VAULTWARDEN_CSS_CACHE: CachedConfigOperation<String> = CachedConfigOperat
|
|||||||
)
|
)
|
||||||
.expect("SCSS to compile")
|
.expect("SCSS to compile")
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
});
|
|
||||||
|
|
||||||
#[get("/css/vaultwarden.css")]
|
// Cache for one day should be enough and not too much
|
||||||
fn vaultwarden_css() -> Css<String> {
|
Cached::ttl(Css(css), 86_400, false)
|
||||||
Css(CONFIG.cached_operation(&VAULTWARDEN_CSS_CACHE))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
|
|||||||
16
src/auth.rs
16
src/auth.rs
@@ -1210,8 +1210,20 @@ pub async fn refresh_tokens(
|
|||||||
) -> ApiResult<(Device, AuthTokens)> {
|
) -> ApiResult<(Device, AuthTokens)> {
|
||||||
let refresh_claims = match decode_refresh(refresh_token) {
|
let refresh_claims = match decode_refresh(refresh_token) {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
debug!("Failed to decode {} refresh_token: {refresh_token}", ip.ip);
|
error!("Failed to decode {} refresh_token: {refresh_token}: {err:?}", ip.ip);
|
||||||
err_silent!(format!("Impossible to read refresh_token: {}", err.message()))
|
//err_silent!(format!("Impossible to read refresh_token: {}", err.message()))
|
||||||
|
|
||||||
|
// If the token failed to decode, it was probably one of the old style tokens that was just a Base64 string.
|
||||||
|
// We can generate a claim for them for backwards compatibility. Note that the password refresh claims don't
|
||||||
|
// check expiration or issuer, so they're not included here.
|
||||||
|
RefreshJwtClaims {
|
||||||
|
nbf: 0,
|
||||||
|
exp: 0,
|
||||||
|
iss: String::new(),
|
||||||
|
sub: AuthMethod::Password,
|
||||||
|
device_token: refresh_token.into(),
|
||||||
|
token: None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(claims) => claims,
|
Ok(claims) => claims,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::{
|
|||||||
fmt,
|
fmt,
|
||||||
process::exit,
|
process::exit,
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicBool, AtomicUsize, Ordering},
|
atomic::{AtomicBool, Ordering},
|
||||||
LazyLock, RwLock,
|
LazyLock, RwLock,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -103,7 +103,6 @@ macro_rules! make_config {
|
|||||||
|
|
||||||
struct Inner {
|
struct Inner {
|
||||||
rocket_shutdown_handle: Option<rocket::Shutdown>,
|
rocket_shutdown_handle: Option<rocket::Shutdown>,
|
||||||
revision: usize,
|
|
||||||
|
|
||||||
templates: Handlebars<'static>,
|
templates: Handlebars<'static>,
|
||||||
config: ConfigItems,
|
config: ConfigItems,
|
||||||
@@ -323,7 +322,7 @@ macro_rules! make_config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
struct ConfigItems { $($( pub $name: make_config! {@type $ty, $none_action}, )+)+ }
|
struct ConfigItems { $($( $name: make_config! {@type $ty, $none_action}, )+)+ }
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct ElementDoc {
|
struct ElementDoc {
|
||||||
@@ -1468,23 +1467,6 @@ pub enum PathType {
|
|||||||
RsaKey,
|
RsaKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CachedConfigOperation<T: Clone> {
|
|
||||||
generator: fn(&Config) -> T,
|
|
||||||
value_cache: RwLock<Option<T>>,
|
|
||||||
revision: AtomicUsize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Clone> CachedConfigOperation<T> {
|
|
||||||
#[allow(private_interfaces)]
|
|
||||||
pub const fn new(generator: fn(&Config) -> T) -> Self {
|
|
||||||
CachedConfigOperation {
|
|
||||||
generator,
|
|
||||||
value_cache: RwLock::new(None),
|
|
||||||
revision: AtomicUsize::new(0),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
pub async fn load() -> Result<Self, Error> {
|
pub async fn load() -> Result<Self, Error> {
|
||||||
// Loading from env and file
|
// Loading from env and file
|
||||||
@@ -1504,7 +1486,6 @@ impl Config {
|
|||||||
Ok(Config {
|
Ok(Config {
|
||||||
inner: RwLock::new(Inner {
|
inner: RwLock::new(Inner {
|
||||||
rocket_shutdown_handle: None,
|
rocket_shutdown_handle: None,
|
||||||
revision: 1,
|
|
||||||
templates: load_templates(&config.templates_folder),
|
templates: load_templates(&config.templates_folder),
|
||||||
config,
|
config,
|
||||||
_env,
|
_env,
|
||||||
@@ -1543,7 +1524,6 @@ impl Config {
|
|||||||
writer.config = config;
|
writer.config = config;
|
||||||
writer._usr = builder;
|
writer._usr = builder;
|
||||||
writer._overrides = overrides;
|
writer._overrides = overrides;
|
||||||
writer.revision += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Save to file
|
//Save to file
|
||||||
@@ -1562,51 +1542,6 @@ impl Config {
|
|||||||
self.update_config(builder, false).await
|
self.update_config(builder, false).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_user_config(&self) -> Result<(), Error> {
|
|
||||||
let operator = opendal_operator_for_path(&CONFIG_FILE_PARENT_DIR)?;
|
|
||||||
operator.delete(&CONFIG_FILENAME).await?;
|
|
||||||
|
|
||||||
// Empty user config
|
|
||||||
let usr = ConfigBuilder::default();
|
|
||||||
|
|
||||||
// Config now is env + defaults
|
|
||||||
let config = {
|
|
||||||
let env = &self.inner.read().unwrap()._env;
|
|
||||||
env.build()
|
|
||||||
};
|
|
||||||
|
|
||||||
// Save configs
|
|
||||||
{
|
|
||||||
let mut writer = self.inner.write().unwrap();
|
|
||||||
writer.config = config;
|
|
||||||
writer._usr = usr;
|
|
||||||
writer._overrides = Vec::new();
|
|
||||||
writer.revision += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn cached_operation<T: Clone>(&self, operation: &CachedConfigOperation<T>) -> T {
|
|
||||||
let config_revision = self.inner.read().unwrap().revision;
|
|
||||||
let cache_revision = operation.revision.load(Ordering::Relaxed);
|
|
||||||
|
|
||||||
// If the current revision matches the cached revision, return the cached value
|
|
||||||
if cache_revision == config_revision {
|
|
||||||
let reader = operation.value_cache.read().unwrap();
|
|
||||||
return reader.as_ref().unwrap().clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, compute the value, update the cache and revision, and return the new value
|
|
||||||
let value = (operation.generator)(&CONFIG);
|
|
||||||
{
|
|
||||||
let mut writer = operation.value_cache.write().unwrap();
|
|
||||||
*writer = Some(value.clone());
|
|
||||||
operation.revision.store(config_revision, Ordering::Relaxed);
|
|
||||||
}
|
|
||||||
value
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Tests whether an email's domain is allowed. A domain is allowed if it
|
/// Tests whether an email's domain is allowed. A domain is allowed if it
|
||||||
/// is in signups_domains_whitelist, or if no whitelist is set (so there
|
/// is in signups_domains_whitelist, or if no whitelist is set (so there
|
||||||
/// are no domain restrictions in effect).
|
/// are no domain restrictions in effect).
|
||||||
@@ -1656,10 +1591,33 @@ impl Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn delete_user_config(&self) -> Result<(), Error> {
|
||||||
|
let operator = opendal_operator_for_path(&CONFIG_FILE_PARENT_DIR)?;
|
||||||
|
operator.delete(&CONFIG_FILENAME).await?;
|
||||||
|
|
||||||
|
// Empty user config
|
||||||
|
let usr = ConfigBuilder::default();
|
||||||
|
|
||||||
|
// Config now is env + defaults
|
||||||
|
let config = {
|
||||||
|
let env = &self.inner.read().unwrap()._env;
|
||||||
|
env.build()
|
||||||
|
};
|
||||||
|
|
||||||
|
// Save configs
|
||||||
|
{
|
||||||
|
let mut writer = self.inner.write().unwrap();
|
||||||
|
writer.config = config;
|
||||||
|
writer._usr = usr;
|
||||||
|
writer._overrides = Vec::new();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn private_rsa_key(&self) -> String {
|
pub fn private_rsa_key(&self) -> String {
|
||||||
format!("{}.pem", self.rsa_key_filename())
|
format!("{}.pem", self.rsa_key_filename())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mail_enabled(&self) -> bool {
|
pub fn mail_enabled(&self) -> bool {
|
||||||
let inner = &self.inner.read().unwrap().config;
|
let inner = &self.inner.read().unwrap().config;
|
||||||
inner._enable_smtp && (inner.smtp_host.is_some() || inner.use_sendmail)
|
inner._enable_smtp && (inner.smtp_host.is_some() || inner.use_sendmail)
|
||||||
|
|||||||
Reference in New Issue
Block a user