diff options
Diffstat (limited to 'vendor')
| -rw-r--r-- | vendor/golang.org/x/oauth2/README.md | 12 | ||||
| -rw-r--r-- | vendor/golang.org/x/oauth2/oauth2.go | 33 | ||||
| -rw-r--r-- | vendor/golang.org/x/oauth2/token.go | 14 | ||||
| -rw-r--r-- | vendor/modules.txt | 2 | 
4 files changed, 53 insertions, 8 deletions
| diff --git a/vendor/golang.org/x/oauth2/README.md b/vendor/golang.org/x/oauth2/README.md index 1473e1296..781770c20 100644 --- a/vendor/golang.org/x/oauth2/README.md +++ b/vendor/golang.org/x/oauth2/README.md @@ -19,7 +19,7 @@ See pkg.go.dev for further documentation and examples.  * [pkg.go.dev/golang.org/x/oauth2](https://pkg.go.dev/golang.org/x/oauth2)  * [pkg.go.dev/golang.org/x/oauth2/google](https://pkg.go.dev/golang.org/x/oauth2/google) -## Policy for new packages +## Policy for new endpoints  We no longer accept new provider-specific packages in this repo if all  they do is add a single endpoint variable. If you just want to add a @@ -29,8 +29,12 @@ package.  ## Report Issues / Send Patches -This repository uses Gerrit for code changes. To learn how to submit changes to -this repository, see https://golang.org/doc/contribute.html. -  The main issue tracker for the oauth2 repository is located at  https://github.com/golang/oauth2/issues. + +This repository uses Gerrit for code changes. To learn how to submit changes to +this repository, see https://golang.org/doc/contribute.html. In particular: + +* Excluding trivial changes, all contributions should be connected to an existing issue. +* API changes must go through the [change proposal process](https://go.dev/s/proposal-process) before they can be accepted. +* The code owners are listed at [dev.golang.org/owners](https://dev.golang.org/owners#:~:text=x/oauth2). diff --git a/vendor/golang.org/x/oauth2/oauth2.go b/vendor/golang.org/x/oauth2/oauth2.go index 291df5c83..9085fabe3 100644 --- a/vendor/golang.org/x/oauth2/oauth2.go +++ b/vendor/golang.org/x/oauth2/oauth2.go @@ -16,6 +16,7 @@ import (  	"net/url"  	"strings"  	"sync" +	"time"  	"golang.org/x/oauth2/internal"  ) @@ -140,7 +141,7 @@ func SetAuthURLParam(key, value string) AuthCodeOption {  //  // State is a token to protect the user from CSRF attacks. You must  // always provide a non-empty string and validate that it matches the -// the state query parameter on your redirect callback. +// state query parameter on your redirect callback.  // See http://tools.ietf.org/html/rfc6749#section-10.12 for more info.  //  // Opts may include AccessTypeOnline or AccessTypeOffline, as well @@ -290,6 +291,8 @@ type reuseTokenSource struct {  	mu sync.Mutex // guards t  	t  *Token + +	expiryDelta time.Duration  }  // Token returns the current token if it's still valid, else will @@ -305,6 +308,7 @@ func (s *reuseTokenSource) Token() (*Token, error) {  	if err != nil {  		return nil, err  	} +	t.expiryDelta = s.expiryDelta  	s.t = t  	return t, nil  } @@ -379,3 +383,30 @@ func ReuseTokenSource(t *Token, src TokenSource) TokenSource {  		new: src,  	}  } + +// ReuseTokenSource returns a TokenSource that acts in the same manner as the +// TokenSource returned by ReuseTokenSource, except the expiry buffer is +// configurable. The expiration time of a token is calculated as +// t.Expiry.Add(-earlyExpiry). +func ReuseTokenSourceWithExpiry(t *Token, src TokenSource, earlyExpiry time.Duration) TokenSource { +	// Don't wrap a reuseTokenSource in itself. That would work, +	// but cause an unnecessary number of mutex operations. +	// Just build the equivalent one. +	if rt, ok := src.(*reuseTokenSource); ok { +		if t == nil { +			// Just use it directly, but set the expiryDelta to earlyExpiry, +			// so the behavior matches what the user expects. +			rt.expiryDelta = earlyExpiry +			return rt +		} +		src = rt.new +	} +	if t != nil { +		t.expiryDelta = earlyExpiry +	} +	return &reuseTokenSource{ +		t:           t, +		new:         src, +		expiryDelta: earlyExpiry, +	} +} diff --git a/vendor/golang.org/x/oauth2/token.go b/vendor/golang.org/x/oauth2/token.go index 822720341..7c64006de 100644 --- a/vendor/golang.org/x/oauth2/token.go +++ b/vendor/golang.org/x/oauth2/token.go @@ -16,10 +16,10 @@ import (  	"golang.org/x/oauth2/internal"  ) -// expiryDelta determines how earlier a token should be considered +// defaultExpiryDelta determines how earlier a token should be considered  // expired than its actual expiration time. It is used to avoid late  // expirations due to client-server time mismatches. -const expiryDelta = 10 * time.Second +const defaultExpiryDelta = 10 * time.Second  // Token represents the credentials used to authorize  // the requests to access protected resources on the OAuth 2.0 @@ -52,6 +52,11 @@ type Token struct {  	// raw optionally contains extra metadata from the server  	// when updating a token.  	raw interface{} + +	// expiryDelta is used to calculate when a token is considered +	// expired, by subtracting from Expiry. If zero, defaultExpiryDelta +	// is used. +	expiryDelta time.Duration  }  // Type returns t.TokenType if non-empty, else "Bearer". @@ -127,6 +132,11 @@ func (t *Token) expired() bool {  	if t.Expiry.IsZero() {  		return false  	} + +	expiryDelta := defaultExpiryDelta +	if t.expiryDelta != 0 { +		expiryDelta = t.expiryDelta +	}  	return t.Expiry.Round(0).Add(-expiryDelta).Before(timeNow())  } diff --git a/vendor/modules.txt b/vendor/modules.txt index dfc91b63f..2b5e8fcb2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -788,7 +788,7 @@ golang.org/x/net/internal/socket  golang.org/x/net/ipv4  golang.org/x/net/ipv6  golang.org/x/net/publicsuffix -# golang.org/x/oauth2 v0.6.0 +# golang.org/x/oauth2 v0.7.0  ## explicit; go 1.17  golang.org/x/oauth2  golang.org/x/oauth2/internal | 
