Join our Newsletter — 33% off our NHI Course
Architecture & Implementation

Schema.lua

← Back to Glossary
By NHI Mgmt Group Updated September 24, 2026 Domain: Architecture & Implementation

Schema.lua is the configuration definition for a Kong plugin. It declares the fields, defaults, and validation rules that control how users configure the plugin, which makes plugin behavior configurable without editing the core handler logic for every deployment.

What Schema.lua Controls

Schema.lua is the plugin contract that defines which configuration values a Kong plugin accepts, what defaults apply, and how input is validated before the handler runs. It separates configuration logic from execution logic, which makes plugin behavior predictable across deployments.

Because the schema is enforced before runtime behavior is evaluated, it is part of the plugin’s control plane. That means the schema shapes not only what users can set, but also what bad input is rejected, what types are coerced, and which combinations of fields are allowed.

How Schema.lua Shapes Plugin Behavior

A well-designed Schema.lua file gives the plugin a stable interface. Fields, required settings, enumerations, nested records, and conditional rules define the acceptable configuration surface, while defaults reduce repetition and keep common settings consistent.

This matters because the schema becomes the source of truth for configuration parsing. If the schema is too loose, invalid or ambiguous settings can reach the handler. If it is too rigid or poorly documented, valid operational use cases become hard to express and the plugin becomes brittle.

Schema.lua also influences upgrade behavior. When a plugin evolves, schema changes can alter compatibility, deprecate fields, or introduce new validation paths. In practice, the schema is where maintainers decide whether a configuration change should be accepted, normalized, warned on, or rejected outright.

Validation, Defaults, and Safe Configuration Boundaries

The most important job of Schema.lua is to enforce safe boundaries around plugin input. Validation prevents malformed configuration from being interpreted as executable logic, and defaults ensure the plugin behaves sensibly when operators omit optional values.

For Kong plugin authors, this is especially important because configuration often arrives from multiple operators, environments, or automation paths. A strong schema limits accidental misuse, makes drift easier to detect, and reduces reliance on defensive checks scattered through the handler.

Schema design also affects usability. Clear field names, precise types, and consistent defaults help operators understand what the plugin expects without reading implementation details. That makes the schema not just a validator, but a durable form of documentation.

Why Schema.lua Matters for Kong Plugin Architecture

Schema.lua is part of what makes Kong plugins modular. The handler can focus on request processing, while the schema defines how the plugin is configured and what input is considered valid. This separation improves maintainability and makes plugin behavior easier to reason about.

In larger environments, that separation also supports safer rollout patterns. Operators can review and test configuration independently from runtime code, and changes to schema become a formal part of plugin versioning. For teams managing many plugins, the schema is where compatibility, clarity, and operational guardrails converge.

When the plugin exposes sensitive behavior, such as routing, transformation, authentication-adjacent logic, or upstream interaction, the schema becomes even more important because it determines which settings are possible at all. In other words, Schema.lua does not just describe a plugin, it constrains its safe operating envelope.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

NIST SP 800-53 Rev 5, OWASP ASVS and CIS Controls v8 set the technical controls, while ISO/IEC 27001:2022 defines the regulatory obligations.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5CM-2 — Baseline ConfigurationSchema.lua defines the approved configuration surface for a plugin.
CM-6 — Configuration SettingsSchema.lua constrains which settings and defaults are allowed.
Recommendation — Define and review the plugin schema as the authoritative configuration baseline. Enforce approved configuration settings through the schema rather than handler logic.
OWASP ASVSV15 — Secure Coding and ArchitectureSchema-driven validation separates input rules from execution logic.
Recommendation — Use schema validation to keep configuration checks out of runtime code paths.
ISO/IEC 27001:2022A.8.9 — Configuration managementSchema.lua governs how plugin configuration is defined and controlled.
Recommendation — Manage plugin schema changes under configuration management and version control.
CIS Controls v8CIS-4 — Secure Configuration of Enterprise Assets and SoftwareThe schema hardens acceptable plugin configuration before deployment.
Recommendation — Use the schema to standardize secure plugin configuration defaults and validation.

Deepen Your Knowledge

Sign up to our weekly newsletter — get 33% off our NHI Foundation Level Course

    NHIMG Editorial Note
    Reviewed and updated by the NHIMG editorial team on September 24, 2026.
    NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org