aboutsummaryrefslogtreecommitdiff
path: root/auth.h
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-03-06 05:09:56 +0100
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-03-06 05:51:49 +0100
commitff8da797a143cb1dfbeb4ce2d2c3e4a1d0c2e56a (patch)
treec51bbbd084f531d11ba765186cc5d39709e40ba3 /auth.h
parent804b8841f3fe59f7058c91fa25c1694f4433642a (diff)
downloadslcl-ff8da797a143cb1dfbeb4ce2d2c3e4a1d0c2e56a.tar.gz
Implement user quota
This feature allows admins to set a specific quota for each user, in MiB. This feature is particularly useful for shared instances, where unlimited user storage might be unfeasible or even dangerous for the server. Also, a nice HTML5 <progress> element has been added to the site that shows how much of the quota has been consumed. If no quota is set, slcl falls back to the default behaviour i.e., assume unlimited storage. Limitations: - While HTTP does specify a Content-Length, which determines the length of the whole request, it does not specify how many files are involved or their individual sizes. - Because of this, if multiple files are uploaded simultaneously, the whole request would be dropped if user quota is exceeded, even if not all files exceeded it. - Also, Content-Length adds the length of some HTTP boilerplate (e.g.: boundaries), but slcl must rely on this before accepting the whole request. In other words, this means some requests might be rejected by slcl because of the extra bytes caused by such boilerplate. - When the quota is exceeded, slcl must close the connection so that the rest of the transfer is cancelled. Unfortunately, this means no HTML can be sent back to the customer to inform about the situation.
Diffstat (limited to 'auth.h')
-rw-r--r--auth.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/auth.h b/auth.h
index a4145aa..ad46585 100644
--- a/auth.h
+++ b/auth.h
@@ -2,6 +2,7 @@
#define AUTH_H
#include "http.h"
+#include <stdbool.h>
struct auth *auth_alloc(const char *dir);
void auth_free(struct auth *a);
@@ -9,5 +10,7 @@ int auth_cookie(const struct auth *a, const struct http_cookie *c);
int auth_login(const struct auth *a, const char *user, const char *password,
char **cookie);
const char *auth_dir(const struct auth *a);
+int auth_quota(const struct auth *a, const char *user, bool *available,
+ unsigned long long *quota);
#endif /* AUTH_H */