diff options
author | mkaay <mkaay@mkaay.de> | 2011-02-05 14:19:22 +0100 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2011-02-05 14:19:22 +0100 |
commit | 7c332ae610f7feca193ba50ea900f5a417681a7b (patch) | |
tree | e71f1ba6b8eb52f13c11289069d65288b17a111c /module/remote | |
parent | py 2.5 fix -> removed import (diff) | |
download | pyload-7c332ae610f7feca193ba50ea900f5a417681a7b.tar.xz |
created unified authentication system (same data for webinterface an GUI/CLI, multiple accounts)
Diffstat (limited to 'module/remote')
-rw-r--r-- | module/remote/RemoteManager.py | 8 | ||||
-rw-r--r-- | module/remote/XMLRPCBackend.py | 7 |
2 files changed, 10 insertions, 5 deletions
diff --git a/module/remote/RemoteManager.py b/module/remote/RemoteManager.py index bc40ea124..fbc7bc5f1 100644 --- a/module/remote/RemoteManager.py +++ b/module/remote/RemoteManager.py @@ -42,6 +42,9 @@ class BackendBase(Thread): def serve(self): pass + + def checkAuth(self, user, password, remoteip=None): + return self.manager.checkAuth(user, password, remoteip) class RemoteManager(): available = ("XMLRPCBackend", ) @@ -65,4 +68,7 @@ class RemoteManager(): else: backend.start() self.backends.append(backend) - + def checkAuth(self, user, password, remoteip=None): + if self.core.config["remote"]["nolocalauth"] and remoteip == "127.0.0.1": + return True + return self.core.db.checkAuth(user, password) diff --git a/module/remote/XMLRPCBackend.py b/module/remote/XMLRPCBackend.py index d5f72034e..08803df23 100644 --- a/module/remote/XMLRPCBackend.py +++ b/module/remote/XMLRPCBackend.py @@ -23,17 +23,16 @@ from module.remote.RemoteManager import BackendBase class XMLRPCBackend(BackendBase): def setup(self): server_addr = (self.core.config['remote']['listenaddr'], int(self.core.config['remote']['port'])) - usermap = {self.core.config.username: self.core.config.password} if self.core.config['ssl']['activated']: if exists(self.core.config['ssl']['cert']) and exists(self.core.config['ssl']['key']): self.core.log.info(_("Using SSL XMLRPCBackend")) self.server = Server.SecureXMLRPCServer(server_addr, self.core.config['ssl']['cert'], - self.core.config['ssl']['key'], usermap) + self.core.config['ssl']['key'], self.checkAuth) else: self.core.log.warning(_("SSL Certificates not found, fallback to auth XMLRPC server")) - self.server = Server.AuthXMLRPCServer(server_addr, usermap) + self.server = Server.AuthXMLRPCServer(server_addr, self.checkAuth) else: - self.server = Server.AuthXMLRPCServer(server_addr, usermap) + self.server = Server.AuthXMLRPCServer(server_addr, self.checkAuth) self.server.register_instance(self.core.server_methods) |