nic-6443 opened a new pull request, #14246:
URL: https://github.com/apache/apisix/pull/14246

   ### Description
   
   `ai-request-rewrite` takes the credentials for its LLM call in `auth.header` 
and `auth.query`, but its schema declares no `encrypt_fields`, so with 
`data_encryption.enable_encrypt_fields` on these values are still written to 
etcd in plaintext. `ai-proxy` and `ai-proxy-multi` already encrypt the same 
fields.
   
   This PR declares `encrypt_fields = {"auth.header", "auth.query"}`, in the 
same form `ai-proxy` uses. Both fields are maps of strings, and 
`process_encrypt_field` already encrypts/decrypts every string value of a map 
leaf, so no core change is needed.
   
   #### Backward compatibility
   
   Configurations stored before this change keep their plaintext values. When a 
value of a newly declared field cannot be decrypted (a plaintext header such as 
`Bearer ...` is not valid base64, and anything that does decode fails AES 
decryption), `process_encrypt_field` logs it at `info` level and keeps the 
stored value unchanged, so the route keeps sending the original credential. 
Re-saving the configuration through the Admin API stores it encrypted.
   
   #### Tests
   
   Added to `t/node/data_encrypt3.t`, next to the existing `ai-proxy` cases:
   
   - `auth.header` and `auth.query` are encrypted in etcd and returned 
decrypted by the Admin API (fails without the schema change);
   - with each field configured alone, the decrypted credential reaches the LLM 
service and the rewritten request is proxied;
   - a route written to etcd with plaintext credentials is returned unchanged 
by the Admin API and still authenticates to the LLM service.
   
   The plugin docs (en/zh) now state that both fields are stored encrypted.
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [x] I have added tests corresponding to this change
   - [x] I have updated the documentation to reflect this change
   - [x] I have verified that this change is backward compatible
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to