Skip to content

Commit 10d6839

Browse files
authored
deprecate ProjectID as its unused (#10)
1 parent f014068 commit 10d6839

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ Google Cloud Platform (Cloud KMS, IAM API, & AppEngine App Identity API) jwt-go
66

77
Google Cloud KMS [now supports signatures](https://cloud.google.com/kms/docs/create-validate-signatures) and support has been added to gcp-jwt-go!
88

9+
## Breaking Changes with v2.2
10+
11+
- Switched to new iamcredentials API - this no longer allows signBlob to be used on the service account the client is authenticated as.
12+
- `IAMConfig.OAuth2HTTPClient` is deprecrated and unused - Use `IAMConfig.IAMClient` instead.
13+
- `IAMConfig.ProjectID` is deprecrated and unused. The API will infer the project from the service account name.
14+
915
## Breaking Changes with v2.1
1016

1117
- Dropping support for AppEngine Go 1.9 environment (last version with AppEngine App Identity support will be for Go 1.11)

config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type kmsConfigKey struct{}
3535
// IAMConfig is relevant for both the signBlob and signJWT IAM API use-cases
3636
type IAMConfig struct {
3737
// ProjectID is the project id that contains the service account you want to sign with. Defaults to "-" to infer the project from the account
38+
// Depcrecated: This field is no longer used as the API will reject all values other than "-".
3839
ProjectID string
3940

4041
// Service account can be the email address or the uniqueId of the service account used to sign the JWT with

iam.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ func (s *SigningMethodIAM) Sign(signingString string, key interface{}) (string,
6060
}
6161
}
6262

63-
// Default the ProjectID to a wildcard
64-
if config.ProjectID == "" {
65-
config.ProjectID = "-"
66-
}
67-
6863
// Do the call
6964
return s.sign(ctx, iamService, config, signingString)
7065
}

iam_blob.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
var (
1313
// SigningMethodIAMBlob implements signing JWTs with the IAM signBlob API.
14-
// https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts/signBlob
14+
// https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/signBlob
1515
SigningMethodIAMBlob *SigningMethodIAM
1616
)
1717

@@ -31,7 +31,7 @@ func signBlob(ctx context.Context, iamService *iamcredentials.Service, config *I
3131
signReq := &iamcredentials.SignBlobRequest{
3232
Payload: base64.StdEncoding.EncodeToString([]byte(signingString)),
3333
}
34-
name := fmt.Sprintf("projects/%s/serviceAccounts/%s", config.ProjectID, config.ServiceAccount)
34+
name := fmt.Sprintf("projects/-/serviceAccounts/%s", config.ServiceAccount)
3535

3636
// Do the call
3737
signResp, err := iamService.Projects.ServiceAccounts.SignBlob(name, signReq).Context(ctx).Do()

iam_jwt.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
var (
1313
// SigningMethodIAMJWT implements signing JWTs with the IAM signJwt API.
14-
// https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts/signJwt
14+
// https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/signJwt
1515
SigningMethodIAMJWT *SigningMethodIAM
1616
)
1717

@@ -39,7 +39,7 @@ func signJwt(ctx context.Context, iamService *iamcredentials.Service, config *IA
3939
}
4040

4141
signReq := &iamcredentials.SignJwtRequest{Payload: string(jwtClaimSet)}
42-
name := fmt.Sprintf("projects/%s/serviceAccounts/%s", config.ProjectID, config.ServiceAccount)
42+
name := fmt.Sprintf("projects/-/serviceAccounts/%s", config.ServiceAccount)
4343

4444
// Do the call
4545
signResp, err := iamService.Projects.ServiceAccounts.SignJwt(name, signReq).Context(ctx).Do()

0 commit comments

Comments
 (0)