From 5c429e15bd552a8e1523e080115715bcc8e19b22 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Mon, 9 Jan 2017 19:34:01 -0500 Subject: [PATCH] remove authjsonrpc subhandlers. we dont use them --- lbrynet/core/Error.py | 4 ---- lbrynet/lbrynet_daemon/auth/server.py | 31 +-------------------------- 2 files changed, 1 insertion(+), 34 deletions(-) diff --git a/lbrynet/core/Error.py b/lbrynet/core/Error.py index 91bf48dcc..36e20151a 100644 --- a/lbrynet/core/Error.py +++ b/lbrynet/core/Error.py @@ -96,9 +96,5 @@ class InvalidAuthenticationToken(Exception): pass -class SubhandlerError(Exception): - pass - - class NegotiationError(Exception): pass diff --git a/lbrynet/lbrynet_daemon/auth/server.py b/lbrynet/lbrynet_daemon/auth/server.py index abbee374f..f7513a458 100644 --- a/lbrynet/lbrynet_daemon/auth/server.py +++ b/lbrynet/lbrynet_daemon/auth/server.py @@ -8,7 +8,7 @@ from twisted.internet import defer from twisted.python.failure import Failure from txjsonrpc import jsonrpclib -from lbrynet.core.Error import InvalidAuthenticationToken, InvalidHeaderError, SubhandlerError +from lbrynet.core.Error import InvalidAuthenticationToken, InvalidHeaderError from lbrynet import conf from lbrynet.lbrynet_daemon.auth.util import APIKey, get_auth_message from lbrynet.lbrynet_daemon.auth.client import LBRY_SECRET @@ -36,7 +36,6 @@ class JSONRPCException(Exception): class AuthorizedBase(object): def __init__(self): self.authorized_functions = [] - self.subhandlers = [] self.callable_methods = {} for methodname in dir(self): @@ -45,21 +44,12 @@ class AuthorizedBase(object): self.callable_methods.update({methodname.split("jsonrpc_")[1]: method}) if hasattr(method, '_auth_required'): self.authorized_functions.append(methodname.split("jsonrpc_")[1]) - elif not methodname.startswith("__"): - method = getattr(self, methodname) - if hasattr(method, '_subhandler'): - self.subhandlers.append(method) @staticmethod def auth_required(f): f._auth_required = True return f - @staticmethod - def subhandler(f): - f._subhandler = True - return f - class AuthJSONRPCServer(AuthorizedBase): """Authorized JSONRPC server used as the base class for the LBRY API @@ -71,12 +61,6 @@ class AuthJSONRPCServer(AuthorizedBase): @AuthJSONRPCServer.auth_required: this requires the client include a valid hmac authentication token in their request - @AuthJSONRPCServer.subhandler: include the tagged method in - the processing of requests, to allow inheriting classes to - modify request handling. Tagged methods will be passed the - request object, and return True when finished to indicate - success - Attributes: allowed_during_startup (list): list of api methods that are callable before the server has finished startup @@ -86,8 +70,6 @@ class AuthJSONRPCServer(AuthorizedBase): authorized_functions (list): list of api methods that require authentication - subhandlers (list): list of subhandlers - callable_methods (dict): dictionary of api_callable_name: method values """ @@ -159,12 +141,6 @@ class AuthJSONRPCServer(AuthorizedBase): token = parsed.pop('hmac', None) version = self._get_jsonrpc_version(parsed.get('jsonrpc'), id_) - try: - self._run_subhandlers(request) - except SubhandlerError as err: - self._render_error(err, request, id_, version) - return server.NOT_DONE_YET - reply_with_next_secret = False if self._use_authentication: if function_name in self.authorized_functions: @@ -302,11 +278,6 @@ class AuthJSONRPCServer(AuthorizedBase): version_for_return = jsonrpclib.VERSION_PRE1 return version_for_return - def _run_subhandlers(self, request): - for handler in self.subhandlers: - if not handler(request): - raise SubhandlerError("Subhandler error processing request: %s", request) - def _callback_render(self, result, request, id_, version, auth_required=False): result_for_return = result if not isinstance(result, dict) else result['result']