From 70be07d3a076bf53e2d9795062dcb29a399ceea2 Mon Sep 17 00:00:00 2001 From: Julian Rother <julian@jrother.eu> Date: Thu, 29 Jul 2021 00:21:47 +0200 Subject: [PATCH] Fixed docs --- docs/api.rst | 77 +++++++++++++++++++++++--------------------- docs/conf.py | 2 +- ldapserver/server.py | 29 ++++++++--------- 3 files changed, 55 insertions(+), 53 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index a9dbb1d..fb9d587 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -33,51 +33,54 @@ LDAP Protocol .. autoclass:: ldapserver.ldap.FilterEqual .. autoclass:: ldapserver.ldap.FilterPresent +.. autoclass:: ldapserver.ldap.LDAPMessage + :members: + LDAP Errors ----------- LDAP response messages carry a result code and an optional diagnostic message. -The subclasses of :any:`ldapserver.LDAPError` represent the possible (non-success) result codes. +The subclasses of :any:`ldapserver.exceptions.LDAPError` represent the possible (non-success) result codes. -Raising a :any:`ldapserver.LDAPError` instance in a handler method of +Raising a :any:`ldapserver.exceptions.LDAPError` instance in a handler method of :any:`ldapserver.BaseLDAPRequestHandler` cases the appropriate response message to be sent with the corresponding result code and diagnostic message. -.. autoexception:: ldapserver.LDAPError -.. autoexception:: ldapserver.LDAPOperationsError -.. autoexception:: ldapserver.LDAPProtocolError -.. autoexception:: ldapserver.LDAPTimeLimitExceeded -.. autoexception:: ldapserver.LDAPSizeLimitExceeded -.. autoexception:: ldapserver.LDAPAuthMethodNotSupported -.. autoexception:: ldapserver.LDAPStrongerAuthRequired -.. autoexception:: ldapserver.LDAPAdminLimitExceeded -.. autoexception:: ldapserver.LDAPUnavailableCriticalExtension -.. autoexception:: ldapserver.LDAPConfidentialityRequired -.. autoexception:: ldapserver.LDAPNoSuchAttribute -.. autoexception:: ldapserver.LDAPUndefinedAttributeType -.. autoexception:: ldapserver.LDAPInappropriateMatching -.. autoexception:: ldapserver.LDAPConstraintViolation -.. autoexception:: ldapserver.LDAPAttributeOrValueExists -.. autoexception:: ldapserver.LDAPInvalidAttributeSyntax -.. autoexception:: ldapserver.LDAPNoSuchObject -.. autoexception:: ldapserver.LDAPAliasProblem -.. autoexception:: ldapserver.LDAPInvalidDNSyntax -.. autoexception:: ldapserver.LDAPAliasDereferencingProblem -.. autoexception:: ldapserver.LDAPInappropriateAuthentication -.. autoexception:: ldapserver.LDAPInvalidCredentials -.. autoexception:: ldapserver.LDAPInsufficientAccessRights -.. autoexception:: ldapserver.LDAPBusy -.. autoexception:: ldapserver.LDAPUnavailable -.. autoexception:: ldapserver.LDAPUnwillingToPerform -.. autoexception:: ldapserver.LDAPLoopDetect -.. autoexception:: ldapserver.LDAPNamingViolation -.. autoexception:: ldapserver.LDAPObjectClassViolation -.. autoexception:: ldapserver.LDAPNotAllowedOnNonLeaf -.. autoexception:: ldapserver.LDAPNotAllowedOnRDN -.. autoexception:: ldapserver.LDAPEntryAlreadyExists -.. autoexception:: ldapserver.LDAPObjectClassModsProhibited -.. autoexception:: ldapserver.LDAPAffectsMultipleDSAs -.. autoexception:: ldapserver.LDAPOther +.. autoexception:: ldapserver.exceptions.LDAPError +.. autoexception:: ldapserver.exceptions.LDAPOperationsError +.. autoexception:: ldapserver.exceptions.LDAPProtocolError +.. autoexception:: ldapserver.exceptions.LDAPTimeLimitExceeded +.. autoexception:: ldapserver.exceptions.LDAPSizeLimitExceeded +.. autoexception:: ldapserver.exceptions.LDAPAuthMethodNotSupported +.. autoexception:: ldapserver.exceptions.LDAPStrongerAuthRequired +.. autoexception:: ldapserver.exceptions.LDAPAdminLimitExceeded +.. autoexception:: ldapserver.exceptions.LDAPUnavailableCriticalExtension +.. autoexception:: ldapserver.exceptions.LDAPConfidentialityRequired +.. autoexception:: ldapserver.exceptions.LDAPNoSuchAttribute +.. autoexception:: ldapserver.exceptions.LDAPUndefinedAttributeType +.. autoexception:: ldapserver.exceptions.LDAPInappropriateMatching +.. autoexception:: ldapserver.exceptions.LDAPConstraintViolation +.. autoexception:: ldapserver.exceptions.LDAPAttributeOrValueExists +.. autoexception:: ldapserver.exceptions.LDAPInvalidAttributeSyntax +.. autoexception:: ldapserver.exceptions.LDAPNoSuchObject +.. autoexception:: ldapserver.exceptions.LDAPAliasProblem +.. autoexception:: ldapserver.exceptions.LDAPInvalidDNSyntax +.. autoexception:: ldapserver.exceptions.LDAPAliasDereferencingProblem +.. autoexception:: ldapserver.exceptions.LDAPInappropriateAuthentication +.. autoexception:: ldapserver.exceptions.LDAPInvalidCredentials +.. autoexception:: ldapserver.exceptions.LDAPInsufficientAccessRights +.. autoexception:: ldapserver.exceptions.LDAPBusy +.. autoexception:: ldapserver.exceptions.LDAPUnavailable +.. autoexception:: ldapserver.exceptions.LDAPUnwillingToPerform +.. autoexception:: ldapserver.exceptions.LDAPLoopDetect +.. autoexception:: ldapserver.exceptions.LDAPNamingViolation +.. autoexception:: ldapserver.exceptions.LDAPObjectClassViolation +.. autoexception:: ldapserver.exceptions.LDAPNotAllowedOnNonLeaf +.. autoexception:: ldapserver.exceptions.LDAPNotAllowedOnRDN +.. autoexception:: ldapserver.exceptions.LDAPEntryAlreadyExists +.. autoexception:: ldapserver.exceptions.LDAPObjectClassModsProhibited +.. autoexception:: ldapserver.exceptions.LDAPAffectsMultipleDSAs +.. autoexception:: ldapserver.exceptions.LDAPOther Indices and tables ------------------ diff --git a/docs/conf.py b/docs/conf.py index 392be5d..1463acf 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,7 +12,7 @@ # import os import sys -sys.path.insert(0, os.path.abspath('../src')) +sys.path.insert(0, os.path.abspath('..')) # -- Project information ----------------------------------------------------- diff --git a/ldapserver/server.py b/ldapserver/server.py index a4f6853..9c34280 100644 --- a/ldapserver/server.py +++ b/ldapserver/server.py @@ -43,13 +43,11 @@ class BaseLDAPRequestHandler(socketserver.BaseRequestHandler): self.on_disconnect() self.request.close() - def handle_message(self, shallowmsg: ldap.ShallowLDAPMessage) -> typing.Iterable[ldap.ProtocolOp]: - '''Handle an LDAP request + def handle_message(self, shallowmsg: ldap.ShallowLDAPMessage) -> typing.Iterable[ldap.LDAPMessage]: + '''Handle an LDAP request foobar :param shallowmsg: Half-decoded LDAP message to handle - :type shallowmsg: ShallowLDAPMessage :returns: Response messages - :rtype: iterable of LDAPMessage objects ''' msgtypes = { ldap.BindRequest: (self.handle_bind, ldap.BindResponse), @@ -107,6 +105,7 @@ class BaseLDAPRequestHandler(socketserver.BaseRequestHandler): traceback.print_exc() def handle_bind(self, op: ldap.BindRequest, controls=None) -> typing.Iterable[ldap.ProtocolOp]: + '''Handle bind bla bla bla''' reject_critical_controls(controls) raise exceptions.LDAPAuthMethodNotSupported() @@ -149,7 +148,7 @@ class SimpleLDAPRequestHandler(BaseLDAPRequestHandler): ''' .. py:attribute:: rootdse - Special single-object :any:`BaseDirectory` that contains information + Special single-object :any:`directory.BaseDirectory` that contains information about the server, such as supported extentions and SASL authentication mechansims. Attributes can be accessed in a dict-like fashion. ''' @@ -158,11 +157,11 @@ class SimpleLDAPRequestHandler(BaseLDAPRequestHandler): ''' .. py:attribute:: subschema - Special single-object :any:`BaseDirectory` that describes the schema. + Special single-object :any:`directory.BaseDirectory` that describes the schema. Per default the subschema includes standard syntaxes, standard matching rules and objectclasses/attributetypes for the rootdse and subschema. It does not include objectclasses/attributetypes for actual data - (e.g. users and groups). See :any:`Subschema` for details. + (e.g. users and groups). See :any:`directory.Subschema` for details. If `subschema` is not `None`, the subschemaSubentry attribute is automatically added to all results returned by :any:`do_search`. @@ -277,7 +276,7 @@ class SimpleLDAPRequestHandler(BaseLDAPRequestHandler): def do_bind_simple_anonymous(self): '''Do LDAP BIND with simple anonymous authentication (`RFC 4513 5.1.1.`_) - :raises LDAPError: if authentication failed + :raises exceptions.LDAPError: if authentication failed :returns: Bind object on success :rtype: obj @@ -291,7 +290,7 @@ class SimpleLDAPRequestHandler(BaseLDAPRequestHandler): :param dn: Distinguished name of the object to be authenticated :type dn: str - :raises LDAPError: if authentication failed + :raises exceptions.LDAPError: if authentication failed :returns: Bind object on success :rtype: obj @@ -308,7 +307,7 @@ class SimpleLDAPRequestHandler(BaseLDAPRequestHandler): :param password: Password for object :type dn: bytes - :raises LDAPError: if authentication failed + :raises exceptions.LDAPError: if authentication failed :returns: Bind object on success :rtype: obj @@ -332,7 +331,7 @@ class SimpleLDAPRequestHandler(BaseLDAPRequestHandler): :rtype: Tuple (obj, bytes/None) The call only returns if authentication succeeded. In any other case, - an appropriate :any:`LDAPError` is raised. + an appropriate :any:`exceptions.LDAPError` is raised. Some SASL methods require additional challenge-response round trips. These can be achieved with the `yield` statement: @@ -373,7 +372,7 @@ class SimpleLDAPRequestHandler(BaseLDAPRequestHandler): opaque string that does not contain the '@' character :type trace_info: str, optional - :raises LDAPError: if authentication failed + :raises exceptions.LDAPError: if authentication failed :returns: Bind object on success :rtype: obj @@ -394,7 +393,7 @@ class SimpleLDAPRequestHandler(BaseLDAPRequestHandler): :param authzid: Authorization identity :type authzid: str, optional - :raises LDAPError: if authentication failed + :raises exceptions.LDAPError: if authentication failed :returns: Bind object on success :rtype: obj @@ -411,7 +410,7 @@ class SimpleLDAPRequestHandler(BaseLDAPRequestHandler): :param authzid: Authorization identity :type authzid: str, optional - :raises LDAPError: if authentication failed + :raises exceptions.LDAPError: if authentication failed :returns: Bind object on success :rtype: obj @@ -442,7 +441,7 @@ class SimpleLDAPRequestHandler(BaseLDAPRequestHandler): :param filterobj: Filter object :type filterobj: Filter - :raises LDAPError: on error + :raises exceptions.LDAPError: on error :returns: Iterable of dn, attributes tuples -- GitLab