22import logging
33from itertools import chain
44from functools import wraps
5- from typing import Generator , Optional , List , Any
5+ from typing import Generator , Optional , List , Any , Union
66
77from base64 import b64encode , b64decode
88
3333OPTIONAL = 2
3434DISABLED = 3
3535
36+ # OID for the SPNEGO mechanism
37+ SPNEGO = gssapi .OID .from_int_seq ("1.3.6.1.5.5.2" )
38+
3639_find_auth = re .compile (r'Negotiate\s*([^,]*)' , re .I ).search
3740
3841
@@ -125,7 +128,9 @@ class HTTPSPNEGOAuth(Auth):
125128 Default is `None`.
126129
127130 `mech` is GSSAPI Mechanism (gssapi.Mechanism) to use for negotiation.
128- Default is `None`
131+ If explicitly given as ``None``, the underlying ``gssapi`` library will
132+ decide which negotiation mechanism to use.
133+ Default is `SPNEGO`.
129134
130135 `sanitize_mutual_error_response` controls whether we should clean up
131136 server responses. See the `SanitizedResponse` class.
@@ -138,7 +143,7 @@ def __init__(self,
138143 delegate : bool = False ,
139144 opportunistic_auth : bool = False ,
140145 creds : gssapi .Credentials = None ,
141- mech : bytes = None ,
146+ mech : Optional [ Union [ bytes , gssapi . OID ]] = SPNEGO ,
142147 sanitize_mutual_error_response : bool = True ):
143148 self .mutual_authentication = mutual_authentication
144149 self .target_name = target_name
0 commit comments