Skip to content

Commit 17b743f

Browse files
committed
Merge tag 'v0.28.0'
2 parents 683866e + 0042180 commit 17b743f

File tree

20 files changed

+111
-63
lines changed

20 files changed

+111
-63
lines changed

LICENSE

Lines changed: 2 additions & 2 deletions
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

Lines changed: 5 additions & 10 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ var Cern = oauth2.Endpoint{
3535
TokenURL: "https://oauth.web.cern.ch/OAuth/Token",
3636
}
3737

38+
// Discord is the endpoint for Discord.
39+
var Discord = oauth2.Endpoint{
40+
AuthURL: "https://discord.com/oauth2/authorize",
41+
TokenURL: "https://discord.com/api/oauth2/token",
42+
}
43+
3844
// Facebook is the endpoint for Facebook.
3945
var Facebook = oauth2.Endpoint{
4046
AuthURL: "https://www.facebook.com/v3.2/dialog/oauth",
@@ -62,8 +68,9 @@ var GitHub = oauth2.Endpoint{
6268

6369
// GitLab is the endpoint for GitLab.
6470
var GitLab = oauth2.Endpoint{
65-
AuthURL: "https://gitlab.com/oauth/authorize",
66-
TokenURL: "https://gitlab.com/oauth/token",
71+
AuthURL: "https://gitlab.com/oauth/authorize",
72+
TokenURL: "https://gitlab.com/oauth/token",
73+
DeviceAuthURL: "https://gitlab.com/oauth/authorize_device",
6774
}
6875

6976
// Google is the endpoint for Google.
@@ -145,6 +152,12 @@ var Odnoklassniki = oauth2.Endpoint{
145152
TokenURL: "https://api.odnoklassniki.ru/oauth/token.do",
146153
}
147154

155+
// Patreon is the endpoint for Patreon.
156+
var Patreon = oauth2.Endpoint{
157+
AuthURL: "https://www.patreon.com/oauth2/authorize",
158+
TokenURL: "https://www.patreon.com/api/oauth2/token",
159+
}
160+
148161
// PayPal is the endpoint for PayPal.
149162
var PayPal = oauth2.Endpoint{
150163
AuthURL: "https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize",

gitlab/gitlab.go

Lines changed: 2 additions & 5 deletions
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

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module golang.org/x/oauth2
22

3-
go 1.18
3+
go 1.23.0
44

55
require (
66
cloud.google.com/go/compute/metadata v0.3.0

google/default.go

Lines changed: 12 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ const (
263263
fileTypeJSON = "json"
264264
)
265265

266-
// Format contains information needed to retireve a subject token for URL or File sourced credentials.
266+
// Format contains information needed to retrieve a subject token for URL or File sourced credentials.
267267
type Format struct {
268268
// Type should be either "text" or "json". This determines whether the file or URL sourced credentials
269269
// expect a simple text subject token or if the subject token will be contained in a JSON object.
@@ -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)

google/externalaccount/basecredentials_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,12 @@ func TestNonworkforceWithWorkforcePoolUserProject(t *testing.T) {
347347
t.Fatalf("Expected error but found none")
348348
}
349349
if got, want := err.Error(), "oauth2/google/externalaccount: Workforce pool user project should not be set for non-workforce pool credentials"; got != want {
350-
t.Errorf("Incorrect error received.\nExpected: %s\nRecieved: %s", want, got)
350+
t.Errorf("Incorrect error received.\nExpected: %s\nReceived: %s", want, got)
351351
}
352352
}
353353

354354
func TestWorkforcePoolCreation(t *testing.T) {
355-
var audienceValidatyTests = []struct {
355+
var audienceValidityTests = []struct {
356356
audience string
357357
expectSuccess bool
358358
}{
@@ -371,7 +371,7 @@ func TestWorkforcePoolCreation(t *testing.T) {
371371
}
372372

373373
ctx := context.Background()
374-
for _, tt := range audienceValidatyTests {
374+
for _, tt := range audienceValidityTests {
375375
t.Run(" "+tt.audience, func(t *testing.T) { // We prepend a space ahead of the test input when outputting for sake of readability.
376376
config := testConfig
377377
config.TokenURL = "https://sts.googleapis.com" // Setting the most basic acceptable tokenURL

0 commit comments

Comments
 (0)