Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add BackendSecurityPolicy for traffic (authN/authZ) from gateway to provider #43

Merged
merged 47 commits into from
Jan 8, 2025

Conversation

aabchoo
Copy link
Contributor

@aabchoo aabchoo commented Dec 12, 2024

  • add backend security policy for traffic from gateway to backend provider
  • introduces api key, oidc, and static key auth
  • add reference to backendSecurityPolicy on llmbackend
  • add provider type on llmbackend

@aabchoo aabchoo force-pushed the aaron/authorization-api branch 2 times, most recently from 52e389b to 89ee946 Compare December 12, 2024 19:35
aabchoo and others added 7 commits December 12, 2024 14:50
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>

Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
fix yaml files

Signed-off-by: Choo <achoo30@bloomberg.net>
This commit is a follow up on #20. Basically, this makes LLMRoute
a pure "addition" to the existing standardized HTTPRoute.
This makes it possible to configure something like
```
kind: LLMRoute
metadata:
  name: llm-route
spec:
  inputSchema: OpenAI
  httpRouteRef:
    name: my-llm-route
---
kind: HTTPRoute
metadata:
  name: my-llm-route
spec:
  matches:
     - headers:
         key: x-envoy-ai-gateway-llm-model
         value: llama3-70b
       backendRefs:
       - kserve:
         weight: 20
       - aws-bedrock:
         weight: 80
```

where LLMRoute is purely referencing HTTPRoute and
users can configure whatever routing condition in a standardized way
via HTTPRoute while leveraging the LLM specific information, in this
case
x-envoy-ai-gateway-llm-model header.

In the implementation, though it's not merged yet, we have to do the
routing calculation in the extproc by actually analyzing the referenced
HTTPRoute, and emulate the behavior in order to do the transformation.
The reason is that the routing decision is made at the very end of
filter chain
in general, and by the time we invoke extproc, we don't have that info.
Furthermore, `x-envoy-ai-gateway-llm-model` is not available before
extproc.

As a bonus of this, we no longer need TargetRef at LLMRoute level since
that's within
the HTTPRoute resources. This will really simplify the PoC
implementation.

---------

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
This adds `backendRef` to LLMBackendSpec which specifies
the "backend" either Service or Backend resource of Envoy Gateway.

The choice of not embedding is intentional - A backend can be a target
of routing in HTTPRoute and can be either of these two types. Hence
this is not suitable for embedding. In addition, in the implementation, 
we won't directly use or reference them, but just simply attach the 
necessary logic by the names, so basically no benefit by doing so.

---------

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
@aabchoo aabchoo force-pushed the aaron/authorization-api branch from 9fb8a19 to ea69193 Compare December 12, 2024 19:54
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
@aabchoo aabchoo force-pushed the aaron/authorization-api branch from a829fe8 to 57e0fa1 Compare December 13, 2024 15:38
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
@aabchoo aabchoo force-pushed the aaron/authorization-api branch from 19c1337 to d2f72ed Compare December 16, 2024 15:56
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
@yuzisun
Copy link
Contributor

yuzisun commented Jan 4, 2025

@mathetake @arkodg @zhaohuabing can you take another look?

Copy link
Member

@mathetake mathetake left a comment

Choose a reason for hiding this comment

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

LGTM per nits above!

// CloudProviderCredentials is a mechanism to access a backend(s). Cloud provider specific logic will be applied.
//
// +optional
CloudProviderCredentials *AuthenticationCloudProviderCredentials `json:"cloudProviderCredentials,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

so i wonder what kind of logic will make cloud providers special compared to others (currently only apiKey though). how do you envision this additional indirect layer will be used? in other words, what kind of logic will be shared among cloud providers

Copy link
Contributor

@yuzisun yuzisun Jan 4, 2025

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

yeah i get that it's complex, but my question is why this another layer is needed and what kind of logic will be shared among cloud providers? what becomes difficult to achieve when you have *AWSCredentials directly here without another layer of AuthenticationCloudProviderCredentials. How does having AuthenticationCloudProviderCredentials helps implement various cloud providers vs having them in here

Copy link
Contributor

Choose a reason for hiding this comment

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

This is mainly a yaml UX, the additional layer for grouping is there for readability, if we list the individual types then it is not intuitive for user to see the classification. The cloud provider security implementations are different but they share the same high level concepts.

aabchoo and others added 9 commits January 6, 2025 14:54
Co-authored-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Co-authored-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Co-authored-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Co-authored-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
// Only one type of BackendSecurityPolicy can be defined.
// +kubebuilder:validation:MaxProperties=2
type BackendSecurityPolicySpec struct {
// Type specifies the auth mechanism used to access the provider. Currently, only "APIKey", AND "AWS_IAM" are supported.
Copy link
Member

Choose a reason for hiding this comment

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

well, shouldn't the type be "CloudProviders" instead of AWS_IAM? The "type" field is for union type assertion and this feels a weird because AWS_IAM is not for the union type assertion but for the higher layer. @yuzisun @arkodg

Copy link
Member

Choose a reason for hiding this comment

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

This is relevant to the thread to #43 (comment) I am still not convinced by the "Yaml UX" stuff there. I am fine with that but at least to be consistent could you make this CloudProviders and have a type inside it for a specific cloud provider? (which i think is a worse UX vs the flat one)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've flattened it out per req

Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Signed-off-by: Aaron Choo <achoo30@bloomberg.net>
Copy link
Member

@mathetake mathetake left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you for your hard word and multiple iterations here! @aabchoo 💯

@mathetake mathetake merged commit 7ada5ca into main Jan 8, 2025
7 checks passed
@mathetake mathetake deleted the aaron/authorization-api branch January 8, 2025 23:50
mathetake added a commit that referenced this pull request Jan 29, 2025
**Commit Message**:

This adds a secret watcher controller that enables the 
hot reload of any secret referenced by backendTrafficPolicy.

**Related Issues/PRs (if applicable)**:

Follow up on #43  #106 #161 
Supersede #185

---------

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
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.

6 participants