Skip to content

Commit

Permalink
Update tutorial to make server_name equal FQDN
Browse files Browse the repository at this point in the history
The introduction shows the differences between NameTypes and
accidentally uses a hardcoded value for server_name, which is a variable
that is used to make calls later in the code. By changing server_name to
a FQDN, this variable will work for anybody using the tutorial.
  • Loading branch information
rebeccc committed Jun 4, 2020
1 parent 99ee548 commit e53ffdc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/source/basic-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ Suppose we wanted to refer to an HTTP server on the current host.
We could refer to it as a *host-based service*, or in the default
mechanism form (in this case, for krb5):

>>> server_hostbased_name = gssapi.Name('HTTP@' + FQDN, name_type=gssapi.NameType.hostbased_service)
>>> server_hostbased_name = gssapi.Name(f"HTTP@{FQDN}", name_type=gssapi.NameType.hostbased_service)
>>> server_hostbased_name
Name(b'HTTP@sross', <OID 1.2.840.113554.1.2.1.4>)
>>> server_name = gssapi.Name('HTTP/sross@')
Name(b'HTTP@seton.mivehind.net', <OID 1.2.840.113554.1.2.1.4>)
>>> server_name = gssapi.Name(f"HTTP/{FQDN}@")
>>> server_name
Name(b'HTTP/sross@', None)
Name(b'HTTP/seton.mivehind.net@', None)
>>>

These are both effectively the same, but if we *canonicalize* both
Expand Down Expand Up @@ -80,7 +80,7 @@ to acquire credentials as such:

>>> REALM.addprinc('HTTP/%s@%s' % (FQDN, REALM.realm))
>>> REALM.extract_keytab('HTTP/%s@%s' % (FQDN, REALM.realm), REALM.keytab)
>>> server_creds = gssapi.Credentials(usage='accept', name=server_name)
>>> server_creds = gssapi.Credentials(usage='accept', name=server_hostbased_name)
>>>

Note that for the krb5 mechanism, in order to acquire credentials with
Expand All @@ -100,7 +100,7 @@ credentials are usable:

>>> server_creds.usage
'accept'
>>> server_creds.name == server_name
>>> server_creds.name == server_hostbased_name
True
>>> server_creds.lifetime is None
True
Expand All @@ -125,7 +125,7 @@ When establishing a security context, the default credentials are
used unless otherwise specified. This allows applications to use
the user's already acquired credentials:

>>> client_ctx = gssapi.SecurityContext(name=server_name, usage='initiate')
>>> client_ctx = gssapi.SecurityContext(name=server_hostbased_name, usage='initiate')
>>> initial_client_token = client_ctx.step()
>>> client_ctx.complete
False
Expand Down

0 comments on commit e53ffdc

Please sign in to comment.