Skip to content

feat: add GCP Authentication Support#752

Merged
yuzisun merged 12 commits intoenvoyproxy:mainfrom
sukumargaonkar:gcp-auth-implementaion
Jul 2, 2025
Merged

feat: add GCP Authentication Support#752
yuzisun merged 12 commits intoenvoyproxy:mainfrom
sukumargaonkar:gcp-auth-implementaion

Conversation

@sukumargaonkar
Copy link
Copy Markdown
Contributor

@sukumargaonkar sukumargaonkar commented Jun 23, 2025

Description

  • Implement GCP integration via OIDC token rotator.
    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.
  • Add ProjectName and Region field in BackendSecurityPolicyGCPCredentials

1: https://cloud.google.com/iam/docs/workload-identity-federation

Related Issues/PRs (if applicable)
Previous PR: #635
Related Issue: #609

Signed-off-by: Sukumar Gaonkar <sgaonkar4@bloomberg.net>
@sukumargaonkar sukumargaonkar changed the title feat: implement GCP OIDC token rotator for Workload Identity Federation feat: Add GCP Authentication Support Jun 23, 2025
Signed-off-by: Sukumar Gaonkar <sgaonkar4@bloomberg.net>
@sukumargaonkar sukumargaonkar changed the title feat: Add GCP Authentication Support feat: add GCP Authentication Support Jun 25, 2025
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>
@sukumargaonkar sukumargaonkar marked this pull request as ready for review June 27, 2025 17:59
@sukumargaonkar sukumargaonkar requested a review from a team as a code owner June 27, 2025 17:59
@sukumargaonkar
Copy link
Copy Markdown
Contributor Author

The current CI failure is related to test-coverage in internal/testing package, which can be ignored for now

Package coverage threshold (81%) satisfied:	FAIL
  below threshold:				coverage:	threshold:
  internal/testing				74.5% (41/55)	81%

@mathetake mathetake requested a review from aabchoo June 27, 2025 18:01
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>
@yuzisun yuzisun merged commit 10bf331 into envoyproxy:main Jul 2, 2025
24 checks passed
Comment on lines +17 to +20
GCPModelPublisherGoogle = "google"
GCPModelPublisherAnthropic = "anthropic"
GCPMethodGenerateContent = "generateContent"
HTTPHeaderKeyContentLength = "Content-Length"
Copy link
Copy Markdown
Member

@mathetake mathetake Jul 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you unexport them

}
}

func validateGCPCredentialsParams(gcpCreds *aigv1a1.BackendSecurityPolicyGCPCredentials) error {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also add gcp prefix here

Comment on lines +59 to +62
if len(hdr.Header.Value) > 0 {
suffixPath := hdr.Header.Value
hdr.Header.Value = fmt.Sprintf("%s/%s", prefixPath, suffixPath)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@yuzisun
Copy link
Copy Markdown
Contributor

yuzisun commented Jul 2, 2025

@sukumargaonkar can you take a look at @mathetake’s comments and address in the follow up PR?

@mathetake
Copy link
Copy Markdown
Member

@sukumargaonkar also could you add more unit test around here?
image

yuzisun added a commit that referenced this pull request Nov 11, 2025
**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>
hustxiayang pushed a commit to hustxiayang/ai-gateway that referenced this pull request Nov 13, 2025
**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>
missBerg pushed a commit to missBerg/ai-gateway that referenced this pull request Dec 20, 2025
**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>
mtparet pushed a commit to blackfuel-ai/ai-gateway that referenced this pull request Jan 14, 2026
**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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants