Skip to content

Commit

Permalink
Tidy up NTLM error messages and update changelog (#84)
Browse files Browse the repository at this point in the history
This also updates the integration tests to include Python 3.12 and an
explicit tests for gMSA password encoding.
  • Loading branch information
jborean93 authored Jun 12, 2024
1 parent fc93d03 commit b1c8fd1
Show file tree
Hide file tree
Showing 7 changed files with 332 additions and 95 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Changelog

## 0.10.3 - TBD
## 0.11.0 - TBD

* Support input password string encoded with the `surrogatepass` error option
* This allows the caller to provide a password for a gMSA or machine account that could contain invalid surrogate pairs for both NTLM and Kerberos auth.
* Stop using deprecated `datetime.dateime.utcnow()` for CredSSP acceptor context
* Treat an empty string as a valid password, `None` is kept as use the cached credential
* Improve the exception shown when no password was provided and no cached credential was available

## 0.10.2 - 2023-10-04

Expand Down
8 changes: 5 additions & 3 deletions src/spnego/_ntlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ def _get_credential(
https://asecuritysite.com/encryption/lmhash
"""
if not store:
raise OperationNotAvailableError(context_msg="Retrieving NTLM store without NTLM_USER_FILE set to a filepath")
raise OperationNotAvailableError(
context_msg="No username or password was specified and the credential cache did not exist or contained no credentials"
)

domain = domain or ""

Expand Down Expand Up @@ -178,7 +180,7 @@ def store_lines(
else:
raise SpnegoError(
ErrorCode.failure,
context_msg="Failed to find any matching credential in " "NTLM_USER_FILE credential store.",
context_msg="Failed to find any matching credential in NTLM_USER_FILE credential store.",
)


Expand Down Expand Up @@ -306,7 +308,7 @@ def __init__(
# Make sure that the credential file is set and exists
if not _get_credential_file():
raise OperationNotAvailableError(
context_msg="Retrieving NTLM store without NTLM_USER_FILE set to a " "filepath"
context_msg="NTLM acceptor requires NTLM credential cache to be provided through the env var NTLM_USER_FILE set to a filepath"
)

self._temp_negotiate: typing.Optional[Negotiate] = None
Expand Down
2 changes: 1 addition & 1 deletion src/spnego/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright: (c) 2020, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)

__version__ = "0.10.3"
__version__ = "0.11.0"
3 changes: 3 additions & 0 deletions tests/integration/inventory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ all:
- C:\Program Files (x86)\Python310-32
- C:\Program Files\Python311
- C:\Program Files (x86)\Python311-32
- C:\Program Files\Python312
- C:\Program Files (x86)\Python312-32
python_venv_path: C:\temp\venv
krb_provider: SSPI

Expand Down Expand Up @@ -65,3 +67,4 @@ all:
domain_username: spnego
domain_password: Password01
domain_upn: '{{ domain_username }}@{{ domain_name | upper }}'
gmsa_username: MyGMSA
Loading

0 comments on commit b1c8fd1

Please # to comment.