-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to use HTTPKerberosAuthentication fails using principal #188
Comments
I’m not aware of this library, or any of its dependencies, ever supporting a username and password in the principal kwarg. The code just passes the principal as is to the underlying libraries and they in turn use that to lookup the username. We do have a separate kwarg specifically for a password which you should be using. As for the non-domain joined Wjndows host, I’ve only ever got that to work with Kerberos auth by adding a realm mapping so SSPI knows how to contact a KDC for the requested realm. I’ve seen claims it works if DNS SRV lookups can work but I have never been able to see that happening. |
WinKerberos, which requests-kerberos used to rely on, supports username and password, allowing you to authenticate as a user different from the Windows logon user. |
In that case the password kwarg can do the same thing. It creates the |
In the current readme, and in the latest released version on pypi, no password argument is supported yet.
For testing I installed requests-kerberos from master now and used the password kwarg. >>> client.fetch_private_key_certificate_pair_for_device(id="100001211", environment=definition.Environment.DEV)
INFO:key_infrastructure.client:Fetch private key and certificate for device with id='100001211' valid -12h:20240617103655 (environment=<Environment.DEV: 'dev'>).
INFO:key_infrastructure.client:Fetch a fresh key infrastructure access token (environment=<Environment.DEV: 'dev'>, role='debug').
DEBUG:key_infrastructure.client:GET url='https://key.infrastructure.at/api/v1/dev/token/roles/debug'
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): key.infrastructure.at:443
DEBUG:urllib3.connectionpool:https://key.infrastructure.at:443 "GET /api/v1/dev/token/roles/debug HTTP/1.1" 401 381
DEBUG:requests_kerberos.kerberos_:handle_401(): Handling: 401
DEBUG:spnego._sspi:SSPI step input:
DEBUG:spnego._sspi:SSPI step output: <..hidden..>
DEBUG:requests_kerberos.kerberos_:authenticate_user(): Authorization header: Negotiate <..hidden..>
DEBUG:urllib3.connectionpool:https://key.infrastructure.at:443 "GET /api/v1/dev/token/roles/debug HTTP/1.1" 401 381
DEBUG:requests_kerberos.kerberos_:authenticate_user(): returning <Response [401]>
DEBUG:requests_kerberos.kerberos_:handle_401(): returning <Response [401]>
DEBUG:requests_kerberos.kerberos_:handle_response(): returning <Response [401]>
DEBUG:requests_kerberos.kerberos_:handle_response() has seen 0 401 responses
DEBUG:requests_kerberos.kerberos_:handle_401(): Handling: 401
DEBUG:requests_kerberos.kerberos_:handle_401(): Kerberos is not supported
DEBUG:requests_kerberos.kerberos_:handle_401(): returning <Response [401]>
DEBUG:requests_kerberos.kerberos_:handle_response(): returning <Response [401]>
DEBUG:requests_kerberos.kerberos_:handle_response() has seen 1 401 responses
DEBUG:requests_kerberos.kerberos_:handle_response(): returning 401 <Response [401]>
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\_workspace_\key_infrastructure\src\key_infrastructure\client.py", line 147, in fetch_private_key_certificate_pair_for_device
with _oki_session(environment, role) as oki_session:
File "C:\Python38\lib\contextlib.py", line 113, in __enter__
return next(self.gen)
File "C:\_workspace_\key_infrastructure\src\key_infrastructure\client.py", line 82, in _oki_session
header = _fetch_fresh_oki_access_token_for_header(environment, role, authentication)
File "C:\_workspace_\key_infrastructure\src\key_infrastructure\client.py", line 64, in _fetch_fresh_oki_access_token_for_header
access_token = _unpack_requests_response(response)["accessToken"]
File "C:\_workspace_\key_infrastructure\src\key_infrastructure\client.py", line 40, in _unpack_requests_response
response.raise_for_status()
File "C:\Users\HW0Mes00Local\AppData\Local\pypoetry\Cache\virtualenvs\key-infrastructure-FYt_TK8o-py3.8\lib\site-packages\requests\models.py", line 1024, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://key.infrastructure.at/api/v1/dev/token/roles/debug
>>> |
Looks like it's due for a new release and for the readme to be updated. The
The
Unfortunately you'll have to look into the logs of the service there. If we build a ticket and send it to the proper server then you'll have to find out why it rejected the ticket. |
#189 updates the README to fix up the incorrect password documentation. |
Thanks a lot, I got everything to run! 👍 🥳 |
On a non-domain joined machine, I try to fetch something from an API where I need Kerberos authentication.
The authentication is set as follows:
Using the correct username and password does not work on the non-domain joined machine.
I don't understand why this is not working. I assume that
requests_kerberos
is always using the credentials from Windows and the Kerberos ticket?My implementation works if the machine is domain-joined and a Kerberos ticket is available
or if I use the wrong username and password on the domain-joined machine.
The text was updated successfully, but these errors were encountered: