KeenAuth.Helpers.InputValidator (KeenAuth v1.0.1)

Copy Markdown View Source

Validates input parameters to prevent abuse and ensure security.

This module provides validation for common input fields like provider names and redirect URLs. It helps prevent denial of service through oversized inputs and other input-based attacks.

Summary

Functions

Validates a provider name.

Validates a redirect URL length.

Functions

validate_provider(provider)

@spec validate_provider(binary()) :: {:ok, binary()} | {:error, :invalid_provider}

Validates a provider name.

Returns {:ok, provider} if valid, or {:error, reason} if invalid.

Validation rules:

  • Must not exceed 64 characters
  • Must only contain alphanumeric characters, hyphens, and underscores

validate_redirect_length(url)

@spec validate_redirect_length(binary() | nil) ::
  {:ok, binary() | nil} | {:error, :redirect_too_long}

Validates a redirect URL length.

Returns {:ok, url} if valid, or {:error, reason} if too long.