Env.schema.secret: New Secret Schema Type for Environment Variables
· Developer impact : medium
The documentation for AdonisJS v7 has been updated to introduce a new environment variable schema type called Env.schema.secret. This schema validates that the value is a non-empty string and wraps it in a Secret instance, designed for sensitive values like API tokens and encryption keys. The secret values are redacted in logs and serialization by default, and can be accessed as plain strings by calling the .release() method.
Developers can now use Env.schema.secret() in their environment variable schemas to securely handle sensitive data. This improves security by preventing accidental logging or serialization of secrets. The new schema type is documented with examples showing how to define secrets and how to retrieve their plain string values when necessary.
- Update environment variable schemas to use Env.schema.secret() for sensitive values such as APP_KEY and API tokens.
- Use the .release() method to access the plain string value of a secret when passing it to libraries or APIs that require a string.
- Be aware that once released, the secret value is no longer protected from logging or serialization.
Updated documentation
Original sources
AI-generated analysis based on the linked sources. Check the original documentation before changing your application.