Trees | Indices | Help |
|
---|
|
1 # This file is part of Buildbot. Buildbot is free software: you can 2 # redistribute it and/or modify it under the terms of the GNU General Public 3 # License as published by the Free Software Foundation, version 2. 4 # 5 # This program is distributed in the hope that it will be useful, but WITHOUT 6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 8 # details. 9 # 10 # You should have received a copy of the GNU General Public License along with 11 # this program; if not, write to the Free Software Foundation, Inc., 51 12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 13 # 14 # Copyright Buildbot Team Members 15 16 from buildbot.status.web.auth import IAuth 1719 """Decide who can do what.""" 20 21 knownActions = [ 22 # If you add a new action here, be sure to also update the documentation 23 # at docs/cfg-statustargets.texinfo 24 'gracefulShutdown', 25 'forceBuild', 26 'forceAllBuilds', 27 'pingBuilder', 28 'stopBuild', 29 'stopAllBuilds', 30 'cancelPendingBuild', 31 'stopChange', 32 'cleanShutdown', 33 ] 349039 self.auth = auth 40 if auth: 41 assert IAuth.providedBy(auth) 42 43 self.config = dict( (a, default_action) for a in self.knownActions ) 44 for act in self.knownActions: 45 if act in kwargs: 46 self.config[act] = kwargs[act] 47 del kwargs[act] 48 49 if kwargs: 50 raise ValueError("unknown authorization action(s) " + ", ".join(kwargs.keys()))5153 """Should the web interface even show the form for ACTION?""" 54 if action not in self.knownActions: 55 raise KeyError("unknown action") 56 cfg = self.config.get(action, False) 57 if cfg: 58 return True 59 return False6062 """Does this action require an authentication form?""" 63 if action not in self.knownActions: 64 raise KeyError("unknown action") 65 cfg = self.config.get(action, False) 66 if cfg == 'auth' or callable(cfg): 67 return True 68 return False6971 """Is this ACTION allowed, given this http REQUEST?""" 72 if action not in self.knownActions: 73 raise KeyError("unknown action") 74 cfg = self.config.get(action, False) 75 if cfg: 76 if cfg == 'auth' or callable(cfg): 77 if not self.auth: 78 return False 79 user = request.args.get("username", ["<unknown>"])[0] 80 passwd = request.args.get("passwd", ["<no-password>"])[0] 81 if user == "<unknown>" or passwd == "<no-password>": 82 return False 83 if self.auth.authenticate(user, passwd): 84 if callable(cfg) and not cfg(user, *args): 85 return False 86 return True 87 return False 88 else: 89 return True # anyone can do this..
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Dec 19 18:26:48 2010 | http://epydoc.sourceforge.net |