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

Remote authenticator and authorizer #234

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

moroten
Copy link
Contributor

@moroten moroten commented Dec 20, 2024

The authenticate and authorize tasks can now be sent remotely over gRPC to an external service. This way, custom authentication and authorization does not require a modified builds of the Buildbarn components.

To avoid spamming the remote service with calls for every REv2 request and keep the latency low, the verdicts, both allow and deny, are cached for a duration specified in the response from the remote service.

@moroten moroten force-pushed the remote-auth branch 3 times, most recently from 8e43646 to 47d3807 Compare December 20, 2024 14:13
@moroten
Copy link
Contributor Author

moroten commented Jan 15, 2025

@EdSchouten Welcome back from Christmas holiday. I forgot to bring this up for discussion yesterday. Any comments? No hurry, take your time.

pkg/proto/auth/auth.proto Show resolved Hide resolved
pkg/proto/auth/auth.proto Show resolved Hide resolved
pkg/grpc/remote_authenticator.go Outdated Show resolved Hide resolved
pkg/grpc/remote_authenticator.go Outdated Show resolved Hide resolved
pkg/grpc/remote_authenticator.go Outdated Show resolved Hide resolved
pkg/grpc/remote_grpc_request_authenticator.go Outdated Show resolved Hide resolved
pkg/grpc/remote_grpc_request_authenticator_test.go Outdated Show resolved Hide resolved
pkg/grpc/remote_authorizer.go Outdated Show resolved Hide resolved
pkg/grpc/request_headers_authenticator.go Outdated Show resolved Hide resolved
@moroten
Copy link
Contributor Author

moroten commented Jan 24, 2025

I've now rebased and fixed all the review comments. The changes were done in Add remote auth .proto definitions and Implement remote authenticator and authorizer.

@moroten
Copy link
Contributor Author

moroten commented Jan 29, 2025

@EdSchouten friendly ping. Would you like me to click "Resolve conversation"?

pkg/auth/remote_authenticator.go Outdated Show resolved Hide resolved
pkg/auth/remote_authenticator.go Outdated Show resolved Hide resolved
pkg/auth/remote_authenticator.go Outdated Show resolved Hide resolved
"google.golang.org/grpc/status"
)

type remoteRequestAuthenticator struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are your thoughts on calling this requestHeadersAuthenticator as well? Yes, it would be the same name as the underlying interface, but because it's in a different package (auth.RequestHeaderAuthenticator vs. http.NewRequestHeadersAuthenticator()) they would still be sufficiently distinct.

The reason I'm bringing this up is because there isn't really anything "remote" about this type. It would be perfectly fine to have an implementation of auth.RequestHeadersAuthenticator that looks at stuff in a SQLite database.

This also makes me wonder: should we reimplement our JWT auth to be built on top of this interface as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also makes me wonder: should we reimplement our JWT auth to be built on top of this interface as well?

Is that just to extract a single header into the JWT handler? Maybe I didn't get how you meant.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now we have these:

-rw-r--r--   1 ed  staff   1240 Dec 15 10:38 pkg/grpc/jwt_authenticator.go
-rw-r--r--   1 ed  staff   1048 Dec 15 10:38 pkg/http/jwt_authenticator.go

But considering that we now have pkg/{grpc,http}/request_header_authenticator.go, we no longer need these, right? We could throw them away and provide a single implementation of auth.RequestHeadersAuthenticator that does the same thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, I get it. I've pushed an update which I've verified in bb-deployments docker-compose for the gRPC header handling.

The authenticate and authorize tasks can now be sent remotely over gRPC
to an external service. This way, custom authentication and
authorization does not require a modified builds of the Buildbarn
components.

To avoid spamming the remote service with calls for every REv2 request
and keep the latency low, the verdicts, both allow and deny, are cached
for a duration specified in the response from the remote service.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants