feat: add GCP Authentication Support#752
Conversation
Signed-off-by: Sukumar Gaonkar <sgaonkar4@bloomberg.net>
Signed-off-by: Sukumar Gaonkar <sgaonkar4@bloomberg.net>
Signed-off-by: Sukumar Gaonkar <sgaonkar4@bloomberg.net>
Signed-off-by: Sukumar Gaonkar <sgaonkar4@bloomberg.net>
Signed-off-by: Sukumar Gaonkar <sgaonkar4@bloomberg.net>
Signed-off-by: Sukumar Gaonkar <sgaonkar4@bloomberg.net>
|
The current CI failure is related to test-coverage in |
Signed-off-by: Sukumar Gaonkar <sgaonkar4@bloomberg.net>
Signed-off-by: Sukumar Gaonkar <sgaonkar4@bloomberg.net>
Signed-off-by: Sukumar Gaonkar <sgaonkar4@bloomberg.net> # Conflicts: # api/v1alpha1/api.go # go.sum
Signed-off-by: Sukumar Gaonkar <sgaonkar4@bloomberg.net>
| GCPModelPublisherGoogle = "google" | ||
| GCPModelPublisherAnthropic = "anthropic" | ||
| GCPMethodGenerateContent = "generateContent" | ||
| HTTPHeaderKeyContentLength = "Content-Length" |
| } | ||
| } | ||
|
|
||
| func validateGCPCredentialsParams(gcpCreds *aigv1a1.BackendSecurityPolicyGCPCredentials) error { |
There was a problem hiding this comment.
shouldn't all of this condition be part of k8s CEL validation? (If so, it's redundant)
|
|
||
| // serviceAccountTokenGenerator defines a function type for generating a GCP service account access token | ||
| // using an STS token and impersonation configuration. | ||
| type serviceAccountTokenGenerator func( |
There was a problem hiding this comment.
this needs a gcp prefix in the struct name
| // tokenTypeJWT indicates the subject token type is a JWT. | ||
| tokenTypeJWT = "urn:ietf:params:oauth:token-type:jwt" //nolint:gosec | ||
| // stsTokenScope is the OAuth scope for GCP cloud platform operations. | ||
| stsTokenScope = "https://www.googleapis.com/auth/cloud-platform" //nolint:gosec |
There was a problem hiding this comment.
gcp prefix is needed here as well
|
|
||
| // stsTokenGenerator defines a function type for exchanging a JWT token for a GCP STS token | ||
| // using Workload Identity Federation configuration. | ||
| type stsTokenGenerator func( |
There was a problem hiding this comment.
can you also add gcp prefix here
| if len(hdr.Header.Value) > 0 { | ||
| suffixPath := hdr.Header.Value | ||
| hdr.Header.Value = fmt.Sprintf("%s/%s", prefixPath, suffixPath) | ||
| } |
There was a problem hiding this comment.
i don't think you need this in practice. (Envoy's API naming is really bad here, but) we should stick to .RawValue for setting headers. (.Value is for formatter) https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/core/v3/base.proto#config-core-v3-headervalue
|
@sukumargaonkar can you take a look at @mathetake’s comments and address in the follow up PR? |
|
@sukumargaonkar also could you add more unit test around here? |
**Description** GCP global region endpoint is different from regional endpoint. Current PR is to handle GCP global region to avoid segfault. Related PR: #752 --------- Signed-off-by: Xiaolin Lin <xlin158@bloomberg.net> Signed-off-by: Dan Sun <dsun20@bloomberg.net> Co-authored-by: Dan Sun <dsun20@bloomberg.net>
**Description** GCP global region endpoint is different from regional endpoint. Current PR is to handle GCP global region to avoid segfault. Related PR: envoyproxy#752 --------- Signed-off-by: Xiaolin Lin <xlin158@bloomberg.net> Signed-off-by: Dan Sun <dsun20@bloomberg.net> Co-authored-by: Dan Sun <dsun20@bloomberg.net> Signed-off-by: yxia216 <yxia216@bloomberg.net>
**Description** GCP global region endpoint is different from regional endpoint. Current PR is to handle GCP global region to avoid segfault. Related PR: envoyproxy#752 --------- Signed-off-by: Xiaolin Lin <xlin158@bloomberg.net> Signed-off-by: Dan Sun <dsun20@bloomberg.net> Co-authored-by: Dan Sun <dsun20@bloomberg.net> Signed-off-by: Erica Hughberg <erica.sundberg.90@gmail.com>
**Description** GCP global region endpoint is different from regional endpoint. Current PR is to handle GCP global region to avoid segfault. Related PR: envoyproxy#752 --------- Signed-off-by: Xiaolin Lin <xlin158@bloomberg.net> Signed-off-by: Dan Sun <dsun20@bloomberg.net> Co-authored-by: Dan Sun <dsun20@bloomberg.net>

Description
This PR add support for authenticating against GCP via external OIDC tokens. It uses google's Workload Identity Federation [1] to exchange an OIDC token for GCP's access token. It also support optional service account impersonation.
ProjectNameandRegionfield in BackendSecurityPolicyGCPCredentials1: https://cloud.google.com/iam/docs/workload-identity-federation
Related Issues/PRs (if applicable)
Previous PR: #635
Related Issue: #609