Commit Graph

68 Commits

Author SHA1 Message Date
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
Fabian Grünbichler
64959d9ae0 move common metadata to workspace
and switch all crates to 2021 edition as well as a unified "authors" value.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:25 +01:00
Fabian Grünbichler
5ec765f842 update d/control files
debcargo 2.6 changed some minor details

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-06 11:21:43 +01:00
Thomas Lamprecht
52a8eb6ace d/control: tree wide update after switch to weak/namespaced dependencies
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-08-26 12:07:36 +02:00
Fabian Grünbichler
289d297c7d build: use weak and namespaced features
to reduce the creep of optional dependencies being exposed as features.

this requires cargo 0.63 (and debcargo built against at least that
version), but greatly reduces the number of binary packages and provides
generated, while still allowing sensible selection of optional
dependencies via the explicit feature meant for pulling them in.

diff stat for running `make  deb` after this change:
 proxmox-http/debian/control         | 226 ++++--------------------------------
 proxmox-router/debian/control       |  74 +-----------
 proxmox-schema/debian/control       |  53 ++-------
 proxmox-subscription/debian/control |  17 +--
 proxmox-sys/debian/control          |  51 +++-----
 proxmox-tfa/debian/control          | 110 ++----------------
 6 files changed, 72 insertions(+), 459 deletions(-)

the 'dep:' prefix marks something on the RHS inside the features section
as dependency, it's only allowed if the string after it is an optional
dependency an no explicit feature of the same name exists. if all
pointers to the optional dependency in the features section are marked
as such, the optional dependency itself will not be exposed as a feature
(either on the cargo or debian/control level).

the '?' suffix marks dependencies as "weak", which only enables the
optional dependency + its feature(s) if the optional dependency itself
is also enabled. it has no effect on d/control since such a relationship
is not encodable in Debian package relations, but it does affect cargo
dependency resolution and allows skipping the build of unneeded optional
dependencies in some cases.

with no packages/crates depending on the no longer exposed automatically
generated features/packages, so these are safe to remove even though
it's technically a breaking change.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-08-26 10:35:00 +02:00
Wolfgang Bumiller
36625fb92c tfa: bump d/control
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-07-26 12:24:01 +02:00
Wolfgang Bumiller
d0b4f0bf2f tfa: docs fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-07-26 12:23:50 +02:00
Wolfgang Bumiller
df0d30a106 bump proxmox-tfa to 2.1.0
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-07-25 13:38:04 +02:00
Wolfgang Bumiller
a7f808d43b tfa: bump edition to 2021
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-07-25 13:35:58 +02:00
Wolfgang Bumiller
d396c3ea31 tfa: clippy fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-07-25 13:35:57 +02:00
Wolfgang Bumiller
ea34292850 tfa: expose 'allow_subdomains' property
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-07-25 13:25:52 +02:00
Thomas Lamprecht
9c0e9dca59 tree wide update of genereated control
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-05-05 10:22:50 +02:00
Thomas Lamprecht
6f8173f67a tfa: rustfmt
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-04-10 12:34:41 +02:00
Wolfgang Bumiller
f04eb949d1 tfa: serde tools: improve variance and dropck
`FoldSeqVisitor` doesn't actually own a `T` and therefore
cannot drop a `T`, we only use it via the `Fn(&mut Out, T)`,
so use `fn(T)` in the `PhantomData` to keep `T`
contravariant.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-03-22 12:31:54 +01:00
Wolfgang Bumiller
86f3c90763 proxmox-tfa: fully deserialize TfaChallenge
otherwise clients cannot use this...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-02-11 08:56:34 +01:00
Wolfgang Bumiller
e5a43afe10 proxmox-tfa: make TfaChallenge members public
rust based *clients* may want/need access to it

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-02-11 08:56:34 +01:00
Fabian Grünbichler
ca563a8cfd misc clippy fixes
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-02-08 14:28:44 +01:00
Thomas Lamprecht
c70d98c90c tfa: fix hyperlink in doc comment
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-02-04 17:06:02 +01:00
Fabian Grünbichler
3ee175c798 tfa: ignore uncompilable doctest
the doctest code uses non-public `fold`, up for re-evaluation if this
gets moved to proxmox-serde and made public..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2021-12-30 11:51:08 +01:00
Wolfgang Bumiller
dddfa1164b tfa: formatting
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-12-07 11:51:22 +01:00
Wolfgang Bumiller
6679005b4f bump proxmox-tfa to 2.0.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-11-28 17:00:29 +01:00
Wolfgang Bumiller
d85ebbb464 tfa: clippy fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-11-28 17:00:29 +01:00
Wolfgang Bumiller
637188d4ba tfa: make configured webauthn origin optional
and add a webauthn origin override parameter to all methods
accessing it

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-11-28 17:00:29 +01:00
Wolfgang Bumiller
508c1e7c85 tfa: let OriginUrl deref to its inner Url, add FromStr impl
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-11-28 17:00:29 +01:00