Skip to content

Commit 1ed420f

Browse files
committed
basic auth
1 parent 9465741 commit 1ed420f

File tree

25 files changed

+924
-80
lines changed

25 files changed

+924
-80
lines changed

components/gitpod-cli/go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ require (
2323
github.com/sourcegraph/jsonrpc2 v0.0.0-20200429184054-15c2290dcb37
2424
github.com/spf13/cobra v1.6.1
2525
golang.org/x/sync v0.2.0
26-
golang.org/x/term v0.6.0
26+
golang.org/x/term v0.8.0
2727
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f
28-
google.golang.org/grpc v1.52.3
28+
google.golang.org/grpc v1.55.0
2929
gopkg.in/yaml.v2 v2.4.0
3030
)
3131

@@ -40,7 +40,7 @@ require (
4040
github.com/onsi/gomega v1.24.2 // indirect
4141
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
4242
golang.org/x/sys v0.11.0 // indirect
43-
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 // indirect
43+
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
4444
)
4545

4646
require (
@@ -56,8 +56,8 @@ require (
5656
github.com/spf13/pflag v1.0.5
5757
github.com/x-cray/logrus-prefixed-formatter v0.5.2
5858
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
59-
golang.org/x/net v0.8.0 // indirect
60-
golang.org/x/text v0.8.0 // indirect
59+
golang.org/x/net v0.10.0 // indirect
60+
golang.org/x/text v0.9.0 // indirect
6161
google.golang.org/protobuf v1.31.0 // indirect
6262
gopkg.in/segmentio/analytics-go.v3 v3.1.0 // indirect
6363
)

components/gitpod-cli/go.sum

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/public-api-server/BUILD.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ packages:
99
- components/common-go:lib
1010
- components/public-api/go:lib
1111
- components/usage-api/go:lib
12+
- components/usage:lib
1213
- components/gitpod-protocol/go:lib
1314
- components/gitpod-db/go:lib
1415
- components/gitpod-db/go:init-testdb

components/public-api-server/go.mod

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ require (
88
github.com/bufbuild/connect-go v1.10.0
99
github.com/coreos/go-oidc/v3 v3.5.0
1010
github.com/gitpod-io/gitpod/common-go v0.0.0-00010101000000-000000000000
11-
github.com/gitpod-io/gitpod/components/gitpod-db/go v0.0.0-00010101000000-000000000000
11+
github.com/gitpod-io/gitpod/components/gitpod-db/go v0.0.0-20231010172218-3eb86ff8b745
1212
github.com/gitpod-io/gitpod/components/public-api/go v0.0.0-00010101000000-000000000000
1313
github.com/gitpod-io/gitpod/gitpod-protocol v0.0.0-00010101000000-000000000000
14+
github.com/gitpod-io/gitpod/usage v0.0.0-00010101000000-000000000000
1415
github.com/gitpod-io/gitpod/usage-api v0.0.0-00010101000000-000000000000
15-
github.com/go-chi/chi/v5 v5.0.8
16+
github.com/go-chi/chi/v5 v5.0.10
1617
github.com/golang-jwt/jwt/v5 v5.0.0
1718
github.com/golang/mock v1.6.0
1819
github.com/google/go-cmp v0.5.9
@@ -46,7 +47,7 @@ require (
4647
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 // indirect
4748
github.com/jzelinskie/stringz v0.0.1 // indirect
4849
github.com/mitchellh/reflectwalk v1.0.2 // indirect
49-
github.com/yuin/gopher-lua v0.0.0-20220504180219-658193537a64 // indirect
50+
github.com/yuin/gopher-lua v1.1.0 // indirect
5051
go.opentelemetry.io/otel v1.16.0 // indirect
5152
go.opentelemetry.io/otel/metric v1.16.0 // indirect
5253
go.opentelemetry.io/otel/trace v1.16.0 // indirect
@@ -60,7 +61,7 @@ require (
6061
)
6162

6263
require (
63-
github.com/alicebob/miniredis/v2 v2.30.0
64+
github.com/alicebob/miniredis/v2 v2.30.2
6465
github.com/beorn7/perks v1.0.1 // indirect
6566
github.com/blang/semver v3.5.1+incompatible // indirect
6667
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
@@ -117,6 +118,8 @@ replace github.com/gitpod-io/gitpod/gitpod-protocol => ../gitpod-protocol/go //
117118

118119
replace github.com/gitpod-io/gitpod/usage-api => ../usage-api/go // leeway
119120

121+
replace github.com/gitpod-io/gitpod/usage => ../usage // leeway
122+
120123
replace k8s.io/api => k8s.io/api v0.27.3 // leeway indirect from components/common-go:lib
121124

122125
replace k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.27.3 // leeway indirect from components/common-go:lib

components/public-api-server/go.sum

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/public-api-server/pkg/server/server.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424

2525
"github.com/gitpod-io/gitpod/components/public-api/go/config"
2626
"github.com/gitpod-io/gitpod/components/public-api/go/experimental/v1/v1connect"
27+
usage_v1connect "github.com/gitpod-io/gitpod/usage-api/v1/v1connect"
2728
"github.com/gorilla/handlers"
2829

2930
"github.com/gitpod-io/gitpod/common-go/baseserver"
@@ -38,6 +39,7 @@ import (
3839
"github.com/gitpod-io/gitpod/public-api-server/pkg/origin"
3940
"github.com/gitpod-io/gitpod/public-api-server/pkg/proxy"
4041
"github.com/gitpod-io/gitpod/public-api-server/pkg/webhooks"
42+
usage_apiv1 "github.com/gitpod-io/gitpod/usage/pkg/apiv1"
4143
"github.com/sirupsen/logrus"
4244
)
4345

@@ -148,7 +150,7 @@ func Start(logger *logrus.Entry, version string, cfg *config.Configuration) erro
148150
idpService: idpService,
149151
authCfg: cfg.Auth,
150152
sessionVerifier: rsa256,
151-
}); registerErr != nil {
153+
}, cfg); registerErr != nil {
152154
return fmt.Errorf("failed to register services: %w", registerErr)
153155
}
154156

@@ -172,7 +174,7 @@ type registerDependencies struct {
172174
authCfg config.AuthConfiguration
173175
}
174176

175-
func register(srv *baseserver.Server, deps *registerDependencies) error {
177+
func register(srv *baseserver.Server, deps *registerDependencies, cfg *config.Configuration) error {
176178
proxy.RegisterMetrics(srv.MetricsRegistry())
177179
oidc.RegisterMetrics(srv.MetricsRegistry())
178180

@@ -205,6 +207,12 @@ func register(srv *baseserver.Server, deps *registerDependencies) error {
205207
rootHandler.Mount(v1connect.NewOIDCServiceHandler(apiv1.NewOIDCService(deps.connPool, deps.expClient, deps.dbConn, deps.cipher), handlerOptions...))
206208
rootHandler.Mount(v1connect.NewIdentityProviderServiceHandler(apiv1.NewIdentityProviderService(deps.connPool, deps.idpService), handlerOptions...))
207209

210+
usageService, err := usage_apiv1.NewUsageServiceConnect(deps.dbConn, &cfg.UsageConfiguration)
211+
if err != nil {
212+
return fmt.Errorf("cannot create usage service handler: %w", err)
213+
}
214+
rootHandler.Mount(usage_v1connect.NewUsageServiceHandler(usageService, handlerOptions...))
215+
208216
if deps.signer != nil {
209217
rootHandler.Mount(v1connect.NewTokensServiceHandler(apiv1.NewTokensService(deps.connPool, deps.expClient, deps.dbConn, deps.signer), handlerOptions...))
210218
}

components/public-api/go/BUILD.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ packages:
33
type: go
44
deps:
55
- components/common-go:lib
6+
- components/usage-api/go:lib
67
srcs:
78
- "**/*.go"
89
- "go.mod"

components/public-api/go/config/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package config
66

77
import (
88
"github.com/gitpod-io/gitpod/common-go/baseserver"
9+
usage_config "github.com/gitpod-io/gitpod/usage-api/config"
910
)
1011

1112
type Configuration struct {
@@ -25,6 +26,8 @@ type Configuration struct {
2526
// Path to file which contains personal access token singing key
2627
PersonalAccessTokenSigningKeyPath string `json:"personalAccessTokenSigningKeyPath"`
2728

29+
UsageConfiguration usage_config.Config `json:"usage"`
30+
2831
// Path to directory containing database configuration files
2932
DatabaseConfigPath string `json:"databaseConfigPath"`
3033

0 commit comments

Comments
 (0)