Skip to content

feat(rpc): support multiple API keys - #663

Open
raushan728 wants to merge 1 commit into
solana-foundation:mainfrom
raushan728:feat/multi-api-keys
Open

feat(rpc): support multiple API keys#663
raushan728 wants to merge 1 commit into
solana-foundation:mainfrom
raushan728:feat/multi-api-keys

Conversation

@raushan728

@raushan728 raushan728 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Migrates api_key: Option<String> to api_keys: Option<Vec<String>>, with backward-compatible deserialization for existing single-key configs (with a deprecation warning). Compares keys via fixed-length SHA-256 hashes with constant-time comparison across all configured keys, avoiding any length-dependent timing signal, and stores a key index as the client identity.

Note: this is a split-out of #559.

@greptile-apps

greptile-apps Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds support for multiple configured API keys while retaining backward-compatible deserialization of the legacy single-key setting.

  • Resolves API keys from configuration or the environment and warns when environment configuration overrides multiple keys.
  • Authenticates against every configured key using fixed-size SHA-256 digests and assigns the matched key index as the client identity.
  • Updates validation, test utilities, fixtures, and example configurations for the new array format.
  • The prior key-length timing finding is fixed: comparisons now operate on fixed-size digests, and the authentication loop does not branch on supplied-key length or exit after a match.

Confidence Score: 5/5

The PR appears safe to merge, with the previous timing concern addressed and no new actionable failures identified.

API-key authentication now hashes both sides to fixed-size digests, checks every configured key without early exit, and retains correct matching behavior for keys of different lengths. No repository-rule violations or outstanding previous findings remain.

Important Files Changed

Filename Overview
crates/lib/src/rpc_server/auth.rs Replaces variable-length key comparisons with fixed-size digest comparisons across all configured keys and records the matched key index.
crates/lib/src/config.rs Migrates authentication configuration to multiple keys with legacy single-key deserialization and environment override handling.
crates/lib/src/rpc_server/server.rs Constructs API-key middleware from the resolved list of configured keys.
crates/lib/src/validator/config_validator.rs Adapts configuration warnings to the multi-key environment override behavior.

Reviews (2): Last reviewed commit: "feat(rpc): support multiple API keys wit..." | Re-trigger Greptile

Comment thread crates/lib/src/rpc_server/auth.rs Outdated
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.

1 participant