summaryrefslogtreecommitdiff
path: root/vendor/google.golang.org/grpc/internal/credentials
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/google.golang.org/grpc/internal/credentials')
-rw-r--r--vendor/google.golang.org/grpc/internal/credentials/credentials.go49
-rw-r--r--vendor/google.golang.org/grpc/internal/credentials/spiffe.go75
-rw-r--r--vendor/google.golang.org/grpc/internal/credentials/syscallconn.go58
-rw-r--r--vendor/google.golang.org/grpc/internal/credentials/util.go52
4 files changed, 0 insertions, 234 deletions
diff --git a/vendor/google.golang.org/grpc/internal/credentials/credentials.go b/vendor/google.golang.org/grpc/internal/credentials/credentials.go
deleted file mode 100644
index 9deee7f65..000000000
--- a/vendor/google.golang.org/grpc/internal/credentials/credentials.go
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2021 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package credentials
-
-import (
- "context"
-)
-
-// requestInfoKey is a struct to be used as the key to store RequestInfo in a
-// context.
-type requestInfoKey struct{}
-
-// NewRequestInfoContext creates a context with ri.
-func NewRequestInfoContext(ctx context.Context, ri any) context.Context {
- return context.WithValue(ctx, requestInfoKey{}, ri)
-}
-
-// RequestInfoFromContext extracts the RequestInfo from ctx.
-func RequestInfoFromContext(ctx context.Context) any {
- return ctx.Value(requestInfoKey{})
-}
-
-// clientHandshakeInfoKey is a struct used as the key to store
-// ClientHandshakeInfo in a context.
-type clientHandshakeInfoKey struct{}
-
-// ClientHandshakeInfoFromContext extracts the ClientHandshakeInfo from ctx.
-func ClientHandshakeInfoFromContext(ctx context.Context) any {
- return ctx.Value(clientHandshakeInfoKey{})
-}
-
-// NewClientHandshakeInfoContext creates a context with chi.
-func NewClientHandshakeInfoContext(ctx context.Context, chi any) context.Context {
- return context.WithValue(ctx, clientHandshakeInfoKey{}, chi)
-}
diff --git a/vendor/google.golang.org/grpc/internal/credentials/spiffe.go b/vendor/google.golang.org/grpc/internal/credentials/spiffe.go
deleted file mode 100644
index 25ade6230..000000000
--- a/vendor/google.golang.org/grpc/internal/credentials/spiffe.go
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *
- * Copyright 2020 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// Package credentials defines APIs for parsing SPIFFE ID.
-//
-// All APIs in this package are experimental.
-package credentials
-
-import (
- "crypto/tls"
- "crypto/x509"
- "net/url"
-
- "google.golang.org/grpc/grpclog"
-)
-
-var logger = grpclog.Component("credentials")
-
-// SPIFFEIDFromState parses the SPIFFE ID from State. If the SPIFFE ID format
-// is invalid, return nil with warning.
-func SPIFFEIDFromState(state tls.ConnectionState) *url.URL {
- if len(state.PeerCertificates) == 0 || len(state.PeerCertificates[0].URIs) == 0 {
- return nil
- }
- return SPIFFEIDFromCert(state.PeerCertificates[0])
-}
-
-// SPIFFEIDFromCert parses the SPIFFE ID from x509.Certificate. If the SPIFFE
-// ID format is invalid, return nil with warning.
-func SPIFFEIDFromCert(cert *x509.Certificate) *url.URL {
- if cert == nil || cert.URIs == nil {
- return nil
- }
- var spiffeID *url.URL
- for _, uri := range cert.URIs {
- if uri == nil || uri.Scheme != "spiffe" || uri.Opaque != "" || (uri.User != nil && uri.User.Username() != "") {
- continue
- }
- // From this point, we assume the uri is intended for a SPIFFE ID.
- if len(uri.String()) > 2048 {
- logger.Warning("invalid SPIFFE ID: total ID length larger than 2048 bytes")
- return nil
- }
- if len(uri.Host) == 0 || len(uri.Path) == 0 {
- logger.Warning("invalid SPIFFE ID: domain or workload ID is empty")
- return nil
- }
- if len(uri.Host) > 255 {
- logger.Warning("invalid SPIFFE ID: domain length larger than 255 characters")
- return nil
- }
- // A valid SPIFFE certificate can only have exactly one URI SAN field.
- if len(cert.URIs) > 1 {
- logger.Warning("invalid SPIFFE ID: multiple URI SANs")
- return nil
- }
- spiffeID = uri
- }
- return spiffeID
-}
diff --git a/vendor/google.golang.org/grpc/internal/credentials/syscallconn.go b/vendor/google.golang.org/grpc/internal/credentials/syscallconn.go
deleted file mode 100644
index 2919632d6..000000000
--- a/vendor/google.golang.org/grpc/internal/credentials/syscallconn.go
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *
- * Copyright 2018 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package credentials
-
-import (
- "net"
- "syscall"
-)
-
-type sysConn = syscall.Conn
-
-// syscallConn keeps reference of rawConn to support syscall.Conn for channelz.
-// SyscallConn() (the method in interface syscall.Conn) is explicitly
-// implemented on this type,
-//
-// Interface syscall.Conn is implemented by most net.Conn implementations (e.g.
-// TCPConn, UnixConn), but is not part of net.Conn interface. So wrapper conns
-// that embed net.Conn don't implement syscall.Conn. (Side note: tls.Conn
-// doesn't embed net.Conn, so even if syscall.Conn is part of net.Conn, it won't
-// help here).
-type syscallConn struct {
- net.Conn
- // sysConn is a type alias of syscall.Conn. It's necessary because the name
- // `Conn` collides with `net.Conn`.
- sysConn
-}
-
-// WrapSyscallConn tries to wrap rawConn and newConn into a net.Conn that
-// implements syscall.Conn. rawConn will be used to support syscall, and newConn
-// will be used for read/write.
-//
-// This function returns newConn if rawConn doesn't implement syscall.Conn.
-func WrapSyscallConn(rawConn, newConn net.Conn) net.Conn {
- sysConn, ok := rawConn.(syscall.Conn)
- if !ok {
- return newConn
- }
- return &syscallConn{
- Conn: newConn,
- sysConn: sysConn,
- }
-}
diff --git a/vendor/google.golang.org/grpc/internal/credentials/util.go b/vendor/google.golang.org/grpc/internal/credentials/util.go
deleted file mode 100644
index f792fd22c..000000000
--- a/vendor/google.golang.org/grpc/internal/credentials/util.go
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- *
- * Copyright 2020 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package credentials
-
-import (
- "crypto/tls"
-)
-
-const alpnProtoStrH2 = "h2"
-
-// AppendH2ToNextProtos appends h2 to next protos.
-func AppendH2ToNextProtos(ps []string) []string {
- for _, p := range ps {
- if p == alpnProtoStrH2 {
- return ps
- }
- }
- ret := make([]string, 0, len(ps)+1)
- ret = append(ret, ps...)
- return append(ret, alpnProtoStrH2)
-}
-
-// CloneTLSConfig returns a shallow clone of the exported
-// fields of cfg, ignoring the unexported sync.Once, which
-// contains a mutex and must not be copied.
-//
-// If cfg is nil, a new zero tls.Config is returned.
-//
-// TODO: inline this function if possible.
-func CloneTLSConfig(cfg *tls.Config) *tls.Config {
- if cfg == nil {
- return &tls.Config{}
- }
-
- return cfg.Clone()
-}