-
-
Notifications
You must be signed in to change notification settings - Fork 38
add generic OIDC auth backend #528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I wonder if adding new admins alongside the normal |
|
@MagicRB are we able to test this in numtide infra? For my own buildbot the issue might be that I have people that want to login when having access to a nix-community repo. |
|
You can test the python-side of this with a mock server as well tree diffdiff --git a/packages/master.cfg.py b/packages/master.cfg.py
index 8cf3db1..2d91c50 100644
--- a/packages/master.cfg.py
+++ b/packages/master.cfg.py
@@ -3,13 +3,18 @@ from buildbot_nix import (
NixConfigurator,
BuildbotNixConfig,
)
-from buildbot_nix.models import PullBasedConfig, PullBasedRepository
+from buildbot_nix.models import (
+ PullBasedConfig,
+ PullBasedRepository,
+ OIDCConfig,
+ AuthBackendConfig,
+ OIDCMappingConfig,
+)
import getpass
import os
import platform
import subprocess
import multiprocessing
-from buildbot.plugins import util
from buildbot.process.factory import BuildFactory
from dataclasses import dataclass
@@ -211,6 +216,17 @@ buildbot_nix_config = BuildbotNixConfig(
url=url,
gcroots_user=getpass.getuser(),
admins=["admin"],
+ auth_backend=AuthBackendConfig.oidc,
+ oidc=OIDCConfig(
+ name="Mock",
+ discovery_url="http://localhost:9400/.well-known/openid-configuration",
+ client_id="123",
+ client_secret_file="/tmp/client_secret",
+ scope=["openid", "email", "profile"],
+ mapping=OIDCMappingConfig(
+ email="email", username="preferred_username", full_name="name", groups=None
+ ),
+ ),
)
c = BuildmasterConfig = dict(
@@ -221,5 +237,5 @@ c = BuildmasterConfig = dict(
NixConfigurator(buildbot_nix_config),
],
protocols={"pb": {"port": "tcp:9989:interface=\\:\\:1"}},
- www=dict(port=PORT, plugins=dict(), auth=util.UserPasswordAuth({"admin": "admin"})),
+ www=dict(port=PORT, plugins=dict()),
)
I also run this PR on https://buildbot.althaea.zone/ but you wouldn't be able to login |
Aligns OIDCMappingConfig/OIDCConfig with other Pydantic models in the file that reject unknown fields. This catches typos and accidental config keys early rather than silently ignoring them.
The "or 'groups'" fallback contradicted the preceding None check. If self.mapping.groups is not None, use it directly. The dict.get() default handles missing keys in the user response.
The code directly indexed token["access_token"] which raises KeyError for malformed responses. Now validates the token first and raises BuildbotNixError with context if the field is missing.
The OIDC client secret was referenced by full path but not exposed to systemd via LoadCredential. Now uses a relative credential name and adds the corresponding LoadCredential entry so the secret is available in $CREDENTIALS_DIRECTORY at runtime.
|
@mrshmllow can you please check? I added documentation and tested the code, you gave me locally. |
d6fbbb2 to
17a32ab
Compare
…to separate files Move detailed GitHub, Gitea, and OIDC authentication documentation from README.md into dedicated files under docs/. This makes the README more concise while keeping comprehensive setup instructions easily accessible.
17a32ab to
a186505
Compare


closes #195
This is a very simple wrapper around the Buildbot
OAuth2Authclass that you can configure with new options.Additionally, you can set your own scope and map the claims, if your OIDC provider changes them in some way. It supports syncing groups although you need to include that scope and mapping yourself.
So far I've tested this successfully with PocketID.
As a note: I decided to identify users by the provider's
preferred_usernamebecause it works well with theadminsoption