Commit Graph

2031 Commits

Author SHA1 Message Date
Wolfgang Bumiller
4639542fce rest-server: PeerAddress for Pin<Box<T>>
since this is how tokio-openssl's SslStream is used in
practice

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 16:14:04 +01:00
Wolfgang Bumiller
515cc729d0 rest-server: drop ServerAdapter, move AuthError
Instead of a ServerAdapter for the index page and
authentication checking (which don't relate to each other),
provide a `.with_auth_handler` and `.with_index_handler`
builder for ApiConfig separately.

Both are optional. Without an index handler, it'll produce a
404. Without an auth handler, an `AuthError::NoData` is
returned.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 16:14:04 +01:00
Wolfgang Bumiller
6904dcf4e6 rest-server: make adapter optional
when no user information or index needs to be defined

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 16:14:04 +01:00
Wolfgang Bumiller
4a5360aef4 rest-server: drop Router from ApiConfig
instead, allow attaching routers to path prefixes and also
add an optional non-formatting router

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 16:13:55 +01:00
Wolfgang Bumiller
258e2399a6 rest-server: make handlebars optional as 'templates' feature
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 16:07:50 +01:00
Wolfgang Bumiller
28ba2016e5 rest-server: cleanup unreadable code
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 15:44:35 +01:00
Wolfgang Bumiller
a1119a3e63 rest-server: use BAD_REQUEST for non-GET on file-paths
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 15:44:35 +01:00
Wolfgang Bumiller
93c027f5cc rest-server: make handle_request a method of ApiConfig
This is what actually defines the API server after all.
The ApiService trait in between is a hyper impl detail.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 15:44:35 +01:00
Wolfgang Bumiller
5fe0777318 rest-server: drop allocation in Service impl
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 15:44:35 +01:00
Wolfgang Bumiller
e377909bee rest-server: PeerAddr trait, drop proxmox-http dep
We pulled in proxmox-http with the client feature solely to
implement the `Service` trait on
`SslStream<RateLimitedStream<TcpStream>>`.

All those `Service` impls are the same: provide a peer
address and return an `ApiService`.
Let's put the `peer_addr()` call into a trait and build from
there.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 15:44:35 +01:00
Wolfgang Bumiller
01436ae30f rest-server: make socketpair private
`proxmox_rest_server::socketpair` doesn't make sense as an
external API

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 15:44:35 +01:00
Wolfgang Bumiller
ccc70bc95f rest-server: start 0.3 api refactoring
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 15:44:35 +01:00
Wolfgang Bumiller
1a14696a5c ldap: test fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 15:44:11 +01:00
Wolfgang Bumiller
7e12788c60 sys: drop sortable and identity macros
We should not use the sys crate to pull in the sortable
macro, just depend on its crate instead...
And the identity macro used to be required by the sortable
macro, but is not anymore and has been deprecated for a
while, so we can now drop it.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-01 13:40:40 +01:00
Wolfgang Bumiller
2cf54dcf2e router: make format&print generic
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-02-28 14:57:35 +01:00
Wolfgang Bumiller
46e803256e release proxmox-ldap to 0.1.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-02-10 10:42:40 +01:00
Wolfgang Bumiller
6dcdbd2bd1 bump proxmox-rest-server to 0.2.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-02-10 10:42:40 +01:00
Lukas Wagner
d696ad5bd1 rest-server: add handle_worker from backup debug cli
The function has now multiple users, so it is moved
here.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-02-10 10:23:41 +01:00
Wolfgang Bumiller
e8e8f83723 ldap: fixup d/control
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-02-08 14:30:52 +01:00
Wolfgang Bumiller
870be885ed ldap: drop Ldap prefix from types that have it
for a bit more consistency and since we tend to repeat stuff
too much

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-02-08 14:29:12 +01:00
Wolfgang Bumiller
4ff5c59559 fix 'default-features = false' for ldap3
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-02-08 14:26:34 +01:00
Wolfgang Bumiller
cd61c8741c ldap: clippy fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-02-08 14:15:44 +01:00
Lukas Wagner
1db057e189 ldap: add debian packaging
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-02-08 14:11:24 +01:00
Lukas Wagner
582e994cca ldap: tests: add LDAP integration tests
This commit adds integration tests to ensure that the crate works as intended.
The tests are executed against a real LDAP server, namely `glauth`. `glauth` was
chosen because it ships as a single, statically compiled binary and can
be configured with a single configuration file.

The tests are written as off-the-shelf unit tests. However, they are
 #[ignored] by default, as they have some special requirements:
   * They required the GLAUTH_BIN environment variable to be set,
     pointing to the location of the `glauth` binary. `glauth` will be
     started and stopped automatically by the test suite.
   * Tests have to be executed sequentially (`--test-threads 1`),
     otherwise multiple instances of the glauth server might bind to the
     same port.

The `run_integration_tests.sh` checks whether GLAUTH_BIN is set, or if
not, attempts to find `glauth` on PATH. The script also ensures that the
tests are run sequentially.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-02-08 14:11:21 +01:00
Lukas Wagner
4488256cb1 ldap: allow searching for LDAP entities
This commit adds the search_entities function, which allows to search for
LDAP entities given certain provided criteria.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-02-08 14:11:18 +01:00
Lukas Wagner
b9ab0ba4fa ldap: add helpers for constructing LDAP filters
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-02-08 14:11:15 +01:00
Lukas Wagner
6fd77c9a5e ldap: add basic user auth functionality
In the LDAP world, authentication is done using the bind operation, where
users are authenticated with the tuple (dn, password). Since we only know
the user's username, it is first necessary to look up the user's
domain (dn).

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-02-08 14:11:12 +01:00
Lukas Wagner
0e2f88ccf3 ldap: create new proxmox-ldap crate
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-02-08 14:11:08 +01:00
Thomas Lamprecht
fbac2f0a0c sys: fixup error types handling
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-02-02 16:32:37 +01:00
Thomas Lamprecht
ce389914ff sys: cope with unavailable KSM sharing info
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-02-02 16:12:20 +01:00
Wolfgang Bumiller
2cebe420c1 bump proxmox-time to 1.1.5-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-01-12 14:23:11 +01:00
Wolfgang Bumiller
fadf7f7bd8 re-add proxmox-uuid d/control
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-01-12 14:22:52 +01:00
Wolfgang Bumiller
78d9b156a8 bump proxmox-uuid to 1.0.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-01-12 13:49:18 +01:00
Thomas Lamprecht
ecf59cbb74 bump version to 0.9.9-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-01-11 18:42:20 +01:00
Thomas Lamprecht
2f4254b414 cargo: update openidconnect to 2.4
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-01-11 18:41:06 +01:00
Fabian Grünbichler
093afb985f bump version to 0.9.8-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-05 12:26:47 +01:00
Fabian Grünbichler
ae6bf664dd update nix to 0.26
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-05 12:24:51 +01:00
Fabian Grünbichler
773400829a update d/control
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-05 12:24:46 +01:00
Fabian Grünbichler
9c44e9b410 update d/control files
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-05 12:17:00 +01:00
Fabian Grünbichler
3046e2f285 bump proxmox-rest-server to 0.2.1-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-05 12:15:14 +01:00
Fabian Grünbichler
30ae33a31d bump proxmox-shared-memory to 0.2.3-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-05 12:13:53 +01:00
Fabian Grünbichler
40cb468bef bump proxmox-router to 1.3.1-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-05 12:10:00 +01:00
Fabian Grünbichler
d0c1958f86 bump proxmox-schema to 1.3.6-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-05 12:08:58 +01:00
Fabian Grünbichler
01e9b3affc bump proxmox-sys to 0.4.2-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-05 12:07:45 +01:00
Fabian Grünbichler
ff9aa2012e update nix to 0.26
it's the version currently shipped by bookworm, so let's unify this widely-used
dependency to make bootstrapping easier.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-05 12:07:16 +01:00
Fabian Grünbichler
6953154254 update d/control
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-05 11:49:03 +01:00
Dietmar Maurer
78e86f3261 re-add epoch_to_rfc3339_utc on wasm target
This was lost in commit 980d6b26df.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2022-12-15 13:35:53 +01:00
Fabian Grünbichler
acaf55c437 clippy fix
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-13 14:56:42 +01:00
Fabian Grünbichler
6eb638c806 section-config: silence clippy
these two functions don't actually use the `type_name` parameter, but the
interface including custom formatters require it.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-13 14:53:28 +01:00
Fabian Grünbichler
77ac0bd5fe section-config: make ReST dump reproducible
HashMaps are not ordered, so each package build containing a section config
dump would have the documentation ordered randomly.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-13 14:51:50 +01:00