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

xds: server-side security: server integration #4092

Merged
merged 7 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
xds: Implement server-side security
  • Loading branch information
easwars committed Dec 16, 2020
commit c23173d9df91099b26d90f5805d75b1d87ca7624
4 changes: 4 additions & 0 deletions internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ var (
// stored in the passed in attributes. This is set by
// credentials/xds/xds.go.
GetXDSHandshakeInfoForTesting interface{} // func (attr *attributes.Attributes) *xds.HandshakeInfo
// GetServerCredentials returns the transport credentials configured on a
// gRPC server. An xDS-enabled server needs to know what type of credentials
// is configured on the underlying gRPC server. This is set by server.go.
GetServerCredentials interface{} // func (s interface{}) *credentials.TransportCredentials
Copy link
Member

Choose a reason for hiding this comment

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

Why not func (s *grpc.Server) ...?

Also it seems the convention is mostly to not give names to the parameters, just list their types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We cannot have this package depend on the grpc package, right. That would lead to a cyclic dependency.

Removed the parameter names.

Copy link
Member

Choose a reason for hiding this comment

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

This was referring to the comment. The type would still be interface{}

)

// HealthChecker defines the signature of the client-side LB channel health checking function.
Expand Down
11 changes: 11 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"google.golang.org/grpc/encoding"
"google.golang.org/grpc/encoding/proto"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/internal"
"google.golang.org/grpc/internal/binarylog"
"google.golang.org/grpc/internal/channelz"
"google.golang.org/grpc/internal/grpcrand"
Expand All @@ -58,6 +59,16 @@ const (
defaultServerMaxSendMessageSize = math.MaxInt32
)

func init() {
internal.GetServerCredentials = func(srv interface{}) credentials.TransportCredentials {
s, ok := srv.(*Server)
if !ok {
return nil
}
return s.opts.creds
}
}

var statusOK = status.New(codes.OK, "")
var logger = grpclog.Component("core")

Expand Down
4 changes: 4 additions & 0 deletions xds/internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ type ListenerUpdate struct {
SecurityCfg *SecurityConfig
}

func (lu *ListenerUpdate) String() string {
return fmt.Sprintf("{RouteConfigName: %q, SecurityConfig: %+v", lu.RouteConfigName, lu.SecurityCfg)
}

// RouteConfigUpdate contains information received in an RDS response, which is
// of interest to the registered RDS watcher.
type RouteConfigUpdate struct {
Expand Down
Loading