diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2018-11-04 11:33:55 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2018-11-04 11:33:55 +0000 |
commit | 1e32c8cd3db78d2494dc30b08ac2fe23a2247f6c (patch) | |
tree | aa0dead705c7fefa4a5ca212eaf6f0e267eea8ad | |
parent | cef783d1432efc5594c2d9ad39e6749b1c4e95d9 (diff) | |
download | netsurf-test-1e32c8cd3db78d2494dc30b08ac2fe23a2247f6c.tar.gz netsurf-test-1e32c8cd3db78d2494dc30b08ac2fe23a2247f6c.tar.bz2 |
Support changing realm
-rwxr-xr-x | cgi-bin/auth.cgi | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/cgi-bin/auth.cgi b/cgi-bin/auth.cgi index 83210d8..7f7aa71 100755 --- a/cgi-bin/auth.cgi +++ b/cgi-bin/auth.cgi @@ -4,23 +4,23 @@ import cgi import cgitb cgitb.enable() -print('WWW-Authenticate: Basic realm="NetSurf Authentication test"') -print('Content-Type: text/plain') -print('') - import os from base64 import b64decode auth = os.getenv("HTTP_AUTHORIZATION") -query = os.getenv("QUERY_STRING") or "user=foo&pass=bar" +query = os.getenv("QUERY_STRING") or "user=foo&pass=bar&realm=NetSurf+Authentication+Test" query = cgi.parse_qs(query) username = query.get("user", ["foo"])[0] password = query.get("pass", query.get("password", ["bar"]))[0] +realm = query.get("realm", ["NetSurf Authentication Test"]) gotuser = None gotpass = None def badauth(reason="NOAUTH"): + print('WWW-Authenticate: Basic realm="{}"'.format(realm)) + print('Content-Type: text/plain') + print('') print('result=BAD, username={}/{}, password={}/{}, reason={}'.format(gotuser, username, gotpass, password, reason)) raise SystemExit @@ -42,4 +42,6 @@ else: badauth("BADPASS") +print('Content-Type: text/plain') +print('') print("result=GOOD, username={}, password={}".format(username, password)) |