This commit is contained in:
parent
0f45b38432
commit
edb56e96dc
22 changed files with 134 additions and 82 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue