mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
vendor: golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f
full diff: 6f1e639406...2bc19b1117
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
a69cda092b
commit
7f9c77b2fe
9 changed files with 92 additions and 24 deletions
|
@ -137,7 +137,7 @@ require (
|
||||||
golang.org/x/crypto v0.0.0-20211202192323-5770296d904e // indirect
|
golang.org/x/crypto v0.0.0-20211202192323-5770296d904e // indirect
|
||||||
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
|
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
|
||||||
golang.org/x/mod v0.4.2 // indirect
|
golang.org/x/mod v0.4.2 // indirect
|
||||||
golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a // indirect
|
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
|
||||||
golang.org/x/text v0.3.6 // indirect
|
golang.org/x/text v0.3.6 // indirect
|
||||||
golang.org/x/tools v0.1.5 // indirect
|
golang.org/x/tools v0.1.5 // indirect
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||||
|
|
|
@ -852,8 +852,8 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a h1:4Kd8OPUx1xgUwrHDaviWZO8MsgoZTZYC3g+8m16RBww=
|
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f h1:Qmd2pbz05z7z6lm0DrgQVVPuBm92jqujBKMHMOlOQEw=
|
||||||
golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
|
2
vendor/golang.org/x/oauth2/google/google.go
generated
vendored
2
vendor/golang.org/x/oauth2/google/google.go
generated
vendored
|
@ -177,7 +177,7 @@ func (f *credentialsFile) tokenSource(ctx context.Context, params CredentialsPar
|
||||||
QuotaProjectID: f.QuotaProjectID,
|
QuotaProjectID: f.QuotaProjectID,
|
||||||
Scopes: params.Scopes,
|
Scopes: params.Scopes,
|
||||||
}
|
}
|
||||||
return cfg.TokenSource(ctx), nil
|
return cfg.TokenSource(ctx)
|
||||||
case "":
|
case "":
|
||||||
return nil, errors.New("missing 'type' field in credentials")
|
return nil, errors.New("missing 'type' field in credentials")
|
||||||
default:
|
default:
|
||||||
|
|
94
vendor/golang.org/x/oauth2/google/internal/externalaccount/basecredentials.go
generated
vendored
94
vendor/golang.org/x/oauth2/google/internal/externalaccount/basecredentials.go
generated
vendored
|
@ -7,10 +7,14 @@ package externalaccount
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"golang.org/x/oauth2"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/oauth2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// now aliases time.Now for testing
|
// now aliases time.Now for testing
|
||||||
|
@ -22,43 +26,101 @@ var now = func() time.Time {
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// Audience is the Secure Token Service (STS) audience which contains the resource name for the workload
|
// Audience is the Secure Token Service (STS) audience which contains the resource name for the workload
|
||||||
// identity pool or the workforce pool and the provider identifier in that pool.
|
// identity pool or the workforce pool and the provider identifier in that pool.
|
||||||
Audience string
|
Audience string
|
||||||
// SubjectTokenType is the STS token type based on the Oauth2.0 token exchange spec
|
// SubjectTokenType is the STS token type based on the Oauth2.0 token exchange spec
|
||||||
// e.g. `urn:ietf:params:oauth:token-type:jwt`.
|
// e.g. `urn:ietf:params:oauth:token-type:jwt`.
|
||||||
SubjectTokenType string
|
SubjectTokenType string
|
||||||
// TokenURL is the STS token exchange endpoint.
|
// TokenURL is the STS token exchange endpoint.
|
||||||
TokenURL string
|
TokenURL string
|
||||||
// TokenInfoURL is the token_info endpoint used to retrieve the account related information (
|
// TokenInfoURL is the token_info endpoint used to retrieve the account related information (
|
||||||
// user attributes like account identifier, eg. email, username, uid, etc). This is
|
// user attributes like account identifier, eg. email, username, uid, etc). This is
|
||||||
// needed for gCloud session account identification.
|
// needed for gCloud session account identification.
|
||||||
TokenInfoURL string
|
TokenInfoURL string
|
||||||
// ServiceAccountImpersonationURL is the URL for the service account impersonation request. This is only
|
// ServiceAccountImpersonationURL is the URL for the service account impersonation request. This is only
|
||||||
// required for workload identity pools when APIs to be accessed have not integrated with UberMint.
|
// required for workload identity pools when APIs to be accessed have not integrated with UberMint.
|
||||||
ServiceAccountImpersonationURL string
|
ServiceAccountImpersonationURL string
|
||||||
// ClientSecret is currently only required if token_info endpoint also
|
// ClientSecret is currently only required if token_info endpoint also
|
||||||
// needs to be called with the generated GCP access token. When provided, STS will be
|
// needs to be called with the generated GCP access token. When provided, STS will be
|
||||||
// called with additional basic authentication using client_id as username and client_secret as password.
|
// called with additional basic authentication using client_id as username and client_secret as password.
|
||||||
ClientSecret string
|
ClientSecret string
|
||||||
// ClientID is only required in conjunction with ClientSecret, as described above.
|
// ClientID is only required in conjunction with ClientSecret, as described above.
|
||||||
ClientID string
|
ClientID string
|
||||||
// CredentialSource contains the necessary information to retrieve the token itself, as well
|
// CredentialSource contains the necessary information to retrieve the token itself, as well
|
||||||
// as some environmental information.
|
// as some environmental information.
|
||||||
CredentialSource CredentialSource
|
CredentialSource CredentialSource
|
||||||
// QuotaProjectID is injected by gCloud. If the value is non-empty, the Auth libraries
|
// QuotaProjectID is injected by gCloud. If the value is non-empty, the Auth libraries
|
||||||
// will set the x-goog-user-project which overrides the project associated with the credentials.
|
// will set the x-goog-user-project which overrides the project associated with the credentials.
|
||||||
QuotaProjectID string
|
QuotaProjectID string
|
||||||
// Scopes contains the desired scopes for the returned access token.
|
// Scopes contains the desired scopes for the returned access token.
|
||||||
Scopes []string
|
Scopes []string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Each element consists of a list of patterns. validateURLs checks for matches
|
||||||
|
// that include all elements in a given list, in that order.
|
||||||
|
|
||||||
|
var (
|
||||||
|
validTokenURLPatterns = []*regexp.Regexp{
|
||||||
|
// The complicated part in the middle matches any number of characters that
|
||||||
|
// aren't period, spaces, or slashes.
|
||||||
|
regexp.MustCompile(`(?i)^[^\.\s\/\\]+\.sts\.googleapis\.com$`),
|
||||||
|
regexp.MustCompile(`(?i)^sts\.googleapis\.com$`),
|
||||||
|
regexp.MustCompile(`(?i)^sts\.[^\.\s\/\\]+\.googleapis\.com$`),
|
||||||
|
regexp.MustCompile(`(?i)^[^\.\s\/\\]+-sts\.googleapis\.com$`),
|
||||||
|
}
|
||||||
|
validImpersonateURLPatterns = []*regexp.Regexp{
|
||||||
|
regexp.MustCompile(`^[^\.\s\/\\]+\.iamcredentials\.googleapis\.com$`),
|
||||||
|
regexp.MustCompile(`^iamcredentials\.googleapis\.com$`),
|
||||||
|
regexp.MustCompile(`^iamcredentials\.[^\.\s\/\\]+\.googleapis\.com$`),
|
||||||
|
regexp.MustCompile(`^[^\.\s\/\\]+-iamcredentials\.googleapis\.com$`),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func validateURL(input string, patterns []*regexp.Regexp, scheme string) bool {
|
||||||
|
parsed, err := url.Parse(input)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if !strings.EqualFold(parsed.Scheme, scheme) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
toTest := parsed.Host
|
||||||
|
|
||||||
|
for _, pattern := range patterns {
|
||||||
|
|
||||||
|
if valid := pattern.MatchString(toTest); valid {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// TokenSource Returns an external account TokenSource struct. This is to be called by package google to construct a google.Credentials.
|
// TokenSource Returns an external account TokenSource struct. This is to be called by package google to construct a google.Credentials.
|
||||||
func (c *Config) TokenSource(ctx context.Context) oauth2.TokenSource {
|
func (c *Config) TokenSource(ctx context.Context) (oauth2.TokenSource, error) {
|
||||||
|
return c.tokenSource(ctx, validTokenURLPatterns, validImpersonateURLPatterns, "https")
|
||||||
|
}
|
||||||
|
|
||||||
|
// tokenSource is a private function that's directly called by some of the tests,
|
||||||
|
// because the unit test URLs are mocked, and would otherwise fail the
|
||||||
|
// validity check.
|
||||||
|
func (c *Config) tokenSource(ctx context.Context, tokenURLValidPats []*regexp.Regexp, impersonateURLValidPats []*regexp.Regexp, scheme string) (oauth2.TokenSource, error) {
|
||||||
|
valid := validateURL(c.TokenURL, tokenURLValidPats, scheme)
|
||||||
|
if !valid {
|
||||||
|
return nil, fmt.Errorf("oauth2/google: invalid TokenURL provided while constructing tokenSource")
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.ServiceAccountImpersonationURL != "" {
|
||||||
|
valid := validateURL(c.ServiceAccountImpersonationURL, impersonateURLValidPats, scheme)
|
||||||
|
if !valid {
|
||||||
|
return nil, fmt.Errorf("oauth2/google: invalid ServiceAccountImpersonationURL provided while constructing tokenSource")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ts := tokenSource{
|
ts := tokenSource{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
conf: c,
|
conf: c,
|
||||||
}
|
}
|
||||||
if c.ServiceAccountImpersonationURL == "" {
|
if c.ServiceAccountImpersonationURL == "" {
|
||||||
return oauth2.ReuseTokenSource(nil, ts)
|
return oauth2.ReuseTokenSource(nil, ts), nil
|
||||||
}
|
}
|
||||||
scopes := c.Scopes
|
scopes := c.Scopes
|
||||||
ts.conf.Scopes = []string{"https://www.googleapis.com/auth/cloud-platform"}
|
ts.conf.Scopes = []string{"https://www.googleapis.com/auth/cloud-platform"}
|
||||||
|
@ -68,7 +130,7 @@ func (c *Config) TokenSource(ctx context.Context) oauth2.TokenSource {
|
||||||
scopes: scopes,
|
scopes: scopes,
|
||||||
ts: oauth2.ReuseTokenSource(nil, ts),
|
ts: oauth2.ReuseTokenSource(nil, ts),
|
||||||
}
|
}
|
||||||
return oauth2.ReuseTokenSource(nil, imp)
|
return oauth2.ReuseTokenSource(nil, imp), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subject token file types.
|
// Subject token file types.
|
||||||
|
@ -78,9 +140,9 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type format struct {
|
type format struct {
|
||||||
// Type is either "text" or "json". When not provided "text" type is assumed.
|
// Type is either "text" or "json". When not provided "text" type is assumed.
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
// SubjectTokenFieldName is only required for JSON format. This would be "access_token" for azure.
|
// SubjectTokenFieldName is only required for JSON format. This would be "access_token" for azure.
|
||||||
SubjectTokenFieldName string `json:"subject_token_field_name"`
|
SubjectTokenFieldName string `json:"subject_token_field_name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +190,7 @@ type baseCredentialSource interface {
|
||||||
subjectToken() (string, error)
|
subjectToken() (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// tokenSource is the source that handles external credentials. It is used to retrieve Tokens.
|
// tokenSource is the source that handles external credentials. It is used to retrieve Tokens.
|
||||||
type tokenSource struct {
|
type tokenSource struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
conf *Config
|
conf *Config
|
||||||
|
|
3
vendor/golang.org/x/oauth2/google/internal/externalaccount/clientauth.go
generated
vendored
3
vendor/golang.org/x/oauth2/google/internal/externalaccount/clientauth.go
generated
vendored
|
@ -6,9 +6,10 @@ package externalaccount
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"golang.org/x/oauth2"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"golang.org/x/oauth2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// clientAuthentication represents an OAuth client ID and secret and the mechanism for passing these credentials as stated in rfc6749#2.3.1.
|
// clientAuthentication represents an OAuth client ID and secret and the mechanism for passing these credentials as stated in rfc6749#2.3.1.
|
||||||
|
|
3
vendor/golang.org/x/oauth2/google/internal/externalaccount/impersonate.go
generated
vendored
3
vendor/golang.org/x/oauth2/google/internal/externalaccount/impersonate.go
generated
vendored
|
@ -9,11 +9,12 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"golang.org/x/oauth2"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/oauth2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// generateAccesstokenReq is used for service account impersonation
|
// generateAccesstokenReq is used for service account impersonation
|
||||||
|
|
3
vendor/golang.org/x/oauth2/google/internal/externalaccount/sts_exchange.go
generated
vendored
3
vendor/golang.org/x/oauth2/google/internal/externalaccount/sts_exchange.go
generated
vendored
|
@ -65,6 +65,9 @@ func exchangeToken(ctx context.Context, endpoint string, request *stsTokenExchan
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(io.LimitReader(resp.Body, 1<<20))
|
body, err := ioutil.ReadAll(io.LimitReader(resp.Body, 1<<20))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if c := resp.StatusCode; c < 200 || c > 299 {
|
if c := resp.StatusCode; c < 200 || c > 299 {
|
||||||
return nil, fmt.Errorf("oauth2/google: status code %d: %s", c, body)
|
return nil, fmt.Errorf("oauth2/google: status code %d: %s", c, body)
|
||||||
}
|
}
|
||||||
|
|
3
vendor/golang.org/x/oauth2/google/internal/externalaccount/urlcredsource.go
generated
vendored
3
vendor/golang.org/x/oauth2/google/internal/externalaccount/urlcredsource.go
generated
vendored
|
@ -9,10 +9,11 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"golang.org/x/oauth2"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"golang.org/x/oauth2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type urlCredentialSource struct {
|
type urlCredentialSource struct {
|
||||||
|
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
|
@ -829,7 +829,7 @@ golang.org/x/net/ipv6
|
||||||
golang.org/x/net/proxy
|
golang.org/x/net/proxy
|
||||||
golang.org/x/net/trace
|
golang.org/x/net/trace
|
||||||
golang.org/x/net/websocket
|
golang.org/x/net/websocket
|
||||||
# golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a
|
# golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f
|
||||||
## explicit; go 1.11
|
## explicit; go 1.11
|
||||||
golang.org/x/oauth2
|
golang.org/x/oauth2
|
||||||
golang.org/x/oauth2/authhandler
|
golang.org/x/oauth2/authhandler
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue