Skip to content

Commit a4238ed

Browse files
committed
Use credentials for kerberos auth
1 parent 29306d9 commit a4238ed

File tree

1 file changed

+20
-27
lines changed

1 file changed

+20
-27
lines changed

neo4j/api.py

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,20 @@
6363
class Auth:
6464
""" Container for auth details.
6565
66-
:param scheme: specifies the type of authentication, examples: "basic", "kerberos"
66+
:param scheme: specifies the type of authentication, examples: "basic",
67+
"kerberos"
6768
:type scheme: str
6869
:param principal: specifies who is being authenticated
6970
:type principal: str or None
7071
:param credentials: authenticates the principal
7172
:type credentials: str or None
7273
:param realm: specifies the authentication provider
7374
:type realm: str or None
74-
:param parameters: extra key word parameters passed along to the authentication provider
75+
:param parameters: extra key word parameters passed along to the
76+
authentication provider
7577
:type parameters: Dict[str, Any]
7678
"""
7779

78-
# TODO in 5.0: change signature to
79-
# def __init__(self, scheme, principal=None, credentials=None,
80-
# ticket=None, realm=None, **parameters):
8180
def __init__(self, scheme, principal, credentials, realm=None, **parameters):
8281
self.scheme = scheme
8382
# Neo4j servers pre 4.4 require the principal field to always be
@@ -86,12 +85,6 @@ def __init__(self, scheme, principal, credentials, realm=None, **parameters):
8685
self.principal = principal
8786
if credentials:
8887
self.credentials = credentials
89-
# TODO in 5.0: add ticket
90-
# :param ticket: alternative to authenticate the principal (depends on
91-
# scheme)
92-
# :type ticket: str or None
93-
# if ticket is not None:
94-
# self.ticket = ticket
9588
if realm:
9689
self.realm = realm
9790
if parameters:
@@ -107,9 +100,12 @@ def basic_auth(user, password, realm=None):
107100
108101
This will set the scheme to "basic" for the auth token.
109102
110-
:param user: user name, this will set the principal
103+
:param user: user name, this will set the
104+
:type user: stro
111105
:param password: current password, this will set the credentials
106+
:type password: stro
112107
:param realm: specifies the authentication provider
108+
:type realm: str or None
113109
114110
:return: auth token for use with :meth:`GraphDatabase.driver`
115111
:rtype: :class:`neo4j.Auth`
@@ -122,15 +118,14 @@ def kerberos_auth(base64_encoded_ticket):
122118
123119
This will set the scheme to "kerberos" for the auth token.
124120
125-
:param base64_encoded_ticket: a base64 encoded service ticket, this will set the credentials
121+
:param base64_encoded_ticket: a base64 encoded service ticket, this will set
122+
the credentials
123+
:type base64_encoded_ticket: str
126124
127125
:return: auth token for use with :meth:`GraphDatabase.driver`
128126
:rtype: :class:`neo4j.Auth`
129127
"""
130-
token = Auth("kerberos", "", None)
131-
# token field is not supported by any other auth scheme. So we inject it.
132-
token.ticket = base64_encoded_ticket
133-
return token
128+
return Auth("kerberos", "", base64_encoded_ticket)
134129

135130

136131
def bearer_auth(base64_encoded_token):
@@ -140,6 +135,7 @@ def bearer_auth(base64_encoded_token):
140135
141136
:param base64_encoded_token: a base64 encoded authentication token generated
142137
by a Single-Sign-On provider.
138+
:type base64_encoded_token: str
143139
144140
:return: auth token for use with :meth:`GraphDatabase.driver`
145141
:rtype: :class:`neo4j.Auth`
@@ -151,25 +147,22 @@ def custom_auth(principal, credentials, realm, scheme, **parameters):
151147
""" Generate a custom auth token.
152148
153149
:param principal: specifies who is being authenticated
150+
:type principal: str or None
154151
:param credentials: authenticates the principal
152+
:type credentials: str or None
155153
:param realm: specifies the authentication provider
154+
:type realm: str or None
156155
:param scheme: specifies the type of authentication
157-
:param parameters: extra key word parameters passed along to the authentication provider
156+
:type scheme: str or None
157+
:param parameters: extra key word parameters passed along to the
158+
authentication provider
159+
:type parameters: Dict[str, Any]
158160
159161
:return: auth token for use with :meth:`GraphDatabase.driver`
160162
:rtype: :class:`neo4j.Auth`
161163
"""
162164
return Auth(scheme, principal, credentials, realm, **parameters)
163165

164-
# TODO in 5.0: alter custom_auth to
165-
# def custom_auth(principal, credentials, ticket, realm, scheme, **parameters):
166-
# """...
167-
# :param ticket: alternative to authenticate the principal (depends on
168-
# scheme)
169-
# ..."""
170-
# return Auth(scheme, principal=principal, credentials=credentials,
171-
# ticket=ticket, realm=realm, **parameter
172-
173166

174167
class Bookmark:
175168
"""A Bookmark object contains an immutable list of bookmark string values.

0 commit comments

Comments
 (0)