diff --git a/warden3/warden_server/warden_server.py b/warden3/warden_server/warden_server.py index 5b4c01cb2e8124eb222a5d9ee969f559e3d7fb4f..322ea1315f5530eaf6f1f3bad4bb62d9037818f1 100755 --- a/warden3/warden_server/warden_server.py +++ b/warden3/warden_server/warden_server.py @@ -279,8 +279,21 @@ class NoAuthenticator(ObjectReq): ObjectReq.__init__(self, req) - def authenticate (self, env, args): - return "anybody" # or None + def shash(self, s): + """ Simple FNV1 hash for creating ids on the fly """ + res = 2166136261 + for c in s: + res = 0xFFFFFFFF & res * 16777619 ^ ord(c) + return res + + + def authenticate(self, env, args): + name = args.get("client", [None])[0] + if name is None: + logging.error("NoAuthenticator: clients must authenticate by name, not secret") + return None + + return Client(self.shash(name), None, None, None, name, None, 1, None, 1, 1, 1, 0) def authorize(self, env, client, path, method): @@ -336,8 +349,8 @@ class X509Authenticator(NoAuthenticator): name, secret, str(cert_names))) return None - # Clients with 'secret' set muset get authorized by it. - # No secret turns auth off for this particular client. + # Clients with 'secret' set must get authenticated by it. + # No secret turns secret auth off for this particular client. if client.secret is not None and secret is None: logging.info("authenticate: missing secret argument") return None