Skip to content

Commit 12ced35

Browse files
authored
Merge branch 'golang:master' into custom-header-prefix
2 parents 1e1fbf6 + b9c813b commit 12ced35

File tree

11 files changed

+68
-24
lines changed

11 files changed

+68
-24
lines changed

LICENSE

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2009 The Go Authors. All rights reserved.
1+
Copyright 2009 The Go Authors.
22

33
Redistribution and use in source and binary forms, with or without
44
modification, are permitted provided that the following conditions are
@@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer.
1010
copyright notice, this list of conditions and the following disclaimer
1111
in the documentation and/or other materials provided with the
1212
distribution.
13-
* Neither the name of Google Inc. nor the names of its
13+
* Neither the name of Google LLC nor the names of its
1414
contributors may be used to endorse or promote products derived from
1515
this software without specific prior written permission.
1616

README.md

+5-10
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@
55

66
oauth2 package contains a client implementation for OAuth 2.0 spec.
77

8-
## Installation
9-
10-
~~~~
11-
go get golang.org/x/oauth2
12-
~~~~
13-
14-
Or you can manually git clone the repository to
15-
`$(go env GOPATH)/src/golang.org/x/oauth2`.
16-
178
See pkg.go.dev for further documentation and examples.
189

1910
* [pkg.go.dev/golang.org/x/oauth2](https://pkg.go.dev/golang.org/x/oauth2)
@@ -33,7 +24,11 @@ The main issue tracker for the oauth2 repository is located at
3324
https://github.com/golang/oauth2/issues.
3425

3526
This repository uses Gerrit for code changes. To learn how to submit changes to
36-
this repository, see https://golang.org/doc/contribute.html. In particular:
27+
this repository, see https://go.dev/doc/contribute.
28+
29+
The git repository is https://go.googlesource.com/oauth2.
30+
31+
Note:
3732

3833
* Excluding trivial changes, all contributions should be connected to an existing issue.
3934
* API changes must go through the [change proposal process](https://go.dev/s/proposal-process) before they can be accepted.

clientcredentials/clientcredentials.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type Config struct {
3737
// URL. This is a constant specific to each server.
3838
TokenURL string
3939

40-
// Scope specifies optional requested permissions.
40+
// Scopes specifies optional requested permissions.
4141
Scopes []string
4242

4343
// EndpointParams specifies additional parameters for requests to the token endpoint.

endpoints/endpoints.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ var GitHub = oauth2.Endpoint{
6262

6363
// GitLab is the endpoint for GitLab.
6464
var GitLab = oauth2.Endpoint{
65-
AuthURL: "https://gitlab.com/oauth/authorize",
66-
TokenURL: "https://gitlab.com/oauth/token",
65+
AuthURL: "https://gitlab.com/oauth/authorize",
66+
TokenURL: "https://gitlab.com/oauth/token",
67+
DeviceAuthURL: "https://gitlab.com/oauth/authorize_device",
6768
}
6869

6970
// Google is the endpoint for Google.

gitlab/gitlab.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66
package gitlab // import "golang.org/x/oauth2/gitlab"
77

88
import (
9-
"golang.org/x/oauth2"
9+
"golang.org/x/oauth2/endpoints"
1010
)
1111

1212
// Endpoint is GitLab's OAuth 2.0 endpoint.
13-
var Endpoint = oauth2.Endpoint{
14-
AuthURL: "https://gitlab.com/oauth/authorize",
15-
TokenURL: "https://gitlab.com/oauth/token",
16-
}
13+
var Endpoint = endpoints.GitLab

google/default.go

+12
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,12 @@ func FindDefaultCredentials(ctx context.Context, scopes ...string) (*Credentials
251251
// a Google Developers service account key file, a gcloud user credentials file (a.k.a. refresh
252252
// token JSON), or the JSON configuration file for workload identity federation in non-Google cloud
253253
// platforms (see https://cloud.google.com/iam/docs/how-to#using-workload-identity-federation).
254+
//
255+
// Important: If you accept a credential configuration (credential JSON/File/Stream) from an
256+
// external source for authentication to Google Cloud Platform, you must validate it before
257+
// providing it to any Google API or library. Providing an unvalidated credential configuration to
258+
// Google APIs can compromise the security of your systems and data. For more information, refer to
259+
// [Validate credential configurations from external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
254260
func CredentialsFromJSONWithParams(ctx context.Context, jsonData []byte, params CredentialsParams) (*Credentials, error) {
255261
// Make defensive copy of the slices in params.
256262
params = params.deepCopy()
@@ -294,6 +300,12 @@ func CredentialsFromJSONWithParams(ctx context.Context, jsonData []byte, params
294300
}
295301

296302
// CredentialsFromJSON invokes CredentialsFromJSONWithParams with the specified scopes.
303+
//
304+
// Important: If you accept a credential configuration (credential JSON/File/Stream) from an
305+
// external source for authentication to Google Cloud Platform, you must validate it before
306+
// providing it to any Google API or library. Providing an unvalidated credential configuration to
307+
// Google APIs can compromise the security of your systems and data. For more information, refer to
308+
// [Validate credential configurations from external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
297309
func CredentialsFromJSON(ctx context.Context, jsonData []byte, scopes ...string) (*Credentials, error) {
298310
var params CredentialsParams
299311
params.Scopes = scopes

google/externalaccount/aws.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828

2929
// AwsSecurityCredentials models AWS security credentials.
3030
type AwsSecurityCredentials struct {
31-
// AccessKeyId is the AWS Access Key ID - Required.
31+
// AccessKeyID is the AWS Access Key ID - Required.
3232
AccessKeyID string `json:"AccessKeyID"`
3333
// SecretAccessKey is the AWS Secret Access Key - Required.
3434
SecretAccessKey string `json:"SecretAccessKey"`

google/externalaccount/basecredentials.go

+33-1
Original file line numberDiff line numberDiff line change
@@ -278,20 +278,52 @@ type Format struct {
278278
type CredentialSource struct {
279279
// File is the location for file sourced credentials.
280280
// One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
281+
//
282+
// Important: If you accept a credential configuration (credential
283+
// JSON/File/Stream) from an external source for authentication to Google
284+
// Cloud Platform, you must validate it before providing it to any Google
285+
// API or library. Providing an unvalidated credential configuration to
286+
// Google APIs can compromise the security of your systems and data. For
287+
// more information, refer to [Validate credential configurations from
288+
// external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
281289
File string `json:"file"`
282290

283291
// Url is the URL to call for URL sourced credentials.
284292
// One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
293+
//
294+
// Important: If you accept a credential configuration (credential
295+
// JSON/File/Stream) from an external source for authentication to Google
296+
// Cloud Platform, you must validate it before providing it to any Google
297+
// API or library. Providing an unvalidated credential configuration to
298+
// Google APIs can compromise the security of your systems and data. For
299+
// more information, refer to [Validate credential configurations from
300+
// external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
285301
URL string `json:"url"`
286302
// Headers are the headers to attach to the request for URL sourced credentials.
287303
Headers map[string]string `json:"headers"`
288304

289305
// Executable is the configuration object for executable sourced credentials.
290306
// One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
307+
//
308+
// Important: If you accept a credential configuration (credential
309+
// JSON/File/Stream) from an external source for authentication to Google
310+
// Cloud Platform, you must validate it before providing it to any Google
311+
// API or library. Providing an unvalidated credential configuration to
312+
// Google APIs can compromise the security of your systems and data. For
313+
// more information, refer to [Validate credential configurations from
314+
// external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
291315
Executable *ExecutableConfig `json:"executable"`
292316

293317
// EnvironmentID is the EnvironmentID used for AWS sourced credentials. This should start with "AWS".
294318
// One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
319+
//
320+
// Important: If you accept a credential configuration (credential
321+
// JSON/File/Stream) from an external source for authentication to Google
322+
// Cloud Platform, you must validate it before providing it to any Google
323+
// API or library. Providing an unvalidated credential configuration to
324+
// Google APIs can compromise the security of your systems and data. For
325+
// more information, refer to [Validate credential configurations from
326+
// external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
295327
EnvironmentID string `json:"environment_id"`
296328
// RegionURL is the metadata URL to retrieve the region from for EC2 AWS credentials.
297329
RegionURL string `json:"region_url"`
@@ -329,7 +361,7 @@ type SubjectTokenSupplier interface {
329361
type AwsSecurityCredentialsSupplier interface {
330362
// AwsRegion should return the AWS region or an error.
331363
AwsRegion(ctx context.Context, options SupplierOptions) (string, error)
332-
// GetAwsSecurityCredentials should return a valid set of AwsSecurityCredentials or an error.
364+
// AwsSecurityCredentials should return a valid set of AwsSecurityCredentials or an error.
333365
// The external account token source does not cache the returned security credentials, so caching
334366
// logic should be implemented in the supplier to prevent multiple requests for the same security credentials.
335367
AwsSecurityCredentials(ctx context.Context, options SupplierOptions) (*AwsSecurityCredentials, error)

jwt/example_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"golang.org/x/oauth2/jwt"
1111
)
1212

13-
func ExampleJWTConfig() {
13+
func ExampleConfig() {
1414
ctx := context.Background()
1515
conf := &jwt.Config{
1616

oauth2.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type Config struct {
5656
// the OAuth flow, after the resource owner's URLs.
5757
RedirectURL string
5858

59-
// Scope specifies optional requested permissions.
59+
// Scopes specifies optional requested permissions.
6060
Scopes []string
6161

6262
// authStyleCache caches which auth style to use when Endpoint.AuthStyle is

token.go

+7
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ type Token struct {
4949
// mechanisms for that TokenSource will not be used.
5050
Expiry time.Time `json:"expiry,omitempty"`
5151

52+
// ExpiresIn is the OAuth2 wire format "expires_in" field,
53+
// which specifies how many seconds later the token expires,
54+
// relative to an unknown time base approximately around "now".
55+
// It is the application's responsibility to populate
56+
// `Expiry` from `ExpiresIn` when required.
57+
ExpiresIn int64 `json:"expires_in,omitempty"`
58+
5259
// raw optionally contains extra metadata from the server
5360
// when updating a token.
5461
raw interface{}

0 commit comments

Comments
 (0)