Skip to content

Commit d2c90c4

Browse files
aiudirogfrozencemetery
authored andcommitted
Don't limit contexts to single server name
Previously, the Name was stored the first time the request header was generated. This locked the user into using only a single host, defeating the purpose of storing the contexts on a hostname basis. Fix this by not storing the Name object. [[email protected]: commit message, updated docstr for target_name] Merges: #23
1 parent 04b3530 commit d2c90c4

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Diff for: requests_gssapi/gssapi_.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ class HTTPSPNEGOAuth(AuthBase):
8787
(default).
8888
8989
`target_name` specifies the remote principal name. It may be either a
90-
GSSAPI name type or a string (default: "HTTP" at the DNS host).
90+
GSSAPI Name type or a string. If a string, it will be treated as a
91+
hostbased service; if it contains no '@', the DNS host will be supplied.
92+
(default: "HTTP" at the DNS host).
9193
9294
`delegate` indicates whether we should attempt credential delegation.
9395
Default is `False`.
@@ -135,14 +137,14 @@ def generate_request_header(self, response, host, is_preemptive=False):
135137

136138
try:
137139
gss_stage = "initiating context"
138-
if type(self.target_name) != gssapi.Name:
139-
if '@' not in self.target_name:
140-
self.target_name = "%s@%s" % (self.target_name, host)
140+
name = self.target_name
141+
if type(name) != gssapi.Name:
142+
if '@' not in name:
143+
name = "%s@%s" % (name, host)
141144

142-
self.target_name = gssapi.Name(
143-
self.target_name, gssapi.NameType.hostbased_service)
145+
name = gssapi.Name(name, gssapi.NameType.hostbased_service)
144146
self.context[host] = gssapi.SecurityContext(
145-
usage="initiate", flags=gssflags, name=self.target_name,
147+
usage="initiate", flags=gssflags, name=name,
146148
creds=self.creds, mech=self.mech)
147149

148150
gss_stage = "stepping context"

0 commit comments

Comments
 (0)