Add the ability to login with a robot, use the wrench icon for robots all over the place.

This commit is contained in:
yackob03 2013-11-20 19:43:19 -05:00
parent b407c1d9fb
commit e69591c7d6
8 changed files with 46 additions and 15 deletions

View file

@ -48,6 +48,20 @@ def process_basic_auth(auth):
except model.DataModelException:
logger.debug('Invalid token: %s' % credentials[1])
elif '+' in credentials[0]:
logger.debug('Trying robot auth with credentials %s' % str(credentials))
# Use as robot auth
try:
robot = model.verify_robot(credentials[0], credentials[1])
logger.debug('Successfully validated robot: %s' % credentials[0])
ctx = _request_ctx_stack.top
ctx.authenticated_user = robot
identity_changed.send(app, identity=Identity(robot.username, 'username'))
return
except model.InvalidRobotException:
logger.debug('Invalid robot or password for robot: %s' % credentials[0])
else:
authenticated = model.verify_user(credentials[0], credentials[1])