Thomas Lamprecht
649ff6f67f
server/REST: check auth: code cleanup, better variable names
...
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-12 18:39:45 +02:00
Thomas Lamprecht
1fa5b1108d
server/REST: make handle_request private
...
it's not used anywhere else, so do not suggest so
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-12 18:39:00 +02:00
Thomas Lamprecht
4becd202c5
server: get index: make content-type non mutable
...
feels more idiomatic
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-12 13:36:45 +02:00
Thomas Lamprecht
a049949d14
server/rest: code cleanup: use async
...
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-12 13:36:45 +02:00
Fabian Grünbichler
16f05d6649
REST: don't print CSRF token
...
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-10-08 15:57:22 +02:00
Thomas Lamprecht
d2b63c504a
REST server: avoid hard coding world readable API endpoints
...
while we probably do not add much more to them, it still looks ugly.
If this was made so that adding a World readable API call is "hard"
and not done by accident, it rather should be done as a test on build
time. But, IMO, the API permission schema definitions are easy to
review, and not often changed/added - so any wrong World readable API
call will normally still caught.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-05 08:29:43 +02:00
Thomas Lamprecht
c6ab240333
rest server: cleanup use statements
...
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-02 13:04:08 +02:00
Thomas Lamprecht
1b79d5d5a5
ui: add translation support
...
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-09-08 08:54:33 +02:00
Thomas Lamprecht
7917e89426
tools: rename extract_auth_cookie to extract_cookie
...
It does nothing specific to authentication..
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-09-08 08:54:33 +02:00
Wolfgang Bumiller
3c8cb5129e
replace and remove old ticket functions
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-12 14:28:21 +02:00
Wolfgang Bumiller
906ea7a45b
introduce Username, Realm and Userid api types
...
and begin splitting up types.rs as it has grown quite large
already
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-10 12:05:01 +02:00
Wolfgang Bumiller
df9109d493
bump proxmox to 0.3, cleanup http_err macro usage
...
Also swap the order of a couple of `.map_err().await` to
`.await.map_err()` since that's generally more efficient.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-29 09:38:36 +02:00
Dominik Csapak
054951682d
server/rest: add console to index
...
register the console template and render it when the 'console' parameter
is given
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-23 12:06:38 +02:00
Dominik Csapak
9993f4d099
server/config: add mechanism to update template
...
instead of exposing handlebars itself, offer a register_template and
a render_template ourselves.
render_template checks if the template file was modified since
the last render and reloads it when necessary
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-23 11:55:00 +02:00
Thomas Lamprecht
ab08bd7f39
server: add path value to NOT_FOUND http error
...
Especially helpful for requests not coming from browsers (where the
URL is normally easy to find out).
Makes it easier to detect if one triggered a request with an old
client, or so..
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-07-16 12:46:51 +02:00
Dietmar Maurer
c6f8eaf481
src/server/rest.rs: avoid compiler warning
2020-07-10 09:13:52 +02:00
Dietmar Maurer
991cc982c7
src/server/rest.rs: disable debug logs
2020-07-09 16:18:14 +02:00
Dominik Csapak
52148f892d
improve 'debug' parameter
...
instead of checking on '1' or 'true', check that it is there and not
'0' and 'false'. this allows using simply
https://foo:8007/?debug
instead of
https://foo:8007/?debug=1
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-06-26 09:12:14 +02:00
Dominik Csapak
d0815e5e71
change index to templates using handlebars
...
using a handlebars instance in ApiConfig, to cache the templates
as long as possible, this is currently ok, as the index template
can only change when the whole package changes
if we split this in the future, we have to trigger a reload of
the daemon on gui package upgrade (so that the template gets reloaded)
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-04-29 17:05:53 +02:00
Dietmar Maurer
d9d3da2b68
src/config/cached_user_info.rs: cache it up to 5 seconds
2020-04-18 08:49:20 +02:00
Wolfgang Bumiller
803e71103a
switch from failure to anyhow
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-17 18:43:30 +02:00
Dietmar Maurer
5bbd4eef2d
src/server/rest.rs: reduce delay for permission error to 500ms
2020-04-16 12:56:34 +02:00
Dietmar Maurer
a73a7c33b2
start impl. access permissions
2020-04-16 12:47:16 +02:00
Dietmar Maurer
d967838214
api: add list_domains
2020-04-09 11:36:45 +02:00
Dietmar Maurer
7726d660b6
src/server/rest.rs: use correct formatter
2020-03-26 12:54:20 +01:00
Wolfgang Bumiller
6b5dc96c7d
bump proxmox crate to 0.1.7
...
The -sys, -tools and -api crate have now been merged into
the proxmx crate directly. Only macro crates are separate
(but still reexported by the proxmox crate in their
designated locations).
When we need to depend on "parts" of the crate later on
we'll just have to use features.
The reason is mostly that these modules had
inter-dependencies which really make them not independent
enough to be their own crates.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-21 13:48:37 +01:00
Thomas Lamprecht
4a08490b81
add CSS file for PBS ExtJS6 basic ui
...
some fitting rules copied over from PVE's ext6-pve.css file.
simply place it in the css subfolder where the proxmox-backup-gui.js
file is hosted and add a "css/" alias for that directory, the
formatter gets use the right content type with that.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-12-17 11:20:32 +01:00
Thomas Lamprecht
26fff0806a
handle_static_file_download: move from and_then to await
...
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-12-17 08:56:55 +01:00
Dietmar Maurer
3e2c83471a
api2: update for latest proxmox-api changes
...
- rename ApiFuture into ApiResponseFuture
- impl. ApiHandler::Async
2019-12-16 10:01:51 +01:00
Wolfgang Bumiller
9717c1b4eb
update a chunk of stuff to the hyper release
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-13 11:24:41 +01:00
Dietmar Maurer
51ea723de3
rename ApiHandler::Async into ApiHandler::AsyncHttp
2019-11-23 09:03:21 +01:00
Dietmar Maurer
764bdf54cf
src/server/rest.rs: simplify code
2019-11-22 18:44:14 +01:00
Dietmar Maurer
fe73df5be1
src/server/rest.rs: rename get_request_parameters_async to get_request_parameters
2019-11-22 17:24:16 +01:00
Dietmar Maurer
ac5b1c2805
src/server/rest.rs - only pass ObjectSchema to get_request_parameters_async()
2019-11-22 17:22:07 +01:00
Dietmar Maurer
b0e1e693d9
src/server/rest.rs: cleanup async code
2019-11-22 13:02:05 +01:00
Dietmar Maurer
4759ecac59
move src/api_schema/config.rs -> src/server/config.rs
2019-11-22 09:23:03 +01:00
Wolfgang Bumiller
ac21864dcf
api/compat: drop more compat imports from api_schema.rs
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-11-21 14:36:28 +01:00
Wolfgang Bumiller
13f6a30f52
api/compat: drop api_handler submodule
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-11-21 14:18:41 +01:00
Wolfgang Bumiller
92ffe68022
api: BoxFut -> ApiFuture
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-11-21 14:16:37 +01:00
Dietmar Maurer
3de9361d12
use const api definitions
2019-11-21 13:32:09 +01:00
Dietmar Maurer
40acfdf04c
avoid some clippy warnings
2019-10-26 11:42:05 +02:00
Dietmar Maurer
d26fde6986
avoid some clippy warnings
2019-10-25 18:44:51 +02:00
Wolfgang Bumiller
a19a6f1b37
src/server/rest.rs: use tokio::timer::delay
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-09-02 15:21:26 +02:00
Wolfgang Bumiller
df52ba5e45
src/server/rest.rs: switch to async
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-09-02 15:21:26 +02:00
Dietmar Maurer
0c3f5449d7
use new proxmox::tools::nodename
2019-08-03 17:06:23 +02:00
Dietmar Maurer
fd40d69ae0
src/server/rest.rs: avoid unwrap
2019-07-03 12:00:43 +02:00
Dietmar Maurer
4ca8acb083
src/server/rest.rs: log peer address, use hyper MakeService
2019-07-03 11:54:35 +02:00
Dietmar Maurer
206d63a20b
file download: avoid unnecessary copy
2019-06-28 07:07:52 +02:00
Wolfgang Bumiller
a99f7ec987
tree-wide: use 'dyn' for all trait objects
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-07 13:13:48 +02:00
Dietmar Maurer
e8a799cf06
src/server/rest.rs: correctly verify json parameters
2019-05-24 09:10:59 +02:00
Dietmar Maurer
4dd886d9a7
src/server/rest.rs: improve error handling
2019-05-23 08:15:32 +02:00
Dietmar Maurer
27c2183ef4
src/server/rest.rs: do not log 1xx status codes as errors
2019-05-14 06:23:22 +02:00
Dietmar Maurer
3bbbece6a2
handle_async_api_request: put rpcenv into a Box
...
So that we can pass rpcenv into futures.
2019-05-09 18:01:24 +02:00
Dietmar Maurer
5b91995837
src/server/formatter.rs: rename format_result to format_data
...
To avoid confusions with Rust Result type.
2019-05-09 13:15:15 +02:00
Dietmar Maurer
010e7b80a8
src/server/rest.rs: use generics to pass RpcEnvironment
2019-05-08 11:09:01 +02:00
Dietmar Maurer
19b33e55af
src/server/rest.rs: make handle_(a)sync_api_request public
2019-05-07 11:23:52 +02:00
Dietmar Maurer
e53d4dadaa
move normalize_path to tools::normalize_uri_path
2019-05-07 09:44:34 +02:00
Wolfgang Bumiller
e6bdfe0674
api_schema: allow generic api handler functions
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-04-16 11:22:23 +02:00
Dietmar Maurer
c76ceea941
src/server/rest.rs: use formatter to encode errors
2019-04-01 08:04:12 +02:00
Dietmar Maurer
24c023fe47
src/server/rest.rs: generate csrf token if we have a valid ticket
...
This is important if the user reloads the browser page.
2019-04-01 07:52:30 +02:00
Dietmar Maurer
022b626bc0
src/server/rest.rs: correctly extract content type
2019-03-19 12:50:15 +01:00
Dietmar Maurer
6dd8bfb84b
src/tools/ticket.rs: define const TICKET_LIFETIME
2019-03-05 12:56:21 +01:00
Dietmar Maurer
9b4e1de1c0
rc/server/rest.rs: allow to pass parameters as application/json
2019-02-27 12:37:53 +01:00
Wolfgang Bumiller
3dc99a5049
cleanup
...
Error::from is already a function taking 1 parameter,
there's no need to wrap it with `|e| Error::from(e)`.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-02-18 13:21:27 +01:00
Dietmar Maurer
435615a34a
src/server/rest.rs: correctly insert NoLogExtension()
2019-02-18 06:54:12 +01:00
Dietmar Maurer
bc6fa1684e
src/server/rest.rs: get_index() include username and CSRF token
...
When we have an valid ticket. Also delay get_index() if called with
an invalid ticket.
2019-02-17 19:28:32 +01:00
Dietmar Maurer
c4c7466024
src/server/rest.rs: factor our normalize_path()
2019-02-17 17:31:53 +01:00
Dietmar Maurer
fce8be6fe1
src/server/rest.rs: improve logs for unauthorized request
2019-02-17 17:18:44 +01:00
Dietmar Maurer
b1c1c468ee
improve api_schema module structure
2019-02-17 10:16:33 +01:00
Dietmar Maurer
304bfa59a8
rename src/api to src/api_schema
2019-02-17 09:59:20 +01:00
Dietmar Maurer
124b26b892
cleanup auth code, verify CSRF prevention token
2019-02-16 15:52:55 +01:00
Dietmar Maurer
1aff635a23
server/rest.rs: add method to log message
2019-02-15 10:16:12 +01:00
Dietmar Maurer
1314000db7
server/rest.rs: log full error messages
2019-02-15 09:55:12 +01:00
Dietmar Maurer
8daf9fd839
server/rest.rs: use a protocol extension to avoid double log
...
Instead of modifying the response header itself.
2019-02-14 16:04:24 +01:00
Dietmar Maurer
9bbd574fba
avoid double logging of proxied requests
2019-02-14 13:28:41 +01:00
Dietmar Maurer
e683d9ccb7
src/server/rest.rs: log failed requests
2019-02-14 13:07:34 +01:00
Dietmar Maurer
50ff21da59
src/client/http_client.rs: try to login
...
use an environment var to store passphrase (PBS_PASSWORD)
2019-02-13 14:31:43 +01:00
Wolfgang Bumiller
fe3b25029b
remove some rather inconvenient debug output
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-02-04 15:34:38 +01:00
Dietmar Maurer
9707fdadd7
implement relead_timezone flag
2019-02-01 10:04:46 +01:00
Dietmar Maurer
5d63509787
delay unauthorized request (rate limit)
2019-01-31 14:34:21 +01:00
Dietmar Maurer
8f75d998be
move http error class to router.rs
2019-01-31 13:22:30 +01:00
Dietmar Maurer
0ef7c190e1
server/rest.rs: verify auth cookie
2019-01-31 12:22:00 +01:00
Dietmar Maurer
200b5b87ea
Utils.js: fix cookie handling
...
Use unsecure cookie foör testing.
2019-01-31 10:08:08 +01:00
Dietmar Maurer
1701fd9bd4
api2/access.rs: add ticket api
2019-01-30 15:16:10 +01:00
Dietmar Maurer
c4f2b212c5
server/rest.rs: simplify proxy code
...
Only pass neccessary parameters.
2019-01-28 18:22:16 +01:00
Dietmar Maurer
8ec1299ab3
server/rest.rs: implement proxy_sync_api_request
2019-01-28 18:06:42 +01:00
Dietmar Maurer
1aa3b197a6
server/rest.rs: add proxy_sync_api_request() dummy
2019-01-28 17:30:39 +01:00
Dietmar Maurer
08e45e3573
src/bin/proxmox-backup-proxy.rs: implement unpriviledged server
...
We want to run the public server as user www-data. Requests needing
root priviledges needs to be proxied to the proxmox-backup.service, which
now listens to 127.0.0.1:82.
2019-01-28 13:29:58 +01:00
Dietmar Maurer
42e06fc5ca
RpcEnvironment: implement set_user() and get_user()
2019-01-27 10:52:26 +01:00
Dietmar Maurer
23db39488f
RpcEnvironment: add environment type enum RpcEnvironmentType
2019-01-27 10:33:42 +01:00
Dietmar Maurer
084ccdd590
also pass rpcenv to async handlers
2019-01-27 10:18:52 +01:00
Dietmar Maurer
a0a545c720
move rpc environment implementation to separate files
2019-01-26 15:08:02 +01:00
Dietmar Maurer
32f3db27bd
api: pass RpcEnvirnment to api handlers
2019-01-26 14:50:37 +01:00
Dietmar Maurer
b1be01218a
server/rest.rs: fake login cookie
2019-01-23 12:49:10 +01:00
Dietmar Maurer
c643065864
rename api3 back to api2
...
There is no real need to change the path, so using api2 we can reuse
all helpers (like tools from proxmox widget toolkit).
2019-01-22 12:10:38 +01:00
Dietmar Maurer
e35404deb7
remove crate tokio-codec (seems to be part of tokio now)
2019-01-20 14:28:06 +01:00
Dietmar Maurer
85722a8492
api/router.rs: rename ApiUploadMethod to ApiAsyncMethod
...
We can use this for uploads and downloads ...
2019-01-19 16:42:43 +01:00
Dietmar Maurer
6e219aefd3
api3/admin/datastore/upload_catar.rs: verify content type ("application/x-proxmox-backup-catar")
2019-01-17 12:43:29 +01:00
Dietmar Maurer
90e1d858e0
api/router.rs: return Result in upload handler
2019-01-17 12:03:38 +01:00
Dietmar Maurer
148b327e63
server/rest.rs: correctly pass query/url parameters
2019-01-16 13:58:36 +01:00