googleapis / googleapis/google-cloud-java

Cloud Function Service Client load credentials through String

未关闭
#10,005 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
auth priority: p2 type: feature request
主要语言
Java
星标
2.1k
派生
1.2k
平均合并
1 天 23 小时
30 天内合并 PR
157

描述

Thanks for stopping by to let us know something could be better!

**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response.

**Is your feature request related to a problem? Please describe.**
I want to load my GCP credentials for the Cloud Function Service Client thru env variable of json string (that contains the contents of GCP credentials) but I can't find it [here](https://github.com/googleapis/google-cloud-java/blob/0d6459c4c189f572e07640b3789f0cc8cd2a2a45/java-functions/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/CloudFunctionsServiceClient.java#L151). Is it not supported?
```json
{
"type": "external_account",
"audience": "//iam.googleapis.com/projects/blabla/locations/blabla/workloadIdentityPools/...",
"subject_token_type": "urn:ietf:params:aws:token-type:aws4_request",
"token_url": "https://sts.googleapis.com/v1/token",
"credential_source": {
"environment_id": "aws1",
"region_url": "http://someip/latest/meta-data/placement/availability-zone",
"url": "http://someip/latest/meta-data/iam/security-credentials",
"regional_cred_verification_url": "https://sts.{region}.amazonaws.com?Action=GetCallerIdentity&Version=2011-06-15"
},
"service_account_impersonation_url": "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/blablabla"
}
```

**Describe the solution you'd like**
I would like a constructor for this client that uses a json string of the contents of the credentials file.
```java
### JsonNode type
public static final CloudFunctionsServiceClient create(JsonNode credentials) throws IOException {
return create(CloudFunctionsServiceSettings.newBuilder().build());
}

### String type
public static final CloudFunctionsServiceClient create(String jsonCredentials) throws IOException {
return create(CloudFunctionsServiceSettings.newBuilder().build());
}
```

**Describe alternatives you've considered**
Used the file and the credential json file path set as an environment variable, but our security measures dictate that no credentials are to be saved as files.

贡献指南

打开贡献指南

调研方向

Start in java-functions/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/CloudFunctionsServiceClient.java at the credential-loading entry point linked in the issue, then compare it with CloudFunctionsServiceSettings. Check how a JSON credential string could be passed without a file; done means the Cloud Functions client can be created from the requested credential contents and the behavior is covered by appropriate tests.

由索引模型根据 Issue 内容生成。

评估

技术栈
gcp, java
领域
api, authentication, cloud
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。