Skip to content

Commit acfbdad

Browse files
committed
Add grpcClientFactory to http.NewAuthenticatorFromConfiguration
1 parent 16a2db0 commit acfbdad

File tree

6 files changed

+13
-9
lines changed

6 files changed

+13
-9
lines changed

cmd/bb_replicator/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func main() {
7070
return util.StatusWrap(err, "gRPC server failure")
7171
}
7272

73-
lifecycleState.MarkReadyAndWait(siblingsGroup)
73+
lifecycleState.MarkReadyAndWait(siblingsGroup, grpcClientFactory)
7474
return nil
7575
})
7676
}

cmd/bb_storage/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func main() {
216216
return util.StatusWrap(err, "gRPC server failure")
217217
}
218218

219-
lifecycleState.MarkReadyAndWait(siblingsGroup)
219+
lifecycleState.MarkReadyAndWait(siblingsGroup, grpcClientFactory)
220220
return nil
221221
})
222222
}

pkg/global/apply_configuration.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ type LifecycleState struct {
5858
// MarkReadyAndWait can be called to report that the program has started
5959
// successfully. The application should now be reported as being healthy
6060
// and ready, and receive incoming requests if applicable.
61-
func (ls *LifecycleState) MarkReadyAndWait(group program.Group) {
61+
func (ls *LifecycleState) MarkReadyAndWait(group program.Group, grpcClientFactory bb_grpc.ClientFactory) {
6262
// Start a diagnostics web server that exposes Prometheus
6363
// metrics and provides a health check endpoint.
6464
if ls.config != nil {
@@ -77,7 +77,8 @@ func (ls *LifecycleState) MarkReadyAndWait(group program.Group) {
7777
bb_http.NewServersFromConfigurationAndServe(
7878
ls.config.HttpServers,
7979
bb_http.NewMetricsHandler(router, "Diagnostics"),
80-
group)
80+
group,
81+
grpcClientFactory)
8182
}
8283
}
8384

pkg/http/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ go_library(
2323
deps = [
2424
"//pkg/auth",
2525
"//pkg/clock",
26+
"//pkg/grpc",
2627
"//pkg/jwt",
2728
"//pkg/program",
2829
"//pkg/proto/configuration/http",

pkg/http/authenticator.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/buildbarn/bb-storage/pkg/auth"
1111
"github.com/buildbarn/bb-storage/pkg/clock"
12+
"github.com/buildbarn/bb-storage/pkg/grpc"
1213
"github.com/buildbarn/bb-storage/pkg/jwt"
1314
"github.com/buildbarn/bb-storage/pkg/program"
1415
configuration "github.com/buildbarn/bb-storage/pkg/proto/configuration/http"
@@ -31,7 +32,7 @@ type Authenticator interface {
3132

3233
// NewAuthenticatorFromConfiguration creates a tree of Authenticator
3334
// objects based on a configuration file.
34-
func NewAuthenticatorFromConfiguration(policy *configuration.AuthenticationPolicy, group program.Group) (Authenticator, error) {
35+
func NewAuthenticatorFromConfiguration(policy *configuration.AuthenticationPolicy, group program.Group, grpcClientFactory grpc.ClientFactory) (Authenticator, error) {
3536
if policy == nil {
3637
return nil, status.Error(codes.InvalidArgument, "Authentication policy not specified")
3738
}
@@ -45,7 +46,7 @@ func NewAuthenticatorFromConfiguration(policy *configuration.AuthenticationPolic
4546
case *configuration.AuthenticationPolicy_Any:
4647
children := make([]Authenticator, 0, len(policyKind.Any.Policies))
4748
for _, childConfiguration := range policyKind.Any.Policies {
48-
child, err := NewAuthenticatorFromConfiguration(childConfiguration, group)
49+
child, err := NewAuthenticatorFromConfiguration(childConfiguration, group, grpcClientFactory)
4950
if err != nil {
5051
return nil, err
5152
}
@@ -119,7 +120,7 @@ func NewAuthenticatorFromConfiguration(policy *configuration.AuthenticationPolic
119120
cookieAEAD,
120121
clock.SystemClock)
121122
case *configuration.AuthenticationPolicy_AcceptHeader:
122-
base, err := NewAuthenticatorFromConfiguration(policyKind.AcceptHeader.Policy, group)
123+
base, err := NewAuthenticatorFromConfiguration(policyKind.AcceptHeader.Policy, group, grpcClientFactory)
123124
if err != nil {
124125
return nil, err
125126
}

pkg/http/server.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"net/http"
66

7+
"github.com/buildbarn/bb-storage/pkg/grpc"
78
"github.com/buildbarn/bb-storage/pkg/program"
89
configuration "github.com/buildbarn/bb-storage/pkg/proto/configuration/http"
910
"github.com/buildbarn/bb-storage/pkg/util"
@@ -13,10 +14,10 @@ import (
1314
// program.Group, based on a configuration message. The web servers are
1415
// automatically terminated if the context associated with the group is
1516
// canceled.
16-
func NewServersFromConfigurationAndServe(configurations []*configuration.ServerConfiguration, handler http.Handler, group program.Group) {
17+
func NewServersFromConfigurationAndServe(configurations []*configuration.ServerConfiguration, handler http.Handler, group program.Group, grpcClientFactory grpc.ClientFactory) {
1718
group.Go(func(ctx context.Context, siblingsGroup, dependenciesGroup program.Group) error {
1819
for _, configuration := range configurations {
19-
authenticator, err := NewAuthenticatorFromConfiguration(configuration.AuthenticationPolicy, dependenciesGroup)
20+
authenticator, err := NewAuthenticatorFromConfiguration(configuration.AuthenticationPolicy, dependenciesGroup, grpcClientFactory)
2021
if err != nil {
2122
return err
2223
}

0 commit comments

Comments
 (0)