Skip to content

Commit 3d7ab2a

Browse files
committed
server: register Login and Logout services with DRPC server
Enable these service on the DRPC server in addition to gRPC. This is controlled by `rpc.experimental_drpc.enabled` (off by default). This change is part of a series and is similar to: #146926 Note: This only registers the service; the client is not updated to use the DRPC client, so this service will not have any functional effect. Epic: CRDB-48925 Release note: None
1 parent b4b2a95 commit 3d7ab2a

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed

pkg/server/authserver/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ go_library(
4444
"@com_github_cockroachdb_logtags//:logtags",
4545
"@com_github_cockroachdb_redact//:redact",
4646
"@com_github_grpc_ecosystem_grpc_gateway//runtime:go_default_library",
47+
"@io_storj_drpc//:drpc",
4748
"@org_golang_google_grpc//:grpc",
4849
"@org_golang_google_grpc//codes",
4950
"@org_golang_google_grpc//metadata",

pkg/server/authserver/api.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ import (
1818
"github.com/cockroachdb/cockroach/pkg/sql/pgwire"
1919
"github.com/grpc-ecosystem/grpc-gateway/runtime"
2020
"google.golang.org/grpc"
21+
"storj.io/drpc"
2122
)
2223

2324
type Server interface {
2425
RegisterService(*grpc.Server)
2526
RegisterGateway(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
2627

28+
RegisterDRPCService(drpc.Mux) error
29+
2730
// UserLogin verifies an incoming request by a user to create an web
2831
// authentication session. It checks the provided credentials against
2932
// the system.users table, and if successful creates a new

pkg/server/authserver/authentication.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import (
4747
"google.golang.org/grpc/codes"
4848
"google.golang.org/grpc/metadata"
4949
"google.golang.org/grpc/status"
50+
"storj.io/drpc"
5051
)
5152

5253
const (
@@ -132,6 +133,15 @@ type authenticationServer struct {
132133
func (s *authenticationServer) RegisterService(g *grpc.Server) {
133134
serverpb.RegisterLogInServer(g, s)
134135
serverpb.RegisterLogOutServer(g, s)
136+
137+
}
138+
139+
// RegisterService registers the LogIn and LogOut services with DRPC.
140+
func (s *authenticationServer) RegisterDRPCService(d drpc.Mux) error {
141+
if err := serverpb.DRPCRegisterLogIn(d, s); err != nil {
142+
return err
143+
}
144+
return serverpb.DRPCRegisterLogOut(d, s)
135145
}
136146

137147
// RegisterGateway starts the gateway (i.e. reverse proxy) that proxies HTTP requests

pkg/server/server.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,10 @@ func NewServer(cfg Config, stopper *stop.Stopper) (serverctl.ServerStartupInterf
12531253
gw.RegisterService(grpcServer.Server)
12541254
}
12551255

1256+
if err := sAuth.RegisterDRPCService(drpcServer); err != nil {
1257+
return nil, err
1258+
}
1259+
12561260
// Tell the node event logger (join, restart) how to populate SQL entries
12571261
// into system.eventlog.
12581262
node.InitLogger(sqlServer.execCfg)

pkg/server/tenant.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,10 @@ func newTenantServer(
480480
gw.RegisterService(args.grpc.Server)
481481
}
482482

483+
if err := sAuth.RegisterDRPCService(args.drpc); err != nil {
484+
return nil, err
485+
}
486+
483487
// Tell the status/admin servers how to access SQL structures.
484488
sStatus.setStmtDiagnosticsRequester(sqlServer.execCfg.StmtDiagnosticsRecorder)
485489
serverIterator.sqlServer = sqlServer

0 commit comments

Comments
 (0)