Skip to content

Commit ade3859

Browse files
pull[bot]BlackDexRychart RedwerkzGeekCornerGHdani-garcia
authored
[pull] main from dani-garcia:main (#64)
* Fix remaning inline format * Use more modern meta tag for charset encoding * fix (2fa.directory): Allow api.2fa.directory, and remove 2fa.directory * Optimize CipherSyncData for very large vaults As mentioned in dani-garcia#3111, using a very very large vault causes some issues. Mainly because of a SQLite limit, but, it could also cause issue on MariaDB/MySQL or PostgreSQL. It also uses a lot of memory, and memory allocations. This PR solves this by removing the need of all the cipher_uuid's just to gather the correct attachments. It will use the user_uuid and org_uuid's to get all attachments linked to both, weither the user has access to them or not. This isn't an issue, since the matching is done per cipher and the attachment data is only returned if there is a matching cipher to where the user has access to. I also modified some code to be able to use `::with_capacity(n)` where possible. This prevents re-allocations if the `Vec` increases size, which will happen a lot if there are a lot of ciphers. According to my tests measuring the time it takes to sync, it seems to have lowered the duration a bit more. Fixes dani-garcia#3111 * Add MFA icon to org member overview The Organization member overview supports showing an icon if the user has MFA enabled or not. This PR adds this feature. This is very useful if you want to enable force mfa for example. * Add avatar color support The new web-vault v2023.1.0 supports a custom color for the avatar. bitwarden/server#2330 This PR adds this feature. * Update Rust to v1.66.1 to patch CVE This PR sets Rust to v1.66.1 to fix a CVE. https://blog.rust-lang.org/2023/01/10/cve-2022-46176.html https://blog.rust-lang.org/2023/01/10/Rust-1.66.1.html Also updated some packages while at it. * Use more modern meta tag for charset encoding * Use more modern meta tag for charset encoding * Fix remaning inline format * Use more modern meta tag for charset encoding * Fix remaning inline format * fix (2fa.directory): Allow api.2fa.directory, and remove 2fa.directory * Use more modern meta tag for charset encoding * Fix remaning inline format * fix (2fa.directory): Allow api.2fa.directory, and remove 2fa.directory * Add MFA icon to org member overview The Organization member overview supports showing an icon if the user has MFA enabled or not. This PR adds this feature. This is very useful if you want to enable force mfa for example. * Use more modern meta tag for charset encoding * Fix remaning inline format * fix (2fa.directory): Allow api.2fa.directory, and remove 2fa.directory * Add MFA icon to org member overview The Organization member overview supports showing an icon if the user has MFA enabled or not. This PR adds this feature. This is very useful if you want to enable force mfa for example. * Update Rust to v1.66.1 to patch CVE This PR sets Rust to v1.66.1 to fix a CVE. https://blog.rust-lang.org/2023/01/10/cve-2022-46176.html https://blog.rust-lang.org/2023/01/10/Rust-1.66.1.html Also updated some packages while at it. * Use more modern meta tag for charset encoding * Fix remaning inline format * fix (2fa.directory): Allow api.2fa.directory, and remove 2fa.directory * Add MFA icon to org member overview The Organization member overview supports showing an icon if the user has MFA enabled or not. This PR adds this feature. This is very useful if you want to enable force mfa for example. * Update Rust to v1.66.1 to patch CVE This PR sets Rust to v1.66.1 to fix a CVE. https://blog.rust-lang.org/2023/01/10/cve-2022-46176.html https://blog.rust-lang.org/2023/01/10/Rust-1.66.1.html Also updated some packages while at it. * Add avatar color support The new web-vault v2023.1.0 supports a custom color for the avatar. bitwarden/server#2330 This PR adds this feature. * Update web vault to 2023.1.0 * include key into user.set_password * include key into user.set_password * Validate note sizes on key-rotation. We also need to validate the note sizes on key-rotation. If we do not validate them before we store them, that could lead to a partial or total loss of the password vault. Validating these restrictions before actually processing them to store/replace the existing ciphers should prevent this. There was also a small bug when using web-sockets. The client which is triggering the password/key-rotation change should not be forced to logout via a web-socket request. That is something the client will handle it self. Refactored the logout notification to either send the device uuid or not on specific actions. Fixes dani-garcia#3152 * include key into user.set_password * Update KDF Configuration and processing - Change default Password Hash KDF Storage from 100_000 to 600_000 iterations - Update Password Hash when the default iteration value is different - Validate password_iterations - Validate client-side KDF to prevent it from being set lower than 100_000 * include key into user.set_password * Validate note sizes on key-rotation. We also need to validate the note sizes on key-rotation. If we do not validate them before we store them, that could lead to a partial or total loss of the password vault. Validating these restrictions before actually processing them to store/replace the existing ciphers should prevent this. There was also a small bug when using web-sockets. The client which is triggering the password/key-rotation change should not be forced to logout via a web-socket request. That is something the client will handle it self. Refactored the logout notification to either send the device uuid or not on specific actions. Fixes dani-garcia#3152 * Updated web vault to 2023.1.1 and rust dependencies * Re-License Vaultwarden to AGPLv3 This commit prepares Vaultwarden for the Re-Licensing to AGPLv3 Solves #2450 * Remove `arm32v6`-specific tag This section of code seems to be breaking the Docker release workflow as of a few days ago, though it's unclear why. This tag only existed to work around an issue with Docker pulling the wrong image for ARMv6 platforms; that issue was resolved in Docker 20.10.0, which has been out for a few years now, so it seems like a reasonable time to drop this tag. * Rename `.buildx` Dockerfiles to `.buildkit` This is a more accurate name, since these Dockerfiles require BuildKit, not Buildx. * Disable Hadolint check for consecutive `RUN` instructions (DL3059) This check doesn't seem to add enough value to justify the difficulties it tends to create when generating `RUN` instructions from a template. * added database migration * working implementation * fixes for current upstream main * "Spell-Jacking" mitigation ~ prevent sensitive data leak from spell checker. @see https://www.otto-js.com/news/article/chrome-and-edge-enhanced-spellcheck-features-expose-pii-even-your-passwords * Fix Javascript issue on non sqlite databases When a non sqlite database is used, loading the admin interface fails because the backup button is not generated. This PR is solves it by checking if the elements are valid. Also made some other changes and fixed some eslint errors. Showing `_post` errors is better now. Update jquery to latest version. Fixes dani-garcia#3166 * Allow listening on privileged ports (below 1024) as non-root This is done by running `setcap cap_net_bind_service=+ep` on the executable in the build stage (doing it in the runtime stage creates an extra copy of the executable that bloats the image). This only works when using the BuildKit-based builder, since the `COPY` instruction doesn't copy capabilities on the legacy builder. * don't nullify key when editing emergency access the client does not send the key on every update of an emergency access contact so the field would be emptied on a change of the wait days or access level. * Replaced wrong mysql column type * improved security, disabling policy usage on email-disabled clients and some refactoring * rust lang specific improvements * completly hide reset password policy on email disabled instances * change description of domain configuration Vaultwarden send won't work if the domain includes a trailing slash. This should be documented, as it may lead to confusion amoung users. * improve wording of domain description * Generate distinct log messages for regex vs. IP blacklisting. When an icon will not be downloaded due to matching a configured blacklist, ensure that the log message indicates the type of blacklist that was matched. * Ensure that all results from check_domain_blacklist_reason are cached. * remove documentation of bug since I'm fixing it * fix trailing slash not being removed from domain * allow editing/unhiding by group Fixes dani-garcia#2989 Signed-off-by: Jan Jansen <[email protected]> * Revert "fix trailing slash not being removed from domain" This reverts commit 679bc7a. * fix trailing slash in configuration builder * remove warn when sanitizing domain * add argon2 kdf fields * Add support for sendmail as a mail transport * check if SENDMAIL_COMMAND is valid using 'which' crate * add EXE_SUFFIX to sendmail executable when not specified * Updated Rust and crates - Updated Rust to v1.67.0 - Updated all crates except for `cookies` and `webauthn` * docs: add build status badge in readme * Fix Organization delete when groups are configured With existing groups configured within an org, deleting that org would fail because of Foreign Key issues. This PR fixes this by making sure the groups get deleted before the org does. Fixes dani-garcia#3247 * Fix Collection Read Only access for groups I messed up with identation sorry it's my first PR Fix Collection Read Only access for groups Fix Collection Read Only access for groups With indentation modification * Validate all needed fields for client API login During the client API login we need to have a `device_identifier`, `device_name` and `device_type`. When these were not provided Vaultwarden would panic. This PR add checks for these fields and makes sure it returns a better error message instead of causing a panic. * Make the admin cookie lifetime adjustable * Add function to fetch user by email address * Apply Admin Session Lifetime to JWT * Apply rewording * docs: add build status badge in readme * docs: add build status badge in readme * Validate all needed fields for client API login During the client API login we need to have a `device_identifier`, `device_name` and `device_type`. When these were not provided Vaultwarden would panic. This PR add checks for these fields and makes sure it returns a better error message instead of causing a panic. * docs: add build status badge in readme * Validate all needed fields for client API login During the client API login we need to have a `device_identifier`, `device_name` and `device_type`. When these were not provided Vaultwarden would panic. This PR add checks for these fields and makes sure it returns a better error message instead of causing a panic. * Fix Organization delete when groups are configured With existing groups configured within an org, deleting that org would fail because of Foreign Key issues. This PR fixes this by making sure the groups get deleted before the org does. Fixes dani-garcia#3247 * docs: add build status badge in readme * Validate all needed fields for client API login During the client API login we need to have a `device_identifier`, `device_name` and `device_type`. When these were not provided Vaultwarden would panic. This PR add checks for these fields and makes sure it returns a better error message instead of causing a panic. * Fix Organization delete when groups are configured With existing groups configured within an org, deleting that org would fail because of Foreign Key issues. This PR fixes this by making sure the groups get deleted before the org does. Fixes dani-garcia#3247 * Fix Collection Read Only access for groups I messed up with identation sorry it's my first PR Fix Collection Read Only access for groups Fix Collection Read Only access for groups With indentation modification * docs: add build status badge in readme * Validate all needed fields for client API login During the client API login we need to have a `device_identifier`, `device_name` and `device_type`. When these were not provided Vaultwarden would panic. This PR add checks for these fields and makes sure it returns a better error message instead of causing a panic. * Fix Organization delete when groups are configured With existing groups configured within an org, deleting that org would fail because of Foreign Key issues. This PR fixes this by making sure the groups get deleted before the org does. Fixes dani-garcia#3247 * Fix Collection Read Only access for groups I messed up with identation sorry it's my first PR Fix Collection Read Only access for groups Fix Collection Read Only access for groups With indentation modification * Make the admin cookie lifetime adjustable * Apply Admin Session Lifetime to JWT * Apply rewording * Add missing collections/details endpoint, based on the existing one * Update web vault to v2023.2.0 and dependencies * Fix vault item display in org vault view In the org vault view, the Bitwarden web vault currently tries to fetch the groups for an org regardless of whether it claims to have group support. If this errors out, no vault items are displayed. * Add confirmation for removing 2FA and deauth sessions in admin panel * Fix the web-vault v2023.2.0 API calls - Supports the new Collection/Group/User editing UI's - Support `/partial` endpoint for cipher updating to allow folder and favorite update for read-only ciphers. - Prevent `Favorite`, `Folder`, `read-only` and `hide-passwords` from being added to the organizational sync. - Added and corrected some `Object` key's to the output json. Fixes dani-garcia#3279 * Some Admin Interface updates - Updated datatables - Added NTP Time check - Added Collections, Groups and Events count for orgs - Renamed `Items` to `Ciphers` - Some small style updates * Fix confirmation for removing 2FA and deauthing sessions in admin panel * Admin token Argon2 hashing support Added support for Argon2 hashing support for the `ADMIN_TOKEN` instead of only supporting a plain text string. The hash must be a PHC string which can be generated via the `argon2` CLI **or** via the also built-in hash command in Vaultwarden. You can simply run `vaultwarden hash` to generate a hash based upon a password the user provides them self. Added a warning during startup and within the admin settings panel is the `ADMIN_TOKEN` is not an Argon2 hash. Within the admin environment a user can ignore that warning and it will not be shown for at least 30 days. After that the warning will appear again unless the `ADMIN_TOKEN` has be converted to an Argon2 hash. I have also tested this on my RaspberryPi 2b and there the `Bitwarden` preset takes almost 4.5 seconds to generate/verify the Argon2 hash. Using the `OWASP` preset it is below 1 second, which I think should be fine for low-graded hardware. If it is needed people could use lower memory settings, but in those cases I even doubt Vaultwarden it self would run. They can always use the `argon2` CLI and generate a faster hash. * Add HEAD routes to avoid spurious error messages Rocket automatically implements a HEAD route when there's a matching GET route, but relying on this behavior also means a spurious error gets logged due to <rwf2/Rocket#1098>. Add explicit HEAD routes for `/` and `/alive` to prevent uptime monitoring services from generating error messages like `No matching routes for HEAD /`. With these new routes, `HEAD /` only checks that the server can respond over the network, while `HEAD /alive` also checks that the database connection is alive, similar to `GET /alive`. * Fix web-vault Member UI show/edit/save There was a small bug left in regards to the web-vault v2023.2.0 fixes. This PR fixes the left items. I think all should be addressed now. When editing a User, you were not able to see or edit groups, or see wich collections a user bellonged to. Fixes dani-garcia#3311 * Upd Crates, Rust, MSRV, GHA and remove Backtrace - Changed MSRV to v1.65. Discussed this with @dani-garcia, and we will support **N-2**. This is/will be the same as for the `time` crate we use. Also updated the wiki regarding this https://github.com/dani-garcia/vaultwarden/wiki/Building-binary - Removed backtrace crate in favor of `std::backtrace` stable since v1.65 - Updated Rust to v1.67.1 - Updated all the crates - Updated the GHA action versions - Adjusted the GHA MSRV build to extract the MSRV from `Cargo.toml` * Merge ClientIp with Headers. Since we now use the `ClientIp` Guard on a lot more places, it also increases the size of binary, and the macro generated code because of this extra Guard. By merging the `ClientIp` Guard with the several `Header` guards we have it reduces the amount of code generated (including LLVM IR), but also a small speedup in build time. I also spotted some small `json!()` optimizations which also reduced the amount of code generated. * Add support for `/api/devices/knowndevice` with HTTP header params Upstream PR: bitwarden/server#2682 * Update Rust, MSRV and Crates - Updated all the crates - Updated Rust and MSRV * Update web vault to v2023.3.0 and dependencies * add endpoint to bulk delete groups * add endpoint to bulk delete collections * don't use `assert()` in production code Co-authored-by: Daniel García <[email protected]> * Add support for Quay.io and GHCR.io as registries - Added support for Quay.io - Added support for GHCR.io To enable support for these container image registries the following needs to be added. As `Actions secrets and variables` - `Secrets` - `DOCKERHUB_TOKEN` and `DOCKERHUB_USERNAME` - `QUAY_TOKEN` and `QUAY_USERNAME` As `Actions secrets and variables` - `Variables` - `Repository Variables` - `DOCKERHUB_REPO` - `GHCR_REPO` - `QUAY_REPO` The `DOCKERHUB_REPO` currently configured in `Secrets` can be removed if wanted, probably best after this PR has been merged. If one of the vars/secrets are not configured it will skip that specific registry! * Some small fixes and updates - Updated workflows to use new checkout version This probably fixes the curl download for hadolint also. - Updated crates including Rocket to the latest rc3 :party: - Applied 2 nightly clippy lints to prevent future clippy issues. * Update web vault to v2023.3.0b * Decode knowndevice `X-Request-Email` as base64url with no padding The clients end up removing the padding characters [1][2]. [1] https://github.com/bitwarden/clients/blob/web-v2023.3.0/libs/common/src/misc/utils.ts#L141-L143 [2] https://github.com/bitwarden/mobile/blob/v2023.3.1/src/Core/Utilities/CoreHelpers.cs#L227-L234 * Fix password reset issues There was used a wrong macro to produce an error message when mailing the user his password was reset failed. It was using `error!()` which does not return an `Err` and aborts the rest of the code. This resulted in the users password still being resetted, but not being notified. This PR fixes this by using `err!()`. Also, do not set the user object as mutable until it really is needed. Second, when a user was using the new Argon2id KDF with custom values like memory and parallelism, that would have rendered the password incorrect. The endpoint which should return all the data did not returned all the new Argon2id values. Fixes dani-garcia#3388 Co-authored-by: Stefan Melmuk <[email protected]> * support `/users/<uuid>/invite/resend` admin api * fmt * always return KdfMemory and KdfParallelism the client will ignore the value of theses fields in case of `PBKDF2` (whether they are unset or left from trying out `Argon2id` as KDF). with `Argon2id` those fields should never be `null` but always in a valid state. if they are `null` (how would that even happen?) the client still assumes default values for `Argon2id` (i.e. m=64 and p=4) and if they are set to something else login will fail anyway. * clear kdf memory and parallelism with pbkdf2 when changing back from argon2id to PBKDF2 the unused parameters should be set to 0. also fix small bug in _register * add mail check * add check user state * Revert setcap, update rust and crates - Revert dani-garcia#3170 as discussed in #3387 In hindsight it's better to not have this feature - Update Dockerfile.j2 for easy version changes. Just change it in one place instead of multiple - Updated to Rust to latest patched version - Updated crates to latest available - Pinned mimalloc to an older version, as it breaks on musl builds * Fix sending out multiple websocket notifications For some reason I encountered a strange bug which resulted in sending out multiple websocket notifications for the exact same user. Added a `distinct()` for the query to filter out multiple uuid's. --------- Signed-off-by: Jan Jansen <[email protected]> Co-authored-by: BlackDex <[email protected]> Co-authored-by: Rychart Redwerkz <[email protected]> Co-authored-by: GeekCorner <[email protected]> Co-authored-by: Daniel García <[email protected]> Co-authored-by: sirux88 <[email protected]> Co-authored-by: Jeremy Lin <[email protected]> Co-authored-by: Daniel Hammer <[email protected]> Co-authored-by: Stefan Melmuk <[email protected]> Co-authored-by: BlockListed <[email protected]> Co-authored-by: Kevin P. Fleming <[email protected]> Co-authored-by: Jan Jansen <[email protected]> Co-authored-by: Helmut K. C. Tessarek <[email protected]> Co-authored-by: soruh <[email protected]> Co-authored-by: r3drun3 <[email protected]> Co-authored-by: Misterbabou <[email protected]> Co-authored-by: Nils Mittler <[email protected]> Co-authored-by: Jeremy Lin <[email protected]> Co-authored-by: Jonathan Elias Caicedo <[email protected]> Co-authored-by: Dylan Pinsonneault <[email protected]> Co-authored-by: Stefan Melmuk <[email protected]> Co-authored-by: Nikolay Nikolaev <[email protected]>
1 parent 367e1ce commit ade3859

File tree

103 files changed

+3647
-2037
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+3647
-2037
lines changed

.env.template

+18-6
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,13 @@
259259
## A comma-separated list means only those users can create orgs:
260260
261261

262-
## Token for the admin interface, preferably use a long random string
263-
## One option is to use 'openssl rand -base64 48'
262+
## Token for the admin interface, preferably an Argon2 PCH string
263+
## Vaultwarden has a built-in generator by calling `vaultwarden hash`
264+
## For details see: https://github.com/dani-garcia/vaultwarden/wiki/Enabling-admin-page#secure-the-admin_token
264265
## If not set, the admin panel is disabled
266+
## New Argon2 PHC string
267+
# ADMIN_TOKEN='$argon2id$v=19$m=65540,t=3,p=4$MmeKRnGK5RW5mJS7h3TOL89GrpLPXJPAtTK8FTqj9HM$DqsstvoSAETl9YhnsXbf43WeaUwJC6JhViIvuPoig78'
268+
## Old plain text string (Will generate warnings in favor of Argon2)
265269
# ADMIN_TOKEN=Vy2VyYTTsKPv8W5aEOWUbB/Bt3DEKePbHmI4m9VcemUMS2rEviDowNAFqYi1xjmp
266270

267271
## Enable this to bypass the admin panel security. This option is only
@@ -298,9 +302,9 @@
298302
## This setting applies globally to all users.
299303
# INCOMPLETE_2FA_TIME_LIMIT=3
300304

301-
## Controls the PBBKDF password iterations to apply on the server
302-
## The change only applies when the password is changed
303-
# PASSWORD_ITERATIONS=100000
305+
## Number of server-side passwords hashing iterations for the password hash.
306+
## The default for new users. If changed, it will be updated during login for existing users.
307+
# PASSWORD_ITERATIONS=350000
304308

305309
## Controls whether users can set password hints. This setting applies globally to all users.
306310
# PASSWORD_HINTS_ALLOWED=true
@@ -335,6 +339,9 @@
335339
## Allow a burst of requests of up to this size, while maintaining the average indicated by `ADMIN_RATELIMIT_SECONDS`.
336340
# ADMIN_RATELIMIT_MAX_BURST=3
337341

342+
## Set the lifetime of admin sessions to this value (in minutes).
343+
# ADMIN_SESSION_LIFETIME=20
344+
338345
## Yubico (Yubikey) Settings
339346
## Set your Client ID and Secret Key for Yubikey OTP
340347
## You can generate it here: https://upgrade.yubico.com/getapikey/
@@ -373,7 +380,7 @@
373380
# ROCKET_WORKERS=10
374381
# ROCKET_TLS={certs="/path/to/certs.pem",key="/path/to/key.pem"}
375382

376-
## Mail specific settings, set SMTP_HOST and SMTP_FROM to enable the mail service.
383+
## Mail specific settings, set SMTP_FROM and either SMTP_HOST or USE_SENDMAIL to enable the mail service.
377384
## To make sure the email links are pointing to the correct host, set the DOMAIN variable.
378385
## Note: if SMTP_USERNAME is specified, SMTP_PASSWORD is mandatory
379386
# SMTP_HOST=smtp.domain.tld
@@ -385,6 +392,11 @@
385392
# SMTP_PASSWORD=password
386393
# SMTP_TIMEOUT=15
387394

395+
# Whether to send mail via the `sendmail` command
396+
# USE_SENDMAIL=false
397+
# Which sendmail command to use. The one found in the $PATH is used if not specified.
398+
# SENDMAIL_COMMAND="/path/to/sendmail"
399+
388400
## Defaults for SSL is "Plain" and "Login" and nothing for Non-SSL connections.
389401
## Possible values: ["Plain", "Login", "Xoauth2"].
390402
## Multiple options need to be separated by a comma ','.

.github/workflows/build.yml

+23-13
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
- "Cargo.*"
1010
- "build.rs"
1111
- "rust-toolchain"
12+
- "rustfmt.toml"
13+
- "diesel.toml"
1214
pull_request:
1315
paths:
1416
- ".github/workflows/build.yml"
@@ -17,6 +19,8 @@ on:
1719
- "Cargo.*"
1820
- "build.rs"
1921
- "rust-toolchain"
22+
- "rustfmt.toml"
23+
- "diesel.toml"
2024

2125
jobs:
2226
build:
@@ -26,60 +30,66 @@ jobs:
2630
# This is done globally to prevent rebuilds when the RUSTFLAGS env variable changes.
2731
env:
2832
RUSTFLAGS: "-D warnings"
33+
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git # Use the old git protocol until it is stable probably in 1.68 or 1.69. MSRV needs to be at this before removed.
2934
strategy:
3035
fail-fast: false
3136
matrix:
3237
channel:
3338
- "rust-toolchain" # The version defined in rust-toolchain
3439
- "msrv" # The supported MSRV
35-
include:
36-
- channel: "msrv"
37-
version: "1.61.0"
3840

3941
name: Build and Test ${{ matrix.channel }}
4042

4143
steps:
4244
# Checkout the repo
4345
- name: "Checkout"
44-
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0
46+
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
4547
# End Checkout the repo
4648

49+
4750
# Install dependencies
4851
- name: "Install dependencies Ubuntu"
4952
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends openssl sqlite build-essential libmariadb-dev-compat libpq-dev libssl-dev pkg-config
5053
# End Install dependencies
5154

55+
5256
# Determine rust-toolchain version
5357
- name: Init Variables
5458
id: toolchain
5559
shell: bash
56-
if: ${{ matrix.channel == 'rust-toolchain' }}
5760
run: |
58-
RUST_TOOLCHAIN="$(cat rust-toolchain)"
61+
if [[ "${{ matrix.channel }}" == 'rust-toolchain' ]]; then
62+
RUST_TOOLCHAIN="$(cat rust-toolchain)"
63+
elif [[ "${{ matrix.channel }}" == 'msrv' ]]; then
64+
RUST_TOOLCHAIN="$(grep -oP 'rust-version.*"(\K.*?)(?=")' Cargo.toml)"
65+
else
66+
RUST_TOOLCHAIN="${{ matrix.channel }}"
67+
fi
5968
echo "RUST_TOOLCHAIN=${RUST_TOOLCHAIN}" | tee -a "${GITHUB_OUTPUT}"
6069
# End Determine rust-toolchain version
6170

62-
# Uses the rust-toolchain file to determine version
71+
72+
# Only install the clippy and rustfmt components on the default rust-toolchain
6373
- name: "Install rust-toolchain version"
64-
uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb # master @ 2022-10-25 - 21:40 GMT+2
74+
uses: dtolnay/rust-toolchain@fc3253060d0c959bea12a59f10f8391454a0b02d # master @ 2023-03-21 - 06:36 GMT+1
6575
if: ${{ matrix.channel == 'rust-toolchain' }}
6676
with:
6777
toolchain: "${{steps.toolchain.outputs.RUST_TOOLCHAIN}}"
6878
components: clippy, rustfmt
6979
# End Uses the rust-toolchain file to determine version
7080

7181

72-
# Install the MSRV channel to be used
82+
# Install the any other channel to be used for which we do not execute clippy and rustfmt
7383
- name: "Install MSRV version"
74-
uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb # master @ 2022-10-25 - 21:40 GMT+2
84+
uses: dtolnay/rust-toolchain@fc3253060d0c959bea12a59f10f8391454a0b02d # master @ 2023-03-21 - 06:36 GMT+1
7585
if: ${{ matrix.channel != 'rust-toolchain' }}
7686
with:
77-
toolchain: ${{ matrix.version }}
87+
toolchain: "${{steps.toolchain.outputs.RUST_TOOLCHAIN}}"
7888
# End Install the MSRV channel to be used
7989

8090

8191
# Enable Rust Caching
82-
- uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
92+
- uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # v2.2.1
8393
# End Enable Rust Caching
8494

8595

@@ -184,7 +194,7 @@ jobs:
184194

185195
# Upload artifact to Github Actions
186196
- name: "Upload artifact"
187-
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3.1.1
197+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
188198
if: ${{ matrix.channel == 'rust-toolchain' }}
189199
with:
190200
name: vaultwarden

.github/workflows/hadolint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
steps:
1414
# Checkout the repo
1515
- name: Checkout
16-
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0
16+
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
1717
# End Checkout the repo
1818

1919

.github/workflows/release.yml

+136-19
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,23 @@ jobs:
4848
ports:
4949
- 5000:5000
5050
env:
51-
DOCKER_BUILDKIT: 1 # Disabled for now, but we should look at this because it will speedup building!
52-
# DOCKER_REPO/secrets.DOCKERHUB_REPO needs to be 'index.docker.io/<user>/<repo>'
53-
DOCKER_REPO: ${{ secrets.DOCKERHUB_REPO }}
51+
# Use BuildKit (https://docs.docker.com/build/buildkit/) for better
52+
# build performance and the ability to copy extended file attributes
53+
# (e.g., for executable capabilities) across build phases.
54+
DOCKER_BUILDKIT: 1
5455
SOURCE_COMMIT: ${{ github.sha }}
5556
SOURCE_REPOSITORY_URL: "https://github.com/${{ github.repository }}"
57+
# The *_REPO variables need to be configured as repository variables
58+
# Append `/settings/variables/actions` to your repo url
59+
# DOCKERHUB_REPO needs to be 'index.docker.io/<user>/<repo>'
60+
# Check for Docker hub credentials in secrets
61+
HAVE_DOCKERHUB_LOGIN: ${{ vars.DOCKERHUB_REPO != '' && secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' }}
62+
# GHCR_REPO needs to be 'ghcr.io/<user>/<repo>'
63+
# Check for Github credentials in secrets
64+
HAVE_GHCR_LOGIN: ${{ vars.GHCR_REPO != '' && github.repository_owner != '' && secrets.GITHUB_TOKEN != '' }}
65+
# QUAY_REPO needs to be 'quay.io/<user>/<repo>'
66+
# Check for Quay.io credentials in secrets
67+
HAVE_QUAY_LOGIN: ${{ vars.QUAY_REPO != '' && secrets.QUAY_USERNAME != '' && secrets.QUAY_TOKEN != '' }}
5668
if: ${{ needs.skip_check.outputs.should_skip != 'true' && github.repository == 'dani-garcia/vaultwarden' }}
5769
strategy:
5870
matrix:
@@ -61,17 +73,10 @@ jobs:
6173
steps:
6274
# Checkout the repo
6375
- name: Checkout
64-
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0
76+
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
6577
with:
6678
fetch-depth: 0
6779

68-
# Login to Docker Hub
69-
- name: Login to Docker Hub
70-
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
71-
with:
72-
username: ${{ secrets.DOCKERHUB_USERNAME }}
73-
password: ${{ secrets.DOCKERHUB_TOKEN }}
74-
7580
# Determine Docker Tag
7681
- name: Init Variables
7782
id: vars
@@ -85,34 +90,146 @@ jobs:
8590
fi
8691
# End Determine Docker Tag
8792

88-
- name: Build Debian based images
93+
# Login to Docker Hub
94+
- name: Login to Docker Hub
95+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
96+
with:
97+
username: ${{ secrets.DOCKERHUB_USERNAME }}
98+
password: ${{ secrets.DOCKERHUB_TOKEN }}
99+
if: ${{ env.HAVE_DOCKERHUB_LOGIN == 'true' }}
100+
101+
# Login to GitHub Container Registry
102+
- name: Login to GitHub Container Registry
103+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
104+
with:
105+
registry: ghcr.io
106+
username: ${{ github.repository_owner }}
107+
password: ${{ secrets.GITHUB_TOKEN }}
108+
if: ${{ env.HAVE_GHCR_LOGIN == 'true' }}
109+
110+
# Login to Quay.io
111+
- name: Login to Quay.io
112+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
113+
with:
114+
registry: quay.io
115+
username: ${{ secrets.QUAY_USERNAME }}
116+
password: ${{ secrets.QUAY_TOKEN }}
117+
if: ${{ env.HAVE_QUAY_LOGIN == 'true' }}
118+
119+
# Debian
120+
121+
# Docker Hub
122+
- name: Build Debian based images (docker.io)
123+
shell: bash
124+
env:
125+
DOCKER_REPO: "${{ vars.DOCKERHUB_REPO }}"
126+
DOCKER_TAG: "${{steps.vars.outputs.DOCKER_TAG}}"
127+
run: |
128+
./hooks/build
129+
if: ${{ matrix.base_image == 'debian' && env.HAVE_DOCKERHUB_LOGIN == 'true' }}
130+
131+
- name: Push Debian based images (docker.io)
132+
shell: bash
133+
env:
134+
DOCKER_REPO: "${{ vars.DOCKERHUB_REPO }}"
135+
DOCKER_TAG: "${{steps.vars.outputs.DOCKER_TAG}}"
136+
run: |
137+
./hooks/push
138+
if: ${{ matrix.base_image == 'debian' && env.HAVE_DOCKERHUB_LOGIN == 'true' }}
139+
140+
# GitHub Container Registry
141+
- name: Build Debian based images (ghcr.io)
142+
shell: bash
143+
env:
144+
DOCKER_REPO: "${{ vars.GHCR_REPO }}"
145+
DOCKER_TAG: "${{steps.vars.outputs.DOCKER_TAG}}"
146+
run: |
147+
./hooks/build
148+
if: ${{ matrix.base_image == 'debian' && env.HAVE_GHCR_LOGIN == 'true' }}
149+
150+
- name: Push Debian based images (ghcr.io)
151+
shell: bash
152+
env:
153+
DOCKER_REPO: "${{ vars.GHCR_REPO }}"
154+
DOCKER_TAG: "${{steps.vars.outputs.DOCKER_TAG}}"
155+
run: |
156+
./hooks/push
157+
if: ${{ matrix.base_image == 'debian' && env.HAVE_GHCR_LOGIN == 'true' }}
158+
159+
# Quay.io
160+
- name: Build Debian based images (quay.io)
89161
shell: bash
90162
env:
163+
DOCKER_REPO: "${{ vars.QUAY_REPO }}"
91164
DOCKER_TAG: "${{steps.vars.outputs.DOCKER_TAG}}"
92165
run: |
93166
./hooks/build
94-
if: ${{ matrix.base_image == 'debian' }}
167+
if: ${{ matrix.base_image == 'debian' && env.HAVE_QUAY_LOGIN == 'true' }}
95168

96-
- name: Push Debian based images
169+
- name: Push Debian based images (quay.io)
97170
shell: bash
98171
env:
172+
DOCKER_REPO: "${{ vars.QUAY_REPO }}"
99173
DOCKER_TAG: "${{steps.vars.outputs.DOCKER_TAG}}"
100174
run: |
101175
./hooks/push
102-
if: ${{ matrix.base_image == 'debian' }}
176+
if: ${{ matrix.base_image == 'debian' && env.HAVE_QUAY_LOGIN == 'true' }}
177+
178+
# Alpine
179+
180+
# Docker Hub
181+
- name: Build Alpine based images (docker.io)
182+
shell: bash
183+
env:
184+
DOCKER_REPO: "${{ vars.DOCKERHUB_REPO }}"
185+
DOCKER_TAG: "${{steps.vars.outputs.DOCKER_TAG}}-alpine"
186+
run: |
187+
./hooks/build
188+
if: ${{ matrix.base_image == 'alpine' && env.HAVE_DOCKERHUB_LOGIN == 'true' }}
189+
190+
- name: Push Alpine based images (docker.io)
191+
shell: bash
192+
env:
193+
DOCKER_REPO: "${{ vars.DOCKERHUB_REPO }}"
194+
DOCKER_TAG: "${{steps.vars.outputs.DOCKER_TAG}}-alpine"
195+
run: |
196+
./hooks/push
197+
if: ${{ matrix.base_image == 'alpine' && env.HAVE_DOCKERHUB_LOGIN == 'true' }}
198+
199+
# GitHub Container Registry
200+
- name: Build Alpine based images (ghcr.io)
201+
shell: bash
202+
env:
203+
DOCKER_REPO: "${{ vars.GHCR_REPO }}"
204+
DOCKER_TAG: "${{steps.vars.outputs.DOCKER_TAG}}-alpine"
205+
run: |
206+
./hooks/build
207+
if: ${{ matrix.base_image == 'alpine' && env.HAVE_GHCR_LOGIN == 'true' }}
208+
209+
- name: Push Alpine based images (ghcr.io)
210+
shell: bash
211+
env:
212+
DOCKER_REPO: "${{ vars.GHCR_REPO }}"
213+
DOCKER_TAG: "${{steps.vars.outputs.DOCKER_TAG}}-alpine"
214+
run: |
215+
./hooks/push
216+
if: ${{ matrix.base_image == 'alpine' && env.HAVE_GHCR_LOGIN == 'true' }}
103217

104-
- name: Build Alpine based images
218+
# Quay.io
219+
- name: Build Alpine based images (quay.io)
105220
shell: bash
106221
env:
222+
DOCKER_REPO: "${{ vars.QUAY_REPO }}"
107223
DOCKER_TAG: "${{steps.vars.outputs.DOCKER_TAG}}-alpine"
108224
run: |
109225
./hooks/build
110-
if: ${{ matrix.base_image == 'alpine' }}
226+
if: ${{ matrix.base_image == 'alpine' && env.HAVE_QUAY_LOGIN == 'true' }}
111227

112-
- name: Push Alpine based images
228+
- name: Push Alpine based images (quay.io)
113229
shell: bash
114230
env:
231+
DOCKER_REPO: "${{ vars.QUAY_REPO }}"
115232
DOCKER_TAG: "${{steps.vars.outputs.DOCKER_TAG}}-alpine"
116233
run: |
117234
./hooks/push
118-
if: ${{ matrix.base_image == 'alpine' }}
235+
if: ${{ matrix.base_image == 'alpine' && env.HAVE_QUAY_LOGIN == 'true' }}

.hadolint.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@ ignored:
33
- DL3008
44
# disable explicit version for apk install
55
- DL3018
6+
# disable check for consecutive `RUN` instructions
7+
- DL3059
68
trustedRegistries:
79
- docker.io
10+
- ghcr.io
11+
- quay.io

0 commit comments

Comments
 (0)