summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-05-26 18:19:28 +0200
committerRoland Reichwein <mail@reichwein.it>2020-05-26 18:19:28 +0200
commitf1f4cbd996aa00b6e4d3d04d0223d02fd553dd96 (patch)
treece1f0e00047af87ad4d526580fafc334a0bb7797
parent817d21e30c8d9c17cef41c4b8920dd8004fad1f6 (diff)
Fix Authorization (WIP)
-rw-r--r--response.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/response.cpp b/response.cpp
index 67cb322..5f4f3f2 100644
--- a/response.cpp
+++ b/response.cpp
@@ -248,14 +248,14 @@ response_type generate_response(request_type& req, Server& server)
if (auth.size() != 0) {
std::string authorization{req[http::field::authorization]};
if (authorization.substr(0, 6) != "Basic "s)
- return HttpStatusAndStats("400", "Bad Authorization Type", req_ctx, res);
+ return HttpStatusAndStats("401", "Bad Authorization Type", req_ctx, res);
authorization = authorization.substr(6);
authorization = decode64(authorization);
size_t pos {authorization.find(':')};
if (pos == authorization.npos)
- return HttpStatusAndStats("400", "Bad Authorization Encoding", req_ctx, res);
+ return HttpStatusAndStats("401", "Bad Authorization Encoding", req_ctx, res);
std::string login{authorization.substr(0, pos)};
std::string password{authorization.substr(pos + 1)};
@@ -268,7 +268,7 @@ response_type generate_response(request_type& req, Server& server)
// For now, WWW-Authenticate: Basic realm="..." will only be generated for static-files.
// All other plugins are expected to present their own login pages
if (req_ctx.GetPluginName() == "static-files")
- res.set(http::field::www_authenticate, "Basic realm=\"Webbox Login\"");
+ res.set(http::field::www_authenticate, "Basic realm=\"Reichwein.IT Webserver Login\"");
return HttpStatusAndStats("401", "Bad Authorization", req_ctx, res);
}