After going through all the questions left as comment by @user1686:
Does your keytab have the correct service principal name? Does your
client system have Kerberos tickets for the user? (Does it have the
initial 'krbtgt' ticket, and did it also obtain a ticket for your web
app's SPN?)
it was observed that the keytab file had a wrong (arcfour-hmac is deprecated) encryption type.
A new keytab file using the aes256-cts-hmac-sha1-96 enctype was generated again and now it looks like:
KVNO Timestamp Principal
---- ------------------- --------------------------------------------------
5 01/01/1970 01:00:00 HTTP/TestServer.l.s.d@L.S.D (aes256-cts-hmac-sha1-96)
Thereafter it was again tested and on this stage I got the following error:
a.b.c.d - - [16/Jun/2021 14:11:30] "GET / HTTP/1.1" 401 12
a.b.c.d - - [16/Jun/2021 14:11:30] "GET / HTTP/1.1" 200 0
Traceback (most recent call last):
File "/usr/lib/python3.7/wsgiref/handlers.py", line 138, in run
self.finish_response()
File "/usr/lib/python3.7/wsgiref/handlers.py", line 180, in finish_response
self.write(data)
File "/usr/lib/python3.7/wsgiref/handlers.py", line 266, in write
"write() argument must be a bytes instance"
AssertionError: write() argument must be a bytes instance
a.b.c.d - - [16/Jun/2021 14:11:30] "GET / HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('10.169.43.210', 58080)
Traceback (most recent call last):
File "/usr/lib/python3.7/wsgiref/handlers.py", line 138, in run
self.finish_response()
File "/usr/lib/python3.7/wsgiref/handlers.py", line 180, in finish_response
self.write(data)
File "/usr/lib/python3.7/wsgiref/handlers.py", line 266, in write
"write() argument must be a bytes instance"
AssertionError: write() argument must be a bytes instance
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.7/wsgiref/handlers.py", line 141, in run
self.handle_error()
File "/usr/lib/python3.7/wsgiref/handlers.py", line 368, in handle_error
self.finish_response()
File "/usr/lib/python3.7/wsgiref/handlers.py", line 180, in finish_response
self.write(data)
File "/usr/lib/python3.7/wsgiref/handlers.py", line 274, in write
self.send_headers()
File "/usr/lib/python3.7/wsgiref/handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "/usr/lib/python3.7/wsgiref/handlers.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.7/socketserver.py", line 316, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python3.7/socketserver.py", line 347, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python3.7/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python3.7/socketserver.py", line 720, in __init__
self.handle()
File "/usr/lib/python3.7/wsgiref/simple_server.py", line 133, in handle
handler.run(self.server.get_app())
File "/usr/lib/python3.7/wsgiref/handlers.py", line 144, in run
self.close()
File "/usr/lib/python3.7/wsgiref/simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
----------------------------------------
a.b.c.d - - [16/Jun/2021 14:11:30] "GET / HTTP/1.1" 403 9
In the error I found out, that:
AssertionError: write() argument must be a bytes instance
thereafter it led me to this thread argument must be a bytes instance WSGI Python3.
And then the content of the code was appropriately edited:
from wsgiref.simple_server import make_server
from wsgi_kerberos import KerberosAuthMiddleware
def example(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
response_body = 'Hello, %s!' % environ['REMOTE_USER']
return [response_body.encode()]
if __name__ == '__main__':
app = KerberosAuthMiddleware(example)
http = make_server('0.0.0.0', 5000, app)
http.serve_forever()
And now I can this in my Browser:
Hello, username@L.S.D!
where username
is my username in the Windows System.
References: