From 41de3e7457aae2483e7b95a70011f7393ae7b32f Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Wed, 13 Jul 2022 10:12:49 -0400 Subject: [PATCH] #3575 add capability authentication --- xpra/server/auth/capability_auth.py | 38 +++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 xpra/server/auth/capability_auth.py diff --git a/xpra/server/auth/capability_auth.py b/xpra/server/auth/capability_auth.py new file mode 100644 index 0000000000..b375deab2f --- /dev/null +++ b/xpra/server/auth/capability_auth.py @@ -0,0 +1,38 @@ +# This file is part of Xpra. +# Copyright (C) 2022 Antoine Martin +# Xpra is released under the terms of the GNU GPL v2, or, at your option, any +# later version. See the file COPYING for details. + +from xpra.server.auth.sys_auth_base import SysAuthenticator, log +from xpra.util import typedict, ellipsizer + + +class Authenticator(SysAuthenticator): + + def __init__(self, **kwargs): + log("capability.Authenticator(%s)", kwargs) + self.uid = -1 + self.gid = -1 + self.property = kwargs.pop("property", "display") + self.value = kwargs.pop("value", "") + #connection = kwargs.get("connection", None) + super().__init__(**kwargs) + + def get_uid(self): + return self.uid + + def get_gid(self): + return self.gid + + + def requires_challenge(self): + return False + + def authenticate(self, caps : typedict) -> bool: #pylint: disable=arguments-differ + value = caps.strget(self.property, None) + log("capability.authenticate(..) %r=%r (value required: %r", + self.property, value, self.value) + return value==self.value + + def __repr__(self): + return "capability"