Skip to content
Advertisement

“TypeError: argument 1 must be str, not None” when running Flask-Kerberos

I am trying to run the Flask-Kerberos example with a valid keytab file (it works with WSGI-Kerberos).

Here is the content of my ‘example.py’ file

JavaScript

here is a ‘config.py’

JavaScript

and here is a ‘.flaskenv’

JavaScript

However, when start the Flask via flask run I am getting the following error in CMD:

JavaScript

And I have seen some related topics (were not helpful):

Advertisement

Answer

I started with brutally integrating the Flask-Kerberos code directly into my ‘example.py’ file and using some print()s:

JavaScript

As was mentioned in this answer:

The problem is exactly as the error message states – you’ve told the kerberos library to get a service principal from the keytab, but the keytab doesn’t contain an entry for that service principal.

So, I decided to check several variables and their values, i.e. _SERVICE_NAME and getServerPrincipalDetails(service, hostname).

Firstly I set the _SERVICE_NAME='L.S.D' and after I got the ‘Forbidden’ response in my Browser. And here is an output in the CMD:

JavaScript

I run the the above code via Vim I received this message:

JavaScript

This issue brought me further to this issue on the GitHub. Where author stated:

Nevermind, regardless of how I interpret the code it works fine with service=”HTTP” and hostname=”my.host.name”.

Therefore, I tried to adjust service and hostname variables of the getServerPrincipalDetails(service, hostname) function. The most convenient way for me to test it was:

JavaScript

So, I ended up with the following variables and their values

JavaScript

And after I got the response in Browser

Flask Kerberos Example

It worked, I think you are username@L.S.D.

and in CMD correspondingly

JavaScript

Unfortunatelly it still does not work via flask run. It was asked as a new question here: Flask-Kerberos yields different results when running the code via “flask run” and with Vim

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement