Security Validator icon

Security Validator

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

Contains

AI-generated

Overview

The Security Validator node validates API keys, tokens, or other sensitive data by checking if the input key contains an expected substring. It supports multiple input modes for the key, including direct input, environment variables, or JavaScript code expressions. This node is useful in workflows where you need to ensure that an API key or token meets certain criteria before proceeding, such as validating user credentials or securing API access.

Use Case Examples

  1. Validating an API key passed directly in the workflow to ensure it contains a specific substring before allowing further processing.
  2. Using an environment variable to securely provide the API key and checking if it contains a required token segment.
  3. Executing custom JavaScript code to extract an API key from incoming JSON data and validating that it contains a certain substring.

Properties

Name Meaning
Input Mode How to provide the input API key, options include direct input, environment variable, or JavaScript 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 substring to check for containment, used when Input Mode is Direct Input.
Case Sensitive Whether the validation should be case sensitive.
Error Message Message to show when validation fails.

Output

JSON

  • _validation
    • status - Validation status, e.g., 'VALID' if the key contains the expected substring.
    • message - Message describing the validation result.
    • timestamp - Timestamp when the validation was performed.
    • validationType - Type of validation performed, here it is 'contains'.
    • 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.
  • Code expression errors will throw an error with the message from the JavaScript execution failure.
  • Validation fails if the input key does not contain the expected substring, and the custom error message is shown if provided.

Discussion