Skip to content
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

buildbot-nix access control for private repos #165

Open
zimbatm opened this issue Jun 8, 2024 · 7 comments
Open

buildbot-nix access control for private repos #165

zimbatm opened this issue Jun 8, 2024 · 7 comments
Labels
enhancement New feature or request
Milestone

Comments

@zimbatm
Copy link
Member

zimbatm commented Jun 8, 2024

In some settings, we only want to show the builds to users with access to the repos.

Is it possible to map the repo access control to the authenticated users?

If not, create a "private" mode where only logged-in users can see the builds and builders.

@Mic92
Copy link
Member

Mic92 commented Jun 8, 2024

It's possible. We already limit certain builder endpoints for projects: https://github.com/Mic92/buildbot-nix/blob/b0526ceab2ec89bed5e194a206391a7d85a833e7/buildbot_nix/__init__.py#L663
This can be also extended to limit logs visible of project itself.

@zimbatm
Copy link
Member Author

zimbatm commented Jun 8, 2024

Could it also be extended to the builder activity?

@MagicRB
Copy link
Contributor

MagicRB commented Jun 8, 2024

Ill look into it tomorrow, should be done with a prototype by the evening

@MagicRB
Copy link
Contributor

MagicRB commented Jun 9, 2024

Very briefly looking into this, I instrumented buildbots authentication with the following code:

    any_endpoint_matcher = util.AnyEndpointMatcher(role="admin", defaultDeny=False)
    old_match = any_endpoint_matcher.match

    def match(self: util.AnyEndpointMatcher, ep: Any, action: Any, options: Any) -> Any:
        import inspect

        if options is None:
            options = {}
        try:
            epobject, epdict = self.master.data.getEndpoint(ep)
            for klass in inspect.getmro(epobject.__class__):
                log.info(
                    "matching on {klass} with action: {action}",
                    klass=klass.__name__,
                    action=action,
                )
        except:
            pass
        old_match(ep, action, options)

    import types

    any_endpoint_matcher.match = types.MethodType(match, any_endpoint_matcher)

    allow_rules.append(any_endpoint_matcher)

Which then prints me a list of endpoints that buildbot is looking for auth for, said list reveals:

  1. ProjectsEndpoint
  2. ProjectEndpoint

ProjectsEndpoint comes into play on the /#/projects URL. Interestingly at /#/projects/3 where I would expect ProjectEndpoint to show up, (also according to the patterns it matches) it doesn't actually show up. The endpoints that do show up are: [ProjectsEndpoint, MasterEndpoint, WorkersEndpoint, BuildRequestsEndpoint, BuildersEndpoint, ChangesEndpoint, BuildsEndpoint] but that doesn't help us much as far as I can tell. ProjectEndpoint only appears at #/builders/19 which makes no sense to me. But I'm probably misunderstanding something.

All of this testing has been done on the github_app branch as I didn't really want to change my nix config from developing that :) and while not logged into buildbot at all. But assuming that the correct endpoints would show up, we have a problem anyway as ProjectsEndpoint does not do any filtering whatsoever and does not allow for it. It directly calls up the DB right here, that function if followed directly executes the equivalent of select * from projects; with no room for any filtering either. So this either calls for upstream changes or a mixin.

Not sure what's the correct path forward here and I would appreciate some input as to what to do here. (this little foray into buildbots endpoint handling also tells me that custom UI is possible with mixins and custom endpoints probably 🎉)

@MagicRB
Copy link
Contributor

MagicRB commented Jun 9, 2024

But also this only comes into play if we want to limit access to projects, for builds its quite simple, namely BuildsEndpoint, we have the same problem here too, at the /builds endpoint it is not enough to just allow or deny it, the response must be edited as far as I can tell. The current code does not allow to mark some build as visible and others not.

@zimbatm zimbatm added this to the Release 1.0 milestone Jun 11, 2024
@zimbatm zimbatm added the enhancement New feature or request label Jun 11, 2024
@zimbatm zimbatm changed the title Private mode buildbot-nix access control for private repos Jun 12, 2024
@zimbatm
Copy link
Member Author

zimbatm commented Jun 13, 2024

Ok. I suspected something like this since Buildbot was designed for open-source use.

Since this requires a major refactor, a better short-term solution is to shield the installation. Users can decide to make their instance private, and then only logged-in users can see build information. Webhooks need to be sent through still.

@MagicRB
Copy link
Contributor

MagicRB commented Jul 15, 2024

I'm pushing this to the future milestone then

@MagicRB MagicRB assigned MagicRB and unassigned MagicRB Jul 15, 2024
@MagicRB MagicRB modified the milestones: Release 1.0, Future Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants