pub struct ApiKeyConfig {Show 26 fields
pub config_id: String,
pub references: ApiKeyReferences,
pub key_length: usize,
pub prefix: Option<String>,
pub default_permissions: Option<HashMap<String, Vec<String>>>,
pub custom_key_generator: Option<Arc<dyn ApiKeyGenerator>>,
pub default_permissions_callback: Option<Arc<dyn ApiKeyDefaultPermissions>>,
pub api_key_headers: Vec<String>,
pub custom_api_key_getter: Option<Arc<dyn ApiKeyGetter>>,
pub custom_api_key_validator: Option<Arc<dyn ApiKeyValidator>>,
pub disable_key_hashing: bool,
pub starting_characters_length: usize,
pub store_starting_characters: bool,
pub max_prefix_length: usize,
pub min_prefix_length: usize,
pub max_name_length: usize,
pub min_name_length: usize,
pub require_name: bool,
pub enable_metadata: bool,
pub key_expiration: KeyExpirationConfig,
pub rate_limit: RateLimitDefaults,
pub enable_session_for_api_keys: bool,
pub storage: ApiKeyStorage,
pub custom_storage: Option<Arc<dyn SecondaryStorage>>,
pub fallback_to_database: bool,
pub defer_updates: bool,
}Expand description
Configuration for the API Key plugin, aligned with the TypeScript ApiKeyOptions.
Fields§
§config_id: StringName of this configuration, stored on every key it creates.
Upstream defaults it to "default".
references: ApiKeyReferencesWhether keys from this configuration belong to a user or to an organization.
key_length: usizeRandom characters per key. Zero selects the upstream default of 64.
prefix: Option<String>§default_permissions: Option<HashMap<String, Vec<String>>>Permissions applied when creation does not supply explicit permissions.
custom_key_generator: Option<Arc<dyn ApiKeyGenerator>>Custom credential generator, receiving the resolved length and prefix.
default_permissions_callback: Option<Arc<dyn ApiKeyDefaultPermissions>>Dynamic defaults, evaluated even when creation supplies explicit permissions.
api_key_headers: Vec<String>§custom_api_key_getter: Option<Arc<dyn ApiKeyGetter>>Overrides header extraction for session emulation.
custom_api_key_validator: Option<Arc<dyn ApiKeyValidator>>Validates the presented plaintext credential before normal key validation.
disable_key_hashing: bool§starting_characters_length: usize§store_starting_characters: bool§max_prefix_length: usize§min_prefix_length: usize§max_name_length: usize§min_name_length: usize§require_name: bool§enable_metadata: bool§key_expiration: KeyExpirationConfig§rate_limit: RateLimitDefaults§enable_session_for_api_keys: bool§storage: ApiKeyStoragePersistence mode. Custom storage overrides the global secondary storage.
custom_storage: Option<Arc<dyn SecondaryStorage>>§fallback_to_database: boolKeep database rows authoritative and repopulate cache misses.
defer_updates: boolDefer secondary-only usage writes and expired/exhausted key deletion.