Skip to content

feat!: Add masterkey as credential option#468

Merged
aawsome merged 1 commit intomainfrom
credential
Jan 30, 2026
Merged

feat!: Add masterkey as credential option#468
aawsome merged 1 commit intomainfrom
credential

Conversation

@aawsome
Copy link
Member

@aawsome aawsome commented Jan 29, 2026

Adds the possibility to use a master key directly as credential to open/initialize a repository.

Using the masterkey has the following advantages:

  • no need anymore to save the masterkey (encrypted) in the repository. This increases security as it eliminates possible master key leaks due to insecure passwords or a vulnerability in the scrypt algorithm.
  • by not using the scrypt algorithm, opening a repository is much faster and needs much less resources (CPU/Memory) making this option interesting for some use cases.

Advantages of the still supported password credential are the possibility to backup the masterkey in the repository - and of course allowing to access the repo using a noticeable password.

Note that this change allows to use repositories with only the masterkey, but additionally allows to access a "normal" repository with keyfiles with either a password or the masterky.

As a side effect, most integration tests are now much faster as most now use the masterkey.

This is a breaking change as it changes Repository methods.

@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.1%. Comparing base (54463a9) to head (4e1b8d8).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/core/src/repository/credentials.rs 47.5% 21 Missing ⚠️
crates/core/src/repository/command_input.rs 33.3% 16 Missing ⚠️
crates/core/src/repository.rs 56.2% 7 Missing ⚠️
crates/core/src/commands/init.rs 71.4% 2 Missing ⚠️
crates/core/src/repofile/keyfile.rs 66.6% 2 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
crates/core/src/error.rs 66.0% <ø> (-1.2%) ⬇️
crates/core/src/repofile.rs 73.9% <ø> (+4.3%) ⬆️
crates/core/tests/integration.rs 78.5% <100.0%> (+0.7%) ⬆️
crates/core/tests/keys.rs 100.0% <ø> (ø)
crates/core/src/commands/init.rs 85.0% <71.4%> (-8.8%) ⬇️
crates/core/src/repofile/keyfile.rs 67.1% <66.6%> (+0.4%) ⬆️
crates/core/src/repository.rs 47.7% <56.2%> (+0.5%) ⬆️
crates/core/src/repository/command_input.rs 55.8% <33.3%> (-10.9%) ⬇️
crates/core/src/repository/credentials.rs 47.5% <47.5%> (ø)

... and 20 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@s-leroux
Copy link

s-leroux commented Jan 30, 2026

Great job!

I assume the key should be given (unencrypted) as a new global option, isn't it?

Many tools accept command-line arguments, environment variables, and password files (with proper permission check, eg, 600). I don't know if this is a requirement here (or maybe you already implemented that!-)

Advantages of the still supported password credential are the possibility to backup the masterkey in the repository

(emphasis mine)

I think the password credentials with the master key encrypted in the repository should remain the default strategy. It is reasonably safe, depending on the SLA of the underlying storage provider. Can the user change the strategy after the repo init?

@aawsome
Copy link
Member Author

aawsome commented Jan 30, 2026

I think the password credentials with the master key encrypted in the repository should remain the default strategy. It is reasonably safe, depending on the SLA of the underlying storage provider. Can the user change the strategy after the repo init?

The default will be what the user selects. If they don't select anything, rustic will ask for a password and create a key for this in the repo as it is now.

The strategy can be changed any time. You can always add new repository keys using rustic key add and remove them using rustic key remove (except the one you are using to call that command, for safety reasons; but using the masterkey, you can remove every key).
And if you have both the masterkey and a password to a key in the repo, you can use either to open the repository.

@aawsome aawsome merged commit fd592d9 into main Jan 30, 2026
25 checks passed
@aawsome aawsome deleted the credential branch January 30, 2026 21:33
@rustic-release-plz rustic-release-plz bot mentioned this pull request Jan 30, 2026
@aawsome
Copy link
Member Author

aawsome commented Jan 31, 2026

This feature has now also been added to rustic and is available in the nightly builds (and the upcoming 0.11.0 version).
I have prepared the docu update here: rustic-rs/docs#123

github-merge-queue bot pushed a commit that referenced this pull request Feb 11, 2026
## 🤖 New release

* `rustic_core`: 0.9.0 -> 0.10.0 (✓ API compatible changes)
* `rustic_backend`: 0.5.4 -> 0.6.0 (✓ API compatible changes)
* `rustic_testing`: 0.3.4 -> 0.4.0 (✓ API compatible changes)
* `rustic_config`: 0.2.3 -> 0.2.4 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

## `rustic_core`

<blockquote>

##
[0.10.0](rustic_core-v0.9.0...rustic_core-v0.10.0)
- 2026-02-09

### Added

- [**breaking**] Add support for batch warmup
([#438](#438))
- [**breaking**] Add masterkey as credential option
([#468](#468))
- improve copy algorithm
([#464](#464))
- [**breaking**] More rewrite features
([#465](#465))
- [**breaking**] Add rewrite command
([#462](#462))
- [**breaking**] extend LocalSourceSaveOptions
([#461](#461))
- [**breaking**] improve restore algorithm
([#453](#453))
- [**breaking**] change ignore-devid to with-devid
([#460](#460))
- Use Timestamp in index
([#458](#458))
- Optimize prune rewrite
([#448](#448))
- [**breaking**] Add support for multiple parents
([#427](#427))

### Fixed

- fix clippy lints
([#473](#473))
- Use jiff everywhere
([#467](#467))
- fix rewrite file count
([#466](#466))
- Return error if too few snapshots for latest~N
([#459](#459))
- Use early-delete-index only if instant-delete is selected
([#457](#457))
- fix clap runtime errors for parent options
([#456](#456))
- Use parents instead of parent; allow latest
([#455](#455))
- improve error handling for missing UID/GID name
([#454](#454))
- fix clippy lints
([#449](#449))

### Other

- update dependencies
([#475](#475))
- [**breaking**] Refactor snapshot grouping
([#474](#474))
- [**breaking**] Simplify Repository status
([#472](#472))
- [**breaking**] Simplify Progress
([#469](#469))
- update MSRV to 1.88.0
([#471](#471))
- FreeBSD build
([#440](#440))
- refactor! use jiff instead of chrono
([#452](#452))
</blockquote>

## `rustic_backend`

<blockquote>

##
[0.6.0](rustic_backend-v0.5.4...rustic_backend-v0.6.0)
- 2026-02-09

### Added

- [**breaking**] Add support for batch warmup
([#438](#438))
- *(backend/opendal)* include scheme in location() and bump opendal to
0.55.0 ([#446](#446))

### Fixed

- fix clippy lints
([#473](#473))
- Use jiff everywhere
([#467](#467))

### Other

- update dependencies
([#475](#475))
- update MSRV to 1.88.0
([#471](#471))
</blockquote>

## `rustic_testing`

<blockquote>

##
[0.4.0](rustic_testing-v0.3.4...rustic_testing-v0.4.0)
- 2026-02-09

### Added

- [**breaking**] Add support for batch warmup
([#438](#438))
</blockquote>

## `rustic_config`

<blockquote>

##
[0.2.4](rustic_config-v0.2.3...rustic_config-v0.2.4)
- 2026-02-09

### Other

- update MSRV to 1.88.0
([#471](#471))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: rustic-release-plz[bot] <182542030+rustic-release-plz[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants