Commit Graph

91 Commits

Author SHA1 Message Date
Wolfgang Bumiller
0652d81977 tree-wide: enable doc_cfg and doc_auto_cfg for docs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-07-02 11:59:53 +02:00
Maximiliano Sandoval
a87d52dad3 remove unneeded returns
Fixes the clippy warning:

warning: unneeded `return` statement
   --> proxmox-tfa/src/api/mod.rs:468:17
    |
468 | /                 return TfaResult::Failure {
469 | |                     needs_saving: true,
470 | |                     tfa_limit_reached,
471 | |                     totp_limit_reached,
472 | |                 };
    | |_________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
    = note: `#[warn(clippy::needless_return)]` on by default
help: remove `return`
    |
468 ~                 TfaResult::Failure {
469 +                     needs_saving: true,
470 +                     tfa_limit_reached,
471 +                     totp_limit_reached,
472 ~                 }
    |

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-06-28 10:22:58 +02:00
Maximiliano Sandoval
18dda8106b remove unnecesary pub(self)
Fixes the clippy warning:

warning: unnecessary `pub(self)`
    --> proxmox-tfa/src/api/mod.rs:1268:1
     |
1268 | pub(self) fn bool_is_false(v: &bool) -> bool {
     | ^^^^^^^^^ help: remove it
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pub_self

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-06-28 10:22:58 +02:00
Maximiliano Sandoval
aff76f9e0e remove needless borrows
Fixes the following clippy warnings:

warning: the borrowed expression implements the required traits
  --> proxmox-tfa/src/api/recovery.rs:86:24
   |
86 |         Ok(hex::encode(&hmac))
   |                        ^^^^^ help: change this to: `hmac`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args

and

warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> proxmox-network-api/src/api_impl.rs:108:47
    |
108 |                 interface.set_bond_slave_list(&slaves)?;
    |                                               ^^^^^^^ help: change this to: `slaves`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
    = note: `#[warn(clippy::needless_borrow)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-06-28 10:22:58 +02:00
Maximiliano Sandoval
16aa2b74bc use unwrap_or_default instead of unwrap_or(Vec::new)
Fixes the clippy warning:

warning: use of `unwrap_or_else` to construct default value
    --> proxmox-tfa/src/api/mod.rs:1355:43
     |
1355 |         |cap| cap.map(Vec::with_capacity).unwrap_or_else(Vec::new),
     |                                           ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default
     = note: `#[warn(clippy::unwrap_or_default)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-06-28 10:22:58 +02:00
Wolfgang Bumiller
80baf82df2 tfa: bump to 4.1.3
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-06-20 13:58:55 +02:00
Wolfgang Bumiller
2e9526dcdd tfa: fix a compile warning
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-06-20 10:55:10 +02:00
Fabian Grünbichler
6f532dfb7d various clippy fixes
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-06-06 11:40:49 +02:00
Wolfgang Bumiller
9da7b3ad49 bump proxmox-tfa to 4.1.2
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-02-02 14:00:49 +01:00
Wolfgang Bumiller
3c1103e7d5 bump proxmox-tfa to 4.1.1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-12-06 16:01:13 +01:00
Wolfgang Bumiller
5d9e33d1d9 tfa: fix deserialize-default in TfaUser
Note that this was currently not deserialized anywhere, so this was
not an issue, but the api-macro now treats this as an error.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-12-06 14:54:47 +01:00
Wolfgang Bumiller
4da2fee6fa bump tfa to 4.1.0
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-11-23 09:21:38 +01:00
Dietmar Maurer
34e86078c2 proxmox-tfa: derive Copy, Clone and PartialEq on TfaType (for GUI)
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-10-23 11:44:45 +02:00
Wolfgang Bumiller
9e8f90e667 tfa: more optional dependency cleanup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-10-16 09:00:18 +02:00
Wolfgang Bumiller
6940908a8a tfa: make totp a feature and mark all optional deps as optional
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-10-16 08:58:09 +02:00
Lukas Wagner
81ca4ae6a1 clippy fix: needless borrow
See:
https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-08 11:29:36 +02:00
Wolfgang Bumiller
1a8a3668a5 bump proxmox-tfa to 4.0.5
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-24 10:56:14 +02:00
Wolfgang Bumiller
50136f1817 bump proxmox-tfa to 4.0.4
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-05 10:46:12 +02:00
Wolfgang Bumiller
8547ee31da tfa: also reset counters when unlocking tfa
Since this requires access to the user data, we need to add
a generic parameter to the unlock methods.
To avoid having to create another major API bump affecting
all our products this short after release, we keep the old
version around with the old behavior.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-04 14:45:18 +02:00
Maximiliano Sandoval
84edb20eb8 tfa: Improve TOTP algorithm parsing
It is very common for TOTP URIs to contain the algorithm in lowercase,
hence we convert to lowercase when doing From<&str> for Algorithm.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2023-06-20 12:39:46 +02:00
Wolfgang Bumiller
39a486f574 bump proxmox-tfa to 4.0.3
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-14 13:52:20 +02:00
Wolfgang Bumiller
5f1a0bc0c9 tfa: make TfaUser fields public
So we can print them in the proxmox-backup-manager CLI text
output.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-14 13:50:38 +02:00
Wolfgang Bumiller
35dc1b0b8d bump proxmox-tfa to 4.0.2
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-05 08:59:55 +02:00
Wolfgang Bumiller
abd2558b01 tfa: reduce default lockout time to an hour
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-01 15:10:53 +02:00
Wolfgang Bumiller
adb868ee08 tfa: include lockout status in the tfa user list
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-01 12:22:18 +02:00
Wolfgang Bumiller
c5a9fa8595 bump proxmox-tfa to 4.0.1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-31 12:54:47 +02:00
Wolfgang Bumiller
f3666afd22 tfa: add d/source/format
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-31 12:54:47 +02:00
Wolfgang Bumiller
a26ec45d74 tfa: add api::methods::unlock_tfa
This mostly serves as documentation for the API call to be
implemented across our products. It's otherwise already just
a oneliner on the TfaConfig.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-31 12:54:47 +02:00
Wolfgang Bumiller
8f8d52f148 update d/copyright files to debian copyright-format 1.0
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-23 13:02:39 +02:00
Wolfgang Bumiller
76ac1a3903 bump proxmox-tfa to 4.0.0-1, auth-api to 0.1.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-10 10:43:21 +02:00
Wolfgang Bumiller
39017fa334 tfa: add functions to unlock totp and tfa
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-10 10:35:54 +02:00
Wolfgang Bumiller
a3448feb1a tfa: log all tfa verify errors and treat as failure, count
Use a custom result type to return success/failure and the
need to save the user data to the caller, while having
logged the error messages rather than returning them.

We count general TFA failures and also TOTP specifically,
and lock the user out of their 2nd factors on too many
failures.

To this end, all errors are now treated as failures.
While technically we can have crypto errors the user might
not be able to cause, we can't always know, and not all
errors are guaranteed to be a host side configuration issue,
so instead, all errors (since they are rare) now now counted
as a regular TFA error.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-10 10:35:54 +02:00
Wolfgang Bumiller
50b793db8d tfa: add data for rate limiting and blocking
TfaUserData uses `#[serde(deny_unknown_fields)]`, so we add
this now, but using it will require explicitly enabling it.

If the TOTP count is high, the user should be locked out of
TOTP entirely until they use a recovery key to reset the
count.

If a user's TFA try count is too high, they should get rate
limited.

In both cases they should receive some kind of notification.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-10 10:26:51 +02:00
Wolfgang Bumiller
8d968274f1 tfa: make 'anyhow' optional, enable with the 'api' feature
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-08 10:32:26 +02:00
Wolfgang Bumiller
3224f42ff5 tfa: fix warning with types feature w/o api feature
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-08 10:32:26 +02:00
Wolfgang Bumiller
5c39559cad tfa: drop anyhow from totp module
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-08 10:32:26 +02:00
Wolfgang Bumiller
c45620b447 tfa: drop anyhow from u2f module
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-08 10:32:26 +02:00
Wolfgang Bumiller
0d942e81a3 tfa: add a 'types' feature to get TfaInfo and TfaType
without adding the entire API as well, so API clients can
actually use the types used by the api methods without
requiring the backend implementation being built in as
well...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-08 10:32:26 +02:00
Wolfgang Bumiller
b6840e95ad tfa: make failing to generate a webauthn challenge non-fatal
If WA or U2F fail to produce a challenge, the user may still
log in with other factors and the challenge will be
considered to not be empty.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-08 10:32:26 +02:00
Wolfgang Bumiller
4b3d171b2d tfa: don't return a challenge if all 2nd factors are disabled
Instead, this should allow the user to login without them.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-08 10:32:26 +02:00
Wolfgang Bumiller
ea1d023a61 tfa: don't automatically drop empty recovery
This should only ever be explicitly removed.

Similarly, include an empty array of recovery keys in the
tfa challenge, so that clients know about empty recoveries
rather than getting an empty challenge when there are no
other factors available.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-08 10:32:26 +02:00
Thomas Lamprecht
5df815f660 proxmox-tfa: update generated d/control
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-03-02 16:54:59 +01:00
Wolfgang Bumiller
bca9c6dbaf bump proxmox-tfa to 3.0.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 16:44:35 +01:00
Wolfgang Bumiller
5349ae208b add proxmox-auth-api crate
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 16:44:35 +01:00
Fabian Grünbichler
ee8419cf2d workspace: switch remaining dependencies
while these are (currently) only used by a single member each, having *all*
dependency versions specified in the top level Cargo.toml only makes the whole
process of managing them less error-prone.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-12 11:05:30 +01:00
Fabian Grünbichler
46a675830d update d/control files
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:47 +01:00
Fabian Grünbichler
bdca6de588 update d/control files
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:47 +01:00
Fabian Grünbichler
e5abc0590e define workspace dependencies in workspace
so that we no longer have to (or forget to) bump the version in multiple places.

notable changes:
- outdated versions have been unified
- proxmox-metrics -> proxmox-async no longer uses explicit empty features
  (proxmox-async doesn't provide any anyway)
- proxmox-subscription -> proxmox-http no longer uses explicit default_features
  = false (proxmox-http has an empty default feature anyway)
- missing path dependencies added (mainly proxmox-rest-server)

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:38 +01:00
Fabian Grünbichler
6c161bd5ab update d/control files
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:38 +01:00
Fabian Grünbichler
4189221470 inherit shared, external dependencies
noteworthy changes:
- proxmox-http had a default_features_false dep on hyper, which is dropped (the
  default feature is empty anyway)
- hyper, libc, nix, tokio and url versions are unified
- missing (cosmetic) bindgen feature on zstd enabled everywhere

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:38 +01:00