summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2017-07-02 16:19:16 +0200
committerJo-Philipp Wich <jo@mein.io>2017-07-02 16:19:16 +0200
commitad93be7632963da1bd5b67d71021d1d63ecfd909 (patch)
treeab35e6e73dbf619c8cb683a95b080db37fb8ef13 /file.c
parentfa51d7fbc67aa27b423c50c77b817514de6def09 (diff)
auth: store parsed username and password
Store the parsed username and password information as HTTP headers in the clients header blob buffer for later use by proc.c Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'file.c')
-rw-r--r--file.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/file.c b/file.c
index 047b4da..e20071b 100644
--- a/file.c
+++ b/file.c
@@ -795,6 +795,7 @@ static bool __handle_file_request(struct client *cl, char *url)
struct dispatch_handler *d;
struct blob_attr *tb[__HDR_MAX];
struct path_info *pi;
+ char *user, *pass;
pi = uh_path_lookup(cl, url);
if (!pi)
@@ -804,11 +805,15 @@ static bool __handle_file_request(struct client *cl, char *url)
return true;
blobmsg_parse(hdr_policy, __HDR_MAX, tb, blob_data(cl->hdr.head), blob_len(cl->hdr.head));
- if (tb[HDR_AUTHORIZATION])
- pi->auth = blobmsg_data(tb[HDR_AUTHORIZATION]);
+ if (tb[HDR_AUTHORIZATION]) {
+ if (!uh_auth_check(cl, pi->name, blobmsg_data(tb[HDR_AUTHORIZATION]), &user, &pass))
+ return true;
- if (!uh_auth_check(cl, pi))
- return true;
+ if (user && pass) {
+ blobmsg_add_string(&cl->hdr, "http-auth-user", user);
+ blobmsg_add_string(&cl->hdr, "http-auth-pass", pass);
+ }
+ }
d = dispatch_find(url, pi);
if (d)