pub fn init_security_config(
schema_json_str: &str,
) -> Result<SecurityConfigFromSchema>Expand description
Initialize security configuration from compiled schema JSON string
Loads security settings from the schema.compiled.json and applies environment variable overrides. This function should be called during server startup after loading the compiled schema.
§SECURITY
- Validates schema JSON size to prevent DOS attacks
- Rejects JSON > 10 MB
- Rejects security config section > 100 KB
§Arguments
schema_json_str- The compiled schema as a JSON string
§Returns
Returns a configured SecurityConfigFromSchema with environment overrides applied
§Errors
Returns error if:
- JSON size exceeds limits
- JSON parsing fails
- Security configuration section is invalid or missing required fields
§Example
// Requires: compiled schema JSON string loaded from disk or a schema loader.
use fraiseql_auth::security_init::init_security_config;
let json_str = r#"{"security":{"auditLogging":{"enabled":true}}}"#;
let security_config = init_security_config(json_str)?;