From 15442c6e1cee1bf4a59c980708ceea78480f063f Mon Sep 17 00:00:00 2001 From: James Robinson Date: Fri, 8 Mar 2024 14:59:47 +0000 Subject: [PATCH 1/4] :sparkles: Add debug option and pass this through to derived classes --- apricot/apricot_server.py | 4 ++++ apricot/ldap/oauth_ldap_server_factory.py | 4 +--- apricot/ldap/oauth_ldap_tree.py | 1 + apricot/ldap/read_only_ldap_server.py | 4 ++-- apricot/oauth/oauth_client.py | 2 ++ docker/entrypoint.sh | 4 ++++ run.py | 5 +++-- 7 files changed, 17 insertions(+), 7 deletions(-) diff --git a/apricot/apricot_server.py b/apricot/apricot_server.py index 863da98..7789566 100644 --- a/apricot/apricot_server.py +++ b/apricot/apricot_server.py @@ -19,10 +19,13 @@ def __init__( client_secret: str, domain: str, port: int, + debug: bool = False, redis_host: str | None = None, redis_port: int | None = None, **kwargs: Any, ) -> None: + self.debug = debug + # Log to stdout log.startLogging(sys.stdout) @@ -42,6 +45,7 @@ def __init__( oauth_client = OAuthClientMap[backend]( client_id=client_id, client_secret=client_secret, + debug=debug, domain=domain, uid_cache=uid_cache, **kwargs, diff --git a/apricot/ldap/oauth_ldap_server_factory.py b/apricot/ldap/oauth_ldap_server_factory.py index 333eda8..5b63fed 100644 --- a/apricot/ldap/oauth_ldap_server_factory.py +++ b/apricot/ldap/oauth_ldap_server_factory.py @@ -8,8 +8,6 @@ class OAuthLDAPServerFactory(ServerFactory): - protocol = ReadOnlyLDAPServer - def __init__(self, oauth_client: OAuthClient): """ Initialise an LDAPServerFactory @@ -31,6 +29,6 @@ def buildProtocol(self, addr: IAddress) -> Protocol: # noqa: N802 @param addr: an object implementing L{IAddress} """ id(addr) # ignore unused arguments - proto = self.protocol() + proto = ReadOnlyLDAPServer(self.adaptor.debug) proto.factory = self.adaptor return proto diff --git a/apricot/ldap/oauth_ldap_tree.py b/apricot/ldap/oauth_ldap_tree.py index 16243aa..b122498 100644 --- a/apricot/ldap/oauth_ldap_tree.py +++ b/apricot/ldap/oauth_ldap_tree.py @@ -21,6 +21,7 @@ def __init__(self, oauth_client: OAuthClient, refresh_interval: int = 60) -> Non @param oauth_client: An OAuth client used to construct the LDAP tree @param refresh_interval: Interval in seconds after which the tree must be refreshed """ + self.debug = oauth_client.debug self.last_update = time.monotonic() self.oauth_client: OAuthClient = oauth_client self.refresh_interval = refresh_interval diff --git a/apricot/ldap/read_only_ldap_server.py b/apricot/ldap/read_only_ldap_server.py index c590f94..f760e71 100644 --- a/apricot/ldap/read_only_ldap_server.py +++ b/apricot/ldap/read_only_ldap_server.py @@ -14,9 +14,9 @@ class ReadOnlyLDAPServer(LDAPServer): - def __init__(self) -> None: + def __init__(self, debug: bool = False) -> None: super().__init__() - self.debug = True + self.debug = debug def getRootDSE( # noqa: N802 self, diff --git a/apricot/oauth/oauth_client.py b/apricot/oauth/oauth_client.py index ce145d4..4aa5035 100644 --- a/apricot/oauth/oauth_client.py +++ b/apricot/oauth/oauth_client.py @@ -34,6 +34,7 @@ def __init__( self, client_id: str, client_secret: str, + debug: bool, domain: str, redirect_uri: str, scopes: list[str], @@ -43,6 +44,7 @@ def __init__( # Set attributes self.bearer_token_: str | None = None self.client_secret = client_secret + self.debug = debug self.domain = domain self.token_url = token_url self.uid_cache = uid_cache diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index ac54e27..8a21379 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -33,6 +33,10 @@ fi # Optional arguments EXTRA_OPTS="" +if [ -n "${DEBUG}" ]; then + EXTRA_OPTS="${EXTRA_OPTS} --debug" +fi + if [ -n "${ENTRA_TENANT_ID}" ]; then EXTRA_OPTS="${EXTRA_OPTS} --entra-tenant-id $ENTRA_TENANT_ID" fi diff --git a/run.py b/run.py index 67f28ed..5ac4230 100644 --- a/run.py +++ b/run.py @@ -12,10 +12,11 @@ ) # Common options needed for all backends parser.add_argument("-b", "--backend", type=OAuthBackend, help="Which OAuth backend to use.") - parser.add_argument("-i", "--client-id", type=str, help="OAuth client ID.") - parser.add_argument("-s", "--client-secret", type=str, help="OAuth client secret.") parser.add_argument("-d", "--domain", type=str, help="Which domain users belong to.") + parser.add_argument("-i", "--client-id", type=str, help="OAuth client ID.") parser.add_argument("-p", "--port", type=int, default=1389, help="Port to run on.") + parser.add_argument("-s", "--client-secret", type=str, help="OAuth client secret.") + parser.add_argument("--debug", action="store_true", help="Enable debug logging.") # Options for Microsoft Entra backend entra_group = parser.add_argument_group("Microsoft Entra") entra_group.add_argument("-t", "--entra-tenant-id", type=str, help="Microsoft Entra tenant ID.", required=False) From 210ee6bf42166461c640c2a99627f265eee1dd78 Mon Sep 17 00:00:00 2001 From: James Robinson Date: Fri, 8 Mar 2024 15:17:19 +0000 Subject: [PATCH 2/4] :loud_sound: Add debug messages --- apricot/apricot_server.py | 8 ++++++++ apricot/ldap/oauth_ldap_tree.py | 6 ++++++ apricot/ldap/read_only_ldap_server.py | 21 +++++++++++++++++++++ apricot/oauth/oauth_client.py | 8 ++++++++ 4 files changed, 43 insertions(+) diff --git a/apricot/apricot_server.py b/apricot/apricot_server.py index 7789566..b5115e5 100644 --- a/apricot/apricot_server.py +++ b/apricot/apricot_server.py @@ -42,6 +42,8 @@ def __init__( # Initialize the appropriate OAuth client try: + if self.debug: + log.msg(f"Creating an OAuthClient for {backend}.") oauth_client = OAuthClientMap[backend]( client_id=client_id, client_secret=client_secret, @@ -55,9 +57,13 @@ def __init__( raise ValueError(msg) from exc # Create an LDAPServerFactory + if self.debug: + log.msg(f"Creating an LDAPServerFactory.") factory = OAuthLDAPServerFactory(oauth_client) # Attach a listening endpoint + if self.debug: + log.msg(f"Attaching a listening endpoint.") endpoint: IStreamServerEndpoint = serverFromString(reactor, f"tcp:{port}") endpoint.listen(factory) @@ -66,4 +72,6 @@ def __init__( def run(self) -> None: """Start the Twisted reactor""" + if self.debug: + log.msg(f"Starting the Twisted reactor.") self.reactor.run() diff --git a/apricot/ldap/oauth_ldap_tree.py b/apricot/ldap/oauth_ldap_tree.py index b122498..8cf402d 100644 --- a/apricot/ldap/oauth_ldap_tree.py +++ b/apricot/ldap/oauth_ldap_tree.py @@ -53,9 +53,13 @@ def root(self) -> OAuthLDAPEntry: "OU=users", {"ou": ["users"], "objectClass": ["organizationalUnit"]} ) # Add groups to the groups OU + if self.debug: + log.msg("Adding groups to the LDAP tree.") for group_attrs in self.oauth_client.validated_groups(): groups_ou.add_child(f"CN={group_attrs.cn}", group_attrs.to_dict()) # Add users to the users OU + if self.debug: + log.msg("Adding users to the LDAP tree.") for user_attrs in self.oauth_client.validated_users(): users_ou.add_child(f"CN={user_attrs.cn}", user_attrs.to_dict()) # Set last updated time @@ -76,4 +80,6 @@ def lookup(self, dn: DistinguishedName | str) -> defer.Deferred[ILDAPEntry]: """ if not isinstance(dn, DistinguishedName): dn = DistinguishedName(stringValue=dn) + if self.debug: + log.msg(f"Starting an LDAP lookup for {dn.getText()}.") return self.root.lookup(dn) diff --git a/apricot/ldap/read_only_ldap_server.py b/apricot/ldap/read_only_ldap_server.py index f760e71..5b52db3 100644 --- a/apricot/ldap/read_only_ldap_server.py +++ b/apricot/ldap/read_only_ldap_server.py @@ -9,6 +9,7 @@ LDAPSearchResultEntry, ) from twisted.internet import defer +from twisted.python import log from apricot.oauth import LDAPControlTuple @@ -26,6 +27,8 @@ def getRootDSE( # noqa: N802 """ Handle an LDAP Root RSE request """ + if self.debug: + log.msg("Handling an LDAP Root RSE request") return super().getRootDSE(request, reply) def handle_LDAPAddRequest( # noqa: N802 @@ -37,6 +40,8 @@ def handle_LDAPAddRequest( # noqa: N802 """ Refuse to handle an LDAP add request """ + if self.debug: + log.msg("Handling an LDAP add request") id((request, controls, reply)) # ignore unused arguments msg = "ReadOnlyLDAPServer will not handle LDAP add requests" raise LDAPProtocolError(msg) @@ -50,6 +55,8 @@ def handle_LDAPBindRequest( # noqa: N802 """ Handle an LDAP bind request """ + if self.debug: + log.msg(f"Handling an LDAP bind request") return super().handle_LDAPBindRequest(request, controls, reply) def handle_LDAPCompareRequest( # noqa: N802 @@ -61,6 +68,8 @@ def handle_LDAPCompareRequest( # noqa: N802 """ Handle an LDAP compare request """ + if self.debug: + log.msg("Handling an LDAP compare request") return super().handle_LDAPCompareRequest(request, controls, reply) def handle_LDAPDelRequest( # noqa: N802 @@ -72,6 +81,8 @@ def handle_LDAPDelRequest( # noqa: N802 """ Refuse to handle an LDAP delete request """ + if self.debug: + log.msg("Handling an LDAP delete request") id((request, controls, reply)) # ignore unused arguments msg = "ReadOnlyLDAPServer will not handle LDAP delete requests" raise LDAPProtocolError(msg) @@ -85,6 +96,8 @@ def handle_LDAPExtendedRequest( # noqa: N802 """ Handle an LDAP extended request """ + if self.debug: + log.msg("Handling an LDAP extended request") return super().handle_LDAPExtendedRequest(request, controls, reply) def handle_LDAPModifyDNRequest( # noqa: N802 @@ -96,6 +109,8 @@ def handle_LDAPModifyDNRequest( # noqa: N802 """ Refuse to handle an LDAP modify DN request """ + if self.debug: + log.msg("Handling an LDAP modify DN request") id((request, controls, reply)) # ignore unused arguments msg = "ReadOnlyLDAPServer will not handle LDAP modify DN requests" raise LDAPProtocolError(msg) @@ -109,6 +124,8 @@ def handle_LDAPModifyRequest( # noqa: N802 """ Refuse to handle an LDAP modify request """ + if self.debug: + log.msg("Handling an LDAP modify request") id((request, controls, reply)) # ignore unused arguments msg = "ReadOnlyLDAPServer will not handle LDAP modify requests" raise LDAPProtocolError(msg) @@ -122,6 +139,8 @@ def handle_LDAPUnbindRequest( # noqa: N802 """ Handle an LDAP unbind request """ + if self.debug: + log.msg("Handling an LDAP unbind request") super().handle_LDAPUnbindRequest(request, controls, reply) def handle_LDAPSearchRequest( # noqa: N802 @@ -133,4 +152,6 @@ def handle_LDAPSearchRequest( # noqa: N802 """ Handle an LDAP search request """ + if self.debug: + log.msg("Handling an LDAP search request") return super().handle_LDAPSearchRequest(request, controls, reply) diff --git a/apricot/oauth/oauth_client.py b/apricot/oauth/oauth_client.py index 4aa5035..4bcca72 100644 --- a/apricot/oauth/oauth_client.py +++ b/apricot/oauth/oauth_client.py @@ -55,6 +55,8 @@ def __init__( try: # OAuth client that uses application credentials + if self.debug: + log.msg(f"Initialising application credential client.") self.session_application = OAuth2Session( client=BackendApplicationClient( client_id=client_id, scope=scopes, redirect_uri=redirect_uri @@ -66,6 +68,8 @@ def __init__( try: # OAuth client that uses delegated credentials + if self.debug: + log.msg(f"Initialising delegated credential client.") self.session_interactive = OAuth2Session( client=LegacyApplicationClient( client_id=client_id, scope=scopes, redirect_uri=redirect_uri @@ -147,6 +151,8 @@ def validated_groups(self) -> list[LDAPAttributeAdaptor]: """ Validate output via pydantic and return a list of LDAPAttributeAdaptor """ + if self.debug: + log.msg("Constructing and validating list of groups") output = [] # Add one self-titled group for each user user_group_dicts = [] @@ -182,6 +188,8 @@ def validated_users(self) -> list[LDAPAttributeAdaptor]: """ Validate output via pydantic and return a list of LDAPAttributeAdaptor """ + if self.debug: + log.msg("Constructing and validating list of users") output = [] for user_dict in self.users(): try: From 1363af40debe82a165ed302569090575049224a5 Mon Sep 17 00:00:00 2001 From: James Robinson Date: Fri, 8 Mar 2024 15:26:46 +0000 Subject: [PATCH 3/4] :loud_sound: Add debug messages to ReadOnlyLDAPServer handlers --- apricot/ldap/read_only_ldap_server.py | 69 +++++++++++++++------------ 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/apricot/ldap/read_only_ldap_server.py b/apricot/ldap/read_only_ldap_server.py index 5b52db3..7983bd7 100644 --- a/apricot/ldap/read_only_ldap_server.py +++ b/apricot/ldap/read_only_ldap_server.py @@ -4,9 +4,18 @@ from ldaptor.protocols.ldap.ldaperrors import LDAPProtocolError from ldaptor.protocols.ldap.ldapserver import LDAPServer from ldaptor.protocols.pureldap import ( + LDAPAddRequest, LDAPBindRequest, + LDAPCompareRequest, + LDAPDelRequest, + LDAPExtendedRequest, + LDAPModifyDNRequest, + LDAPModifyRequest, + LDAPProtocolRequest, + LDAPSearchRequest, LDAPSearchResultDone, LDAPSearchResultEntry, + LDAPUnbindRequest, ) from twisted.internet import defer from twisted.python import log @@ -21,19 +30,19 @@ def __init__(self, debug: bool = False) -> None: def getRootDSE( # noqa: N802 self, - request: LDAPBindRequest, + request: LDAPProtocolRequest, reply: Callable[[LDAPSearchResultEntry], None] | None, ) -> LDAPSearchResultDone: """ - Handle an LDAP Root RSE request + Handle an LDAP Root DSE request """ if self.debug: - log.msg("Handling an LDAP Root RSE request") + log.msg(f"Handling an LDAP Root DSE request.") return super().getRootDSE(request, reply) def handle_LDAPAddRequest( # noqa: N802 self, - request: LDAPBindRequest, + request: LDAPAddRequest, controls: list[LDAPControlTuple] | None, reply: Callable[..., None] | None, ) -> defer.Deferred[ILDAPEntry]: @@ -41,7 +50,7 @@ def handle_LDAPAddRequest( # noqa: N802 Refuse to handle an LDAP add request """ if self.debug: - log.msg("Handling an LDAP add request") + log.msg(f"Handling an LDAP add request.") id((request, controls, reply)) # ignore unused arguments msg = "ReadOnlyLDAPServer will not handle LDAP add requests" raise LDAPProtocolError(msg) @@ -56,12 +65,12 @@ def handle_LDAPBindRequest( # noqa: N802 Handle an LDAP bind request """ if self.debug: - log.msg(f"Handling an LDAP bind request") + log.msg(f"Handling an LDAP bind request.") return super().handle_LDAPBindRequest(request, controls, reply) def handle_LDAPCompareRequest( # noqa: N802 self, - request: LDAPBindRequest, + request: LDAPCompareRequest, controls: list[LDAPControlTuple] | None, reply: Callable[..., None] | None, ) -> defer.Deferred[ILDAPEntry]: @@ -69,12 +78,12 @@ def handle_LDAPCompareRequest( # noqa: N802 Handle an LDAP compare request """ if self.debug: - log.msg("Handling an LDAP compare request") + log.msg(f"Handling an LDAP compare request.") return super().handle_LDAPCompareRequest(request, controls, reply) def handle_LDAPDelRequest( # noqa: N802 self, - request: LDAPBindRequest, + request: LDAPDelRequest, controls: list[LDAPControlTuple] | None, reply: Callable[..., None] | None, ) -> defer.Deferred[ILDAPEntry]: @@ -82,14 +91,14 @@ def handle_LDAPDelRequest( # noqa: N802 Refuse to handle an LDAP delete request """ if self.debug: - log.msg("Handling an LDAP delete request") + log.msg(f"Handling an LDAP delete request.") id((request, controls, reply)) # ignore unused arguments msg = "ReadOnlyLDAPServer will not handle LDAP delete requests" raise LDAPProtocolError(msg) def handle_LDAPExtendedRequest( # noqa: N802 self, - request: LDAPBindRequest, + request: LDAPExtendedRequest, controls: list[LDAPControlTuple] | None, reply: Callable[..., None] | None, ) -> defer.Deferred[ILDAPEntry]: @@ -97,12 +106,12 @@ def handle_LDAPExtendedRequest( # noqa: N802 Handle an LDAP extended request """ if self.debug: - log.msg("Handling an LDAP extended request") + log.msg(f"Handling an LDAP extended request.") return super().handle_LDAPExtendedRequest(request, controls, reply) def handle_LDAPModifyDNRequest( # noqa: N802 self, - request: LDAPBindRequest, + request: LDAPModifyDNRequest, controls: list[LDAPControlTuple] | None, reply: Callable[..., None] | None, ) -> defer.Deferred[ILDAPEntry]: @@ -110,14 +119,14 @@ def handle_LDAPModifyDNRequest( # noqa: N802 Refuse to handle an LDAP modify DN request """ if self.debug: - log.msg("Handling an LDAP modify DN request") + log.msg(f"Handling an LDAP modify DN request.") id((request, controls, reply)) # ignore unused arguments msg = "ReadOnlyLDAPServer will not handle LDAP modify DN requests" raise LDAPProtocolError(msg) def handle_LDAPModifyRequest( # noqa: N802 self, - request: LDAPBindRequest, + request: LDAPModifyRequest, controls: list[LDAPControlTuple] | None, reply: Callable[..., None] | None, ) -> defer.Deferred[ILDAPEntry]: @@ -125,33 +134,33 @@ def handle_LDAPModifyRequest( # noqa: N802 Refuse to handle an LDAP modify request """ if self.debug: - log.msg("Handling an LDAP modify request") + log.msg(f"Handling an LDAP modify request.") id((request, controls, reply)) # ignore unused arguments msg = "ReadOnlyLDAPServer will not handle LDAP modify requests" raise LDAPProtocolError(msg) - def handle_LDAPUnbindRequest( # noqa: N802 + def handle_LDAPSearchRequest( # noqa: N802 self, - request: LDAPBindRequest, + request: LDAPSearchRequest, controls: list[LDAPControlTuple] | None, - reply: Callable[..., None] | None, - ) -> None: + reply: Callable[[LDAPSearchResultEntry], None] | None, + ) -> defer.Deferred[ILDAPEntry]: """ - Handle an LDAP unbind request + Handle an LDAP search request """ if self.debug: - log.msg("Handling an LDAP unbind request") - super().handle_LDAPUnbindRequest(request, controls, reply) + log.msg(f"Handling an LDAP search request.") + return super().handle_LDAPSearchRequest(request, controls, reply) - def handle_LDAPSearchRequest( # noqa: N802 + def handle_LDAPUnbindRequest( # noqa: N802 self, - request: LDAPBindRequest, + request: LDAPUnbindRequest, controls: list[LDAPControlTuple] | None, - reply: Callable[[LDAPSearchResultEntry], None] | None, - ) -> defer.Deferred[ILDAPEntry]: + reply: Callable[..., None] | None, + ) -> None: """ - Handle an LDAP search request + Handle an LDAP unbind request """ if self.debug: - log.msg("Handling an LDAP search request") - return super().handle_LDAPSearchRequest(request, controls, reply) + log.msg(f"Handling an LDAP unbind request.") + super().handle_LDAPUnbindRequest(request, controls, reply) From 776e06b3bb33f84dc6fe23f040069f926d6efcb8 Mon Sep 17 00:00:00 2001 From: James Robinson Date: Fri, 8 Mar 2024 15:29:33 +0000 Subject: [PATCH 4/4] :rotating_light: Minor linting fixes --- apricot/apricot_server.py | 7 ++++--- apricot/ldap/oauth_ldap_server_factory.py | 2 +- apricot/ldap/read_only_ldap_server.py | 22 +++++++++++----------- apricot/oauth/oauth_client.py | 6 +++--- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/apricot/apricot_server.py b/apricot/apricot_server.py index b5115e5..e67dc27 100644 --- a/apricot/apricot_server.py +++ b/apricot/apricot_server.py @@ -19,6 +19,7 @@ def __init__( client_secret: str, domain: str, port: int, + *, debug: bool = False, redis_host: str | None = None, redis_port: int | None = None, @@ -58,12 +59,12 @@ def __init__( # Create an LDAPServerFactory if self.debug: - log.msg(f"Creating an LDAPServerFactory.") + log.msg("Creating an LDAPServerFactory.") factory = OAuthLDAPServerFactory(oauth_client) # Attach a listening endpoint if self.debug: - log.msg(f"Attaching a listening endpoint.") + log.msg("Attaching a listening endpoint.") endpoint: IStreamServerEndpoint = serverFromString(reactor, f"tcp:{port}") endpoint.listen(factory) @@ -73,5 +74,5 @@ def __init__( def run(self) -> None: """Start the Twisted reactor""" if self.debug: - log.msg(f"Starting the Twisted reactor.") + log.msg("Starting the Twisted reactor.") self.reactor.run() diff --git a/apricot/ldap/oauth_ldap_server_factory.py b/apricot/ldap/oauth_ldap_server_factory.py index 5b63fed..d3c075a 100644 --- a/apricot/ldap/oauth_ldap_server_factory.py +++ b/apricot/ldap/oauth_ldap_server_factory.py @@ -29,6 +29,6 @@ def buildProtocol(self, addr: IAddress) -> Protocol: # noqa: N802 @param addr: an object implementing L{IAddress} """ id(addr) # ignore unused arguments - proto = ReadOnlyLDAPServer(self.adaptor.debug) + proto = ReadOnlyLDAPServer(debug=self.adaptor.debug) proto.factory = self.adaptor return proto diff --git a/apricot/ldap/read_only_ldap_server.py b/apricot/ldap/read_only_ldap_server.py index 7983bd7..3208141 100644 --- a/apricot/ldap/read_only_ldap_server.py +++ b/apricot/ldap/read_only_ldap_server.py @@ -24,7 +24,7 @@ class ReadOnlyLDAPServer(LDAPServer): - def __init__(self, debug: bool = False) -> None: + def __init__(self, *, debug: bool = False) -> None: super().__init__() self.debug = debug @@ -37,7 +37,7 @@ def getRootDSE( # noqa: N802 Handle an LDAP Root DSE request """ if self.debug: - log.msg(f"Handling an LDAP Root DSE request.") + log.msg("Handling an LDAP Root DSE request.") return super().getRootDSE(request, reply) def handle_LDAPAddRequest( # noqa: N802 @@ -50,7 +50,7 @@ def handle_LDAPAddRequest( # noqa: N802 Refuse to handle an LDAP add request """ if self.debug: - log.msg(f"Handling an LDAP add request.") + log.msg("Handling an LDAP add request.") id((request, controls, reply)) # ignore unused arguments msg = "ReadOnlyLDAPServer will not handle LDAP add requests" raise LDAPProtocolError(msg) @@ -65,7 +65,7 @@ def handle_LDAPBindRequest( # noqa: N802 Handle an LDAP bind request """ if self.debug: - log.msg(f"Handling an LDAP bind request.") + log.msg("Handling an LDAP bind request.") return super().handle_LDAPBindRequest(request, controls, reply) def handle_LDAPCompareRequest( # noqa: N802 @@ -78,7 +78,7 @@ def handle_LDAPCompareRequest( # noqa: N802 Handle an LDAP compare request """ if self.debug: - log.msg(f"Handling an LDAP compare request.") + log.msg("Handling an LDAP compare request.") return super().handle_LDAPCompareRequest(request, controls, reply) def handle_LDAPDelRequest( # noqa: N802 @@ -91,7 +91,7 @@ def handle_LDAPDelRequest( # noqa: N802 Refuse to handle an LDAP delete request """ if self.debug: - log.msg(f"Handling an LDAP delete request.") + log.msg("Handling an LDAP delete request.") id((request, controls, reply)) # ignore unused arguments msg = "ReadOnlyLDAPServer will not handle LDAP delete requests" raise LDAPProtocolError(msg) @@ -106,7 +106,7 @@ def handle_LDAPExtendedRequest( # noqa: N802 Handle an LDAP extended request """ if self.debug: - log.msg(f"Handling an LDAP extended request.") + log.msg("Handling an LDAP extended request.") return super().handle_LDAPExtendedRequest(request, controls, reply) def handle_LDAPModifyDNRequest( # noqa: N802 @@ -119,7 +119,7 @@ def handle_LDAPModifyDNRequest( # noqa: N802 Refuse to handle an LDAP modify DN request """ if self.debug: - log.msg(f"Handling an LDAP modify DN request.") + log.msg("Handling an LDAP modify DN request.") id((request, controls, reply)) # ignore unused arguments msg = "ReadOnlyLDAPServer will not handle LDAP modify DN requests" raise LDAPProtocolError(msg) @@ -134,7 +134,7 @@ def handle_LDAPModifyRequest( # noqa: N802 Refuse to handle an LDAP modify request """ if self.debug: - log.msg(f"Handling an LDAP modify request.") + log.msg("Handling an LDAP modify request.") id((request, controls, reply)) # ignore unused arguments msg = "ReadOnlyLDAPServer will not handle LDAP modify requests" raise LDAPProtocolError(msg) @@ -149,7 +149,7 @@ def handle_LDAPSearchRequest( # noqa: N802 Handle an LDAP search request """ if self.debug: - log.msg(f"Handling an LDAP search request.") + log.msg("Handling an LDAP search request.") return super().handle_LDAPSearchRequest(request, controls, reply) def handle_LDAPUnbindRequest( # noqa: N802 @@ -162,5 +162,5 @@ def handle_LDAPUnbindRequest( # noqa: N802 Handle an LDAP unbind request """ if self.debug: - log.msg(f"Handling an LDAP unbind request.") + log.msg("Handling an LDAP unbind request.") super().handle_LDAPUnbindRequest(request, controls, reply) diff --git a/apricot/oauth/oauth_client.py b/apricot/oauth/oauth_client.py index 4bcca72..05c5719 100644 --- a/apricot/oauth/oauth_client.py +++ b/apricot/oauth/oauth_client.py @@ -34,7 +34,7 @@ def __init__( self, client_id: str, client_secret: str, - debug: bool, + debug: bool, # noqa: FBT001 domain: str, redirect_uri: str, scopes: list[str], @@ -56,7 +56,7 @@ def __init__( try: # OAuth client that uses application credentials if self.debug: - log.msg(f"Initialising application credential client.") + log.msg("Initialising application credential client.") self.session_application = OAuth2Session( client=BackendApplicationClient( client_id=client_id, scope=scopes, redirect_uri=redirect_uri @@ -69,7 +69,7 @@ def __init__( try: # OAuth client that uses delegated credentials if self.debug: - log.msg(f"Initialising delegated credential client.") + log.msg("Initialising delegated credential client.") self.session_interactive = OAuth2Session( client=LegacyApplicationClient( client_id=client_id, scope=scopes, redirect_uri=redirect_uri