[Pkg-debile-commits] [debile-master] 82/126: fixing auth to allow user auth
Sylvestre Ledru
sylvestre at alioth.debian.org
Mon Aug 19 14:56:19 UTC 2013
This is an automated email from the git hooks/post-receive script.
sylvestre pushed a commit to branch scan-build-html
in repository debile-master.
commit 7cb2a4a3699f6973aa96fba18393ed3c0b1b65da
Author: Paul Tagliamonte <tag at pault.ag>
Date: Tue Jun 11 22:07:31 2013 -0400
fixing auth to allow user auth
---
lucy/models/user.py | 6 +++++-
lucy/server.py | 25 +++++++++++++++++++++++--
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/lucy/models/user.py b/lucy/models/user.py
index f2e2afe..b939353 100644
--- a/lucy/models/user.py
+++ b/lucy/models/user.py
@@ -4,8 +4,9 @@ from lucy.models import LucyObject
class User(LucyObject):
_type = 'users'
- def __init__(self, _id, name, email, gpg, **kwargs):
+ def __init__(self, _id, auth, name, email, gpg, **kwargs):
super(User, self).__init__(_id=_id,
+ auth=auth,
gpg=gpg,
name=name,
email=email,
@@ -23,4 +24,7 @@ class User(LucyObject):
from lucy import Source
return Source.get_uploads_for_user(self['_id'])
+ def auth(self, auth):
+ return self['auth'] == auth
+
get_by_uid = LucyObject.load
diff --git a/lucy/server.py b/lucy/server.py
index 99e38f3..c898de0 100644
--- a/lucy/server.py
+++ b/lucy/server.py
@@ -147,22 +147,43 @@ class LucyInterface(object):
def get_builder_id():
+ if NAMESPACE.machine is None:
+ raise KeyError("What the shit, doing something you can't do")
return NAMESPACE.machine['_id']
+def get_user_id():
+ if NAMESPACE.user is None:
+ raise KeyError("What the shit, doing something you can't do")
+ return NAMESPACE.user['_id']
+
+
class LucyAuthMixIn(SimpleXMLRPCRequestHandler):
def authenticate(self):
+ NAMESPACE.machine = None
+ NAMESPACE.user = None
(basic, _, encoded) = self.headers.get('Authorization').partition(' ')
if basic.lower() != 'basic':
self.send_error(401, 'Only allowed basic type thing')
+ entity, password = b64decode(encoded.encode()).decode().split(":", 1)
+
+ if self.authenticate_machine(entity, password):
+ return True
+ return self.authenticate_user()
- machine, password = b64decode(encoded.encode()).decode().split(":", 1)
+ def authenticate_user(self, user, password):
+ user = User.load(user)
+ if user.auth(password):
+ NAMESPACE.user = user
+ return True
+ return False
+
+ def authenticate_machine(self, machine, password):
machine = Machine.load(machine)
if machine.auth(password):
NAMESPACE.machine = machine
machine.ping()
return True
- NAMESPACE.machine = None
return False
def parse_request(self, *args):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-debile/debile-master.git
More information about the Pkg-debile-commits
mailing list