Security Validator icon

Security Validator

Validate API keys, tokens and sensitive data - stops workflow if invalid, passes all data if valid

Starts With

AI-generated

Overview

The Security Validator node validates API keys or tokens by checking if the provided input key starts with an expected prefix. It supports multiple input modes for the key, including direct input, environment variables, and JavaScript code expressions. This node is useful in workflows where API key validation is required to ensure secure access before proceeding, such as validating incoming API requests or tokens before processing data.

Use Case Examples

  1. Validate an API key passed directly in the workflow to ensure it starts with a specific prefix.
  2. Use an environment variable to securely validate an API key without exposing it in the workflow.
  3. Run a custom JavaScript expression to extract and validate an API key from complex input data.

Properties

Name Meaning
Input Mode How to provide the input API key (direct input, environment variable, or code expression).
Input Key (API Key/Token) The API key to validate, used when Input Mode is Direct Input.
Environment Variable Name Name of the environment variable containing the API key, used when Input Mode is Environment Variable.
JavaScript Code JavaScript code that returns the API key to validate, used when Input Mode is Code Expression.
Expected Key (API Key/Token) The expected API key prefix to validate against, used when Input Mode is Direct Input.
Case Sensitive Whether the validation should be case sensitive.
Error Message Custom error message to show when validation fails.

Output

JSON

  • _validation
    • status - Validation status, e.g., 'VALID' if the API key validation passed.
    • message - Message describing the validation result.
    • timestamp - Timestamp when the validation was performed.
    • validationType - Type of validation performed, here it is 'startsWith'.
    • inputMode - Input mode used to provide the API key.

Dependencies

  • Requires access to environment variables if using environment variable input mode.

Troubleshooting

  • If using environment variable mode, ensure the environment variable is set and not empty; otherwise, an error is thrown.
  • If the input key is empty or missing, the node throws an error indicating the input value is required.
  • If the expected key is missing in direct input mode, an error is thrown indicating the expected key is required.
  • If the JavaScript code expression throws an error, the node reports a code execution error with the message.
  • Validation fails if the input key does not start with the expected prefix, triggering the custom or default error message.

Discussion