From 7b19a0b4e838393a0856dbc3a0a26cbbf1c3e153 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Fri, 28 Apr 2017 22:10:33 -0700 Subject: [PATCH] vendor jwtcreds --- vendor-log | 3 ++ .../Xe/x/tools/svc/credentials/jwt/jwt.go | 24 +++++++++ .../grpc/credentials/credentials.go | 4 ++ .../grpc/credentials/credentials_util_go17.go | 3 +- .../grpc/credentials/credentials_util_go18.go | 53 +++++++++++++++++++ .../credentials/credentials_util_pre_go17.go | 2 - 6 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 vendor/github.com/Xe/x/tools/svc/credentials/jwt/jwt.go create mode 100644 vendor/google.golang.org/grpc/credentials/credentials_util_go18.go diff --git a/vendor-log b/vendor-log index 84caef2..878fb76 100644 --- a/vendor-log +++ b/vendor-log @@ -128,3 +128,6 @@ a0175ee3bccc567396460bf5acd36800cb10c49c github.com/alecthomas/template/parse 2efee857e7cfd4f3d0138cc3cbb1b4966962b93a github.com/alecthomas/units 3acf1b3de25d89c7688c63bb45f6b07f566555ec github.com/dickeyxxx/netrc 7f0871f2e17818990e4eed73f9b5c2f429501228 gopkg.in/alecthomas/kingpin.v2 +4d65901933bb7bed40783d9b9f6ae2ea2b829889 (dirty) github.com/Xe/x/tools/svc/credentials/jwt +da118f7b8e5954f39d0d2130ab35d4bf0e3cb344 golang.org/x/net/context +0eb507a2ca07f13baf499f89d66cc566bf644643 (dirty) google.golang.org/grpc/credentials diff --git a/vendor/github.com/Xe/x/tools/svc/credentials/jwt/jwt.go b/vendor/github.com/Xe/x/tools/svc/credentials/jwt/jwt.go new file mode 100644 index 0000000..978c880 --- /dev/null +++ b/vendor/github.com/Xe/x/tools/svc/credentials/jwt/jwt.go @@ -0,0 +1,24 @@ +package jwt + +import ( + "golang.org/x/net/context" + "google.golang.org/grpc/credentials" +) + +type jwt struct { + token string +} + +func NewFromToken(token string) credentials.PerRPCCredentials { + return jwt{token: token} +} + +func (j jwt) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { + return map[string]string{ + "authorization": j.token, + }, nil +} + +func (j jwt) RequireTransportSecurity() bool { + return false +} diff --git a/vendor/google.golang.org/grpc/credentials/credentials.go b/vendor/google.golang.org/grpc/credentials/credentials.go index 4d45c3e..a8114d6 100644 --- a/vendor/google.golang.org/grpc/credentials/credentials.go +++ b/vendor/google.golang.org/grpc/credentials/credentials.go @@ -102,6 +102,10 @@ type TransportCredentials interface { // authentication protocol on rawConn for clients. It returns the authenticated // connection and the corresponding auth information about the connection. // Implementations must use the provided context to implement timely cancellation. + // gRPC will try to reconnect if the error returned is a temporary error + // (io.EOF, context.DeadlineExceeded or err.Temporary() == true). + // If the returned error is a wrapper error, implementations should make sure that + // the error implements Temporary() to have the correct retry behaviors. ClientHandshake(context.Context, string, net.Conn) (net.Conn, AuthInfo, error) // ServerHandshake does the authentication handshake for servers. It returns // the authenticated connection and the corresponding auth information about diff --git a/vendor/google.golang.org/grpc/credentials/credentials_util_go17.go b/vendor/google.golang.org/grpc/credentials/credentials_util_go17.go index 9647b9e..7597b09 100644 --- a/vendor/google.golang.org/grpc/credentials/credentials_util_go17.go +++ b/vendor/google.golang.org/grpc/credentials/credentials_util_go17.go @@ -1,4 +1,5 @@ // +build go1.7 +// +build !go1.8 /* * @@ -44,8 +45,6 @@ import ( // contains a mutex and must not be copied. // // If cfg is nil, a new zero tls.Config is returned. -// -// TODO replace this function with official clone function. func cloneTLSConfig(cfg *tls.Config) *tls.Config { if cfg == nil { return &tls.Config{} diff --git a/vendor/google.golang.org/grpc/credentials/credentials_util_go18.go b/vendor/google.golang.org/grpc/credentials/credentials_util_go18.go new file mode 100644 index 0000000..0ecf342 --- /dev/null +++ b/vendor/google.golang.org/grpc/credentials/credentials_util_go18.go @@ -0,0 +1,53 @@ +// +build go1.8 + +/* + * + * Copyright 2017, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +package credentials + +import ( + "crypto/tls" +) + +// 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. +func cloneTLSConfig(cfg *tls.Config) *tls.Config { + if cfg == nil { + return &tls.Config{} + } + + return cfg.Clone() +} diff --git a/vendor/google.golang.org/grpc/credentials/credentials_util_pre_go17.go b/vendor/google.golang.org/grpc/credentials/credentials_util_pre_go17.go index 09b8d12..cfd40df 100644 --- a/vendor/google.golang.org/grpc/credentials/credentials_util_pre_go17.go +++ b/vendor/google.golang.org/grpc/credentials/credentials_util_pre_go17.go @@ -44,8 +44,6 @@ import ( // contains a mutex and must not be copied. // // If cfg is nil, a new zero tls.Config is returned. -// -// TODO replace this function with official clone function. func cloneTLSConfig(cfg *tls.Config) *tls.Config { if cfg == nil { return &tls.Config{}