This commit is contained in:
parent
0f45b38432
commit
edb56e96dc
22 changed files with 134 additions and 82 deletions
|
@ -7,8 +7,8 @@ import importlib
|
|||
import buildbot.plugins
|
||||
|
||||
|
||||
def _get_auth_config(ENVIRONMENT: str):
|
||||
if ENVIRONMENT == "LOCAL":
|
||||
def _get_auth_config(environment: str):
|
||||
if environment == "LOCAL":
|
||||
import conf.local.auth
|
||||
|
||||
importlib.reload(conf.local.auth)
|
||||
|
@ -20,13 +20,13 @@ def _get_auth_config(ENVIRONMENT: str):
|
|||
return conf.production.auth
|
||||
|
||||
|
||||
def fetch_authentication(ENVIRONMENT: str):
|
||||
auth_config = _get_auth_config(ENVIRONMENT)
|
||||
return auth_config.get_authentication(ENVIRONMENT)
|
||||
def fetch_authentication(environment: str):
|
||||
auth_config = _get_auth_config(environment)
|
||||
return auth_config.get_authentication(environment)
|
||||
|
||||
|
||||
def fetch_authorization(ENVIRONMENT: str):
|
||||
auth_config = _get_auth_config(ENVIRONMENT)
|
||||
def fetch_authorization(environment: str):
|
||||
auth_config = _get_auth_config(environment)
|
||||
|
||||
admin_usernames = auth_config.admin_usernames
|
||||
deploy_dev_usernames = auth_config.deploy_dev_usernames
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
# SPDX-FileCopyrightText: 2011-2024 Blender Authors
|
||||
# <pep8 compliant>
|
||||
|
||||
import buildbot.plugins
|
||||
# import buildbot.plugins
|
||||
import os
|
||||
from buildbot.www.oauth2 import OAuth2Auth
|
||||
from urllib.parse import urljoin
|
||||
|
||||
# Buildbot admin with access to everything.
|
||||
admin_usernames = [
|
||||
|
@ -19,10 +22,30 @@ trusted_dev_usernames = [
|
|||
"admin",
|
||||
]
|
||||
|
||||
gitea_endpoint = os.environ.get("GITEA_ENDPOINT", default="")
|
||||
gitea_client_id = os.environ.get("GITEA_CLIENT_ID", default="")
|
||||
gitea_client_secret = os.environ.get("GITEA_CLIENT_SECRET", default="")
|
||||
|
||||
def get_authentication(ENVIRONMENT: str):
|
||||
class LocalEnvAuth(buildbot.plugins.util.CustomAuth):
|
||||
def check_credentials(self, user, password):
|
||||
return user.decode() == "admin" and password.decode() == "admin"
|
||||
|
||||
return LocalEnvAuth()
|
||||
def get_authentication(environment: str):
|
||||
class GiteaAuth(OAuth2Auth):
|
||||
name = "projects.blender.org"
|
||||
faIcon = "fa-cogs"
|
||||
|
||||
AUTH_URL = "login/oauth/authorize"
|
||||
TOKEN_URL = "login/oauth/access_token"
|
||||
|
||||
def __init__(self, endpoint, client_id, client_secret, **kwargs):
|
||||
super(GiteaAuth, self).__init__(client_id, client_secret, **kwargs)
|
||||
self.resourceEndpoint = endpoint
|
||||
self.authUri = urljoin(endpoint, self.AUTH_URL)
|
||||
self.tokenUri = urljoin(endpoint, self.TOKEN_URL)
|
||||
|
||||
def getUserInfoFromOAuthClient(self, c):
|
||||
return self.get(c, "/api/v1/user")
|
||||
|
||||
# class LocalEnvAuth(buildbot.plugins.util.CustomAuth):
|
||||
# def check_credentials(self, user, password):
|
||||
# return user.decode() == "admin" and password.decode() == "admin"
|
||||
|
||||
return GiteaAuth(gitea_endpoint, gitea_client_id, gitea_client_secret)
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
import importlib
|
||||
|
||||
|
||||
def _get_config(ENVIRONMENT: str):
|
||||
if ENVIRONMENT == "LOCAL":
|
||||
def _get_config(environment: str):
|
||||
if environment == "LOCAL":
|
||||
import conf.local.machines
|
||||
|
||||
importlib.reload(conf.local.machines)
|
||||
|
@ -18,13 +18,13 @@ def _get_config(ENVIRONMENT: str):
|
|||
return conf.production.machines
|
||||
|
||||
|
||||
def fetch_platform_worker_names(ENVIRONMENT: str):
|
||||
machines_config = _get_config(ENVIRONMENT)
|
||||
return machines_config.get_worker_names(ENVIRONMENT)
|
||||
def fetch_platform_worker_names(environment: str):
|
||||
machines_config = _get_config(environment)
|
||||
return machines_config.get_worker_names(environment)
|
||||
|
||||
|
||||
def get_worker_password(ENVIRONMENT: str, worker_name: str) -> str:
|
||||
machines_config = _get_config(ENVIRONMENT)
|
||||
def get_worker_password(environment: str, worker_name: str) -> str:
|
||||
machines_config = _get_config(environment)
|
||||
return machines_config.get_worker_password(worker_name)
|
||||
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ import importlib
|
|||
from typing import Any
|
||||
|
||||
|
||||
def get_config(ENVIRONMENT: str) -> Any:
|
||||
if ENVIRONMENT == "LOCAL":
|
||||
def get_config(environment: str) -> Any:
|
||||
if environment == "LOCAL":
|
||||
import conf.local.worker
|
||||
|
||||
importlib.reload(conf.local.worker)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue