diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2016-07-09 22:39:20 +0200 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2016-07-09 22:39:20 +0200 |
commit | 311a02c31e03b23cc66e662cce63e6c19d4bc662 (patch) | |
tree | 051bf90b1a9d8c584d7f03dcd7788c0c914d96f3 /server.py | |
parent | 045f9bc3b68f03d88b9623a0893eeca3ff1ff372 (diff) | |
download | auth-xmppmessage-311a02c31e03b23cc66e662cce63e6c19d4bc662.tar.gz auth-xmppmessage-311a02c31e03b23cc66e662cce63e6c19d4bc662.zip |
re-request credentials after sending token and use threading mixin
Diffstat (limited to 'server.py')
-rwxr-xr-x | server.py | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -6,6 +6,7 @@ import argparse import functions import logging from http.server import BaseHTTPRequestHandler, HTTPServer +from socketserver import ThreadingMixIn logging.basicConfig(level=logging.INFO) @@ -21,6 +22,10 @@ def send_token(conf, username, orig_uri): functions.send_message(conf.jid, conf.password, username, message) +class ThreadingSimpleServer(ThreadingMixIn, HTTPServer): + pass + + class RequestHandler(BaseHTTPRequestHandler): def do_GET(self): global LAST_REQUEST_TIME, CACHE @@ -38,6 +43,7 @@ class RequestHandler(BaseHTTPRequestHandler): LAST_REQUEST_TIME = time.time() send_token(conf, username, self.headers['X-Original-URI']) self.send_response(401, "Token sent, retry") + self.send_header("WWW-Authenticate", "Basic realm=\"xmppmessage auth\"") else: self.send_response(429, 'Too Many Requests') else: @@ -47,7 +53,7 @@ class RequestHandler(BaseHTTPRequestHandler): self.send_response(200, "OK go forward") else: logging.info("Denied %s", username) - self.send_response(401, "Authentication failed, username or password wrong") + self.send_response(403, "Authentication failed, username or password wrong") else: self.send_response(401) self.send_header("WWW-Authenticate", "Basic realm=\"xmppmessage auth\"") |