Flask/Python decoding username NTLM or Negotiate Authentication Header -
i have flask app hosted in iis in our intranet. in flask, i'm able www-authenticate header, need determine windows username. did have basic authentication enabled , able parse out username via method, want transparent user. in ie have option set auto login intranet sites they're not prompted username , password.
i able string can either begin ntlm or negotiate (depending on setting in iis) , long auth string. reliable way can decode in python/flask?
got it.
class remoteusermiddleware(object): def __init__(self, app): self.app = app def __call__(self, environ, start_response): user = environ.pop('http_x_proxy_remote_user', none) environ['remote_user'] = user return self.app(environ, start_response) app.wsgi_app = remoteusermiddleware(app.wsgi_app)
then in view doing this:
username = str(request.environ.get('logon_user'))
Comments
Post a Comment