feat: add allow list to API keys (#19972)

Add API key allow list to the SDK

This PR adds an allow list to API keys in the SDK. The allow list is a list of targets that the API key is allowed to access. If the allow list is empty, a default allow list with a single entry that allows access to all resources is created.

The changes include:

- Adding a default allow list when generating an API key if none is provided
- Adding allow list to the API key response in the SDK
- Converting database allow list entries to SDK format in the API response
- Adding tests to verify the default allow list behavior



Fixes #19854
This commit is contained in:
Thomas Kosiewski
2025-10-24 12:33:56 +01:00
committed by GitHub
parent f947a34103
commit f684831f56
14 changed files with 162 additions and 47 deletions
+2 -1
View File
@@ -1126,7 +1126,8 @@ CREATE TABLE api_keys (
ip_address inet DEFAULT '0.0.0.0'::inet NOT NULL,
token_name text DEFAULT ''::text NOT NULL,
scopes api_key_scope[] NOT NULL,
allow_list text[] NOT NULL
allow_list text[] NOT NULL,
CONSTRAINT api_keys_allow_list_not_empty CHECK ((array_length(allow_list, 1) > 0))
);
COMMENT ON COLUMN api_keys.hashed_secret IS 'hashed_secret contains a SHA256 hash of the key secret. This is considered a secret and MUST NOT be returned from the API as it is used for API key encryption in app proxying code.';