-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: As a user, I want to reference a secret in ai-proxy plugin, so that I don't have to write the apikey in plain text in plugin configuration #13132
Description
Description
Context
Currently, ai-proxy plugin supports auth in 3 ways:
auth.header- plain text value in plugin configauth.query- plain text value in plugin configauth.gcp- with JSON auth file with service account in plugin config or ENV var (GCP_SERVICE_ACCOUNT)
Goal/Use Case
I have a Kubernetes deployment (APISIX Ingress Controller) and Secret resources created/updated via an external secret vault service. This allows, for example, to rotate secret values without redeploying APISIX instances.
I'd like to avoid writing the API key value in my plugin's config and use, for example, a reference to the secret resource, similarly to how *-auth plugin works on Consumer, with authParameter (APISIX Ingress Controller Docs | ApisixConsumer).
Proposal
I'd like to discuss the following implementations and understand if and why they can (or cannot) be implemented:
-
Support auth via environment variables reference, similarly to Consumer's *-auth plugins
$ENV://$env_name/$sub_key.Example usage:
routes: - id: ai_endpoint uri: /ai/chat/completions plugins: ai-proxy: provider: openai-compatible auth: header: Authorization: Bearer $ENV://MY_API_TOKEN # ...
For reference: APISIX Docs | Secret - Use environment variables to manage secrets
-
Support auth via some sort of secret reference, e.g.
$secret.secret_id:routes: - id: ai_endpoint uri: /ai/chat/completions plugins: ai-proxy: provider: openai-compatible auth: header: Authorization: Bearer $secret.my_secret_id # ...
-
Perform context variable resolution on auth parameters (
queryandheader). The token could be fetched and injected via another plugin or something similar:routes: - id: ai_endpoint uri: /ai/chat/completions plugins: serverless-pre-function: phase: rewrite functions: - | return function(conf, ctx) # Some logic to fetch the secret ctx.var.my_secret = "abc123" end ai-proxy: provider: openai-compatible auth: header: Authorization: Bearer $my_secret # ...
-
Other? Maybe consumer-based?
I also have another question: why do *-auth plugin support secret resolution via $ENV:// and $secret:// but others do not? Is there a specific design choice?
Metadata
Metadata
Assignees
Labels
Type
Projects
Status