xpra icon
Bug tracker and wiki

Ticket #1488: sql-auth-stub.patch

File sql-auth-stub.patch, 2.8 KB (added by Antoine Martin, 20 months ago)

stub for sql auth

  • xpra/server/auth/sql_auth.py

     
     1# This file is part of Xpra.
     2# Copyright (C) 2017 Antoine Martin <antoine@devloop.org.uk>
     3# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
     4# later version. See the file COPYING for details.
     5
     6import sys
     7from xpra.server.auth.sys_auth_base import SysAuthenticator, init, log
     8assert init and log #tests will disable logging from here
     9
     10
     11class Authenticator(SysAuthenticator):
     12
     13    def __init__(self, username, **kwargs):
     14        SysAuthenticator.__init__(self, username)
     15        self.db_name = kwargs.get("db_name", "xpra.sdb")
     16        self.password_query = kwargs.get("password_query", "SELECT password FROM users WHERE username=(?)")
     17        self.sessions_query = kwargs.get("sessions_query", "SELECT .. ")
     18        self.authenticate = self.authenticate_hmac
     19
     20    def __repr__(self):
     21        return "sql"
     22
     23    def get_password(self):
     24        #look up in database here
     25        return None
     26
     27    def get_sessions(self):
     28        #look up in database here
     29        return []
     30
     31
     32def main():
     33    def usage(msg="invalid number of arguments"):
     34        print(msg)
     35        print("usage: %s create|..." % sys.argv[0])
     36        return 1
     37    from xpra.platform import program_context
     38    with program_context("SQL Auth", "SQL Auth"):
     39        if len(sys.argv)!=2:
     40            return usage()
     41        cmd = sys.argv[1]
     42        if cmd=="create":
     43            #create the schema or something
     44            pass
     45        else:
     46            return usage("invalid command '%s'" % cmd)
     47    return 0
     48
     49if __name__ == "__main__":
     50    r = main()
     51    sys.exit(r)
  • xpra/server/server_core.py

     
    299299            else:
    300300                auth = "pam"
    301301            authlog("will try to use sys auth module '%s' for %s", auth, sys.platform)
    302         from xpra.server.auth import fail_auth, reject_auth, allow_auth, none_auth, file_auth, multifile_auth, password_auth, env_auth
     302        from xpra.server.auth import fail_auth, reject_auth, allow_auth, none_auth, file_auth, multifile_auth, password_auth, env_auth, sql_auth
    303303        AUTH_MODULES = {
    304304                        "fail"      : fail_auth,
    305305                        "reject"    : reject_auth,
     
    309309                        "password"  : password_auth,
    310310                        "multifile" : multifile_auth,
    311311                        "file"      : file_auth,
     312                        "sql"       : sql_auth,
    312313                        }
    313314        try:
    314315            from xpra.server.auth import pam_auth