コード例 #1
0
 def createAuthConfigAdminPassword(self, authcfg):
     if not self.configAssertContains(authcfg, ['adminPassword']):
         return None
     return util.UserPasswordAuth({'admin': authcfg['adminPassword']})
コード例 #2
0
ファイル: buildmaster.py プロジェクト: ostree/buildbot
    def buildmaster_config_base(self) -> Dict[str, Any]:
        """Generate a base for the Buildmaster configuration settings as `dict`
        (i.e. the ``BuildmasterConfig`` `dict` that is read by the Buildbot
        twistd application) with all the settings properly defined."""

        # The buildbot instance name title
        title = "CLIP OS" if self.__settings else "DEBUGGING ONLY"
        title_url = "https://clip-os.org/"

        # Authentication settings
        if not self.__settings:
            auth = NoAuth()
            authz = util.Authz()
        else:
            if not self.secrets:
                admin_usernames = []
                auth_backend = 'user-password-dict'
                auth_backend_parameters = {}
            else:
                admin_usernames = self.secrets.admin_usernames
                auth_backend = self.secrets.auth_backend
                auth_backend_parameters = self.secrets.auth_backend_parameters

            if auth_backend == 'user-password-dict':
                auth = util.UserPasswordAuth(auth_backend_parameters)
            elif auth_backend == 'github':
                auth = util.GitHubAuth(
                    clientId=auth_backend_parameters['clientId'],
                    clientSecret=auth_backend_parameters['clientSecret'],
                    getTeamsMembership=False,  # useless for us
                )
            else:
                raise NotImplementedError(
                    "Unknown auth backend {!r} from secrets".format(
                        auth_backend))

            authz = util.Authz(
                allowRules=[
                    # Admins can do anything.
                    util.AnyEndpointMatcher(role="admins", defaultDeny=False),
                    # Future-proof control endpoints.
                    util.AnyControlEndpointMatcher(role="admins"),
                ],
                roleMatchers=[
                    # Defined administration from their usernames
                    util.RolesFromUsername(
                        roles=['admins'],
                        usernames=admin_usernames,
                    )
                ],
            )

        return {
            # Presentation settings
            'title': title,
            'titleURL': title_url,

            # Database settings
            'db': {
                'db_url': self.db_url,
            },

            # Web UI settings
            'buildbotURL': self.buildbot_url,
            'www': {
                # The port to listen to (a HTTP reverse-proxy should be
                # configured behind this port):
                'port': self.www_port,
                # Do not use an alternative logfile for HTTP logging, use
                # twistd logging output (the fallback) rather than a separate
                # file because the twistd logging output is known to be
                # properly collected.
                'logfileName': None,
                # Do not use Gravatars:
                'avatar_methods': [],

                # Web UI plugins potential settings:
                'plugins': {
                    'waterfall_view': {},
                    # Useless for now:
                    #'console_view': {},
                    #'grid_view': {},
                },

                # Web UI custom configuration:
                'ui_default_config': {
                    'Waterfall.scaling_waterfall': 0.04,
                    'Builders.show_old_builders': True,
                    'Builders.show_workers_name': True,
                },

                # Authentication settings for the web UI and REST API:
                'auth': auth,
                'authz': authz,
            },

            # Buildmaster/workers network related settings
            'protocols': {
                # Settings for Twisted's Perspective Broker protocol
                'pb': {
                    # The port to use to communicate with the Buildbot workers
                    'port': self.pb_port,
                },
            },

            # Disable Buildbot usage tracking for the moment:
            # See: http://docs.buildbot.net/latest/manual/cfg-global.html#buildbotnetusagedata
            'buildbotNetUsageData': None,
        }
コード例 #3
0
### Fetch users from json file
users = []
admins = []
for user in json.load(open('../users.json')):
    if user['admin']:
        admins.append(user['user'])
    users.append((user['user'], user['pass']))

authz = util.Authz(allowRules=[
    util.AnyEndpointMatcher(role='admins', defaultDeny=False),
    util.StopBuildEndpointMatcher(role='owner'),
    util.ForceBuildEndpointMatcher(role='users'),
    util.ForceBuildEndpointMatcher(role='users'),
    util.ForceBuildEndpointMatcher(role='users'),
    util.AnyControlEndpointMatcher(role='admins')
],
                   roleMatchers=[
                       util.RolesFromUsername(roles=['admins'],
                                              usernames=admins),
                       util.RolesFromUsername(roles=['users'],
                                              usernames=users),
                       util.RolesFromOwner(role='owner')
                   ])

######################################################################

WWW = dict(port=8010,
           authz=authz,
           auth=util.UserPasswordAuth(users),
           plugins=dict(console_view={}, pullrequests=[opencv, contrib]))
コード例 #4
0
                   factory=make_fifoci_linux("ogl-lin-nouveau", "pr")),
     BuilderConfig(name="pr-fifoci-ogl-lin-nv",
                   workernames=["ec2-ubu64-nv"],
                   factory=make_fifoci_linux("ogl-lin-nv", "pr")),
     BuilderConfig(name="pr-fifoci-ogl-lin-radeon",
                   workernames=["delroth-vm-ubuntu-radeon"],
                   factory=make_fifoci_linux("ogl-lin-radeon", "pr")),
     BuilderConfig(name="pr-fifoci-sw-lin-mesa",
                   workernames=["hive"],
                   factory=make_fifoci_linux("sw-lin-mesa", "pr")),
     BuilderConfig(name="lint", workernames=["ubuntu"],
                   factory=make_lint()),
 ],
 "www": {
     "port": 8010,
     "auth": util.UserPasswordAuth({"dolphin": WEBAUTH_PASSWORD}),
     "plugins": {
         "waterfall_view": {
             "num_builds": 50
         },
         "console_view": {},
     },
 },
 "services": [
     reporters.HttpStatusPush(
         serverUrl="https://central.dolphin-emu.org/buildbot",
         wantProperties=True),
     reporters.Prometheus(port=8011),
 ],
 "db": {
     "db_url": "sqlite:///state.sqlite",