SelectoComponents.Debug.ProductionConfig (selecto_components v0.3.20)

Secure configuration for enabling debug panel in production.

To enable debug panel in production, you must set BOTH:

  1. SELECTO_DEBUG_ENABLED=true
  2. SELECTO_DEBUG_TOKEN=<secure-random-token>

And include the token in your session or as a query parameter: ?debug_token=<token>

This ensures debug panel cannot be accidentally exposed in production.

Link to this section Summary

Functions

Check if debug mode should be enabled based on environment and security requirements.

Generate a secure random token for production debug access. Run this in IEx to generate a token for your SELECTO_DEBUG_TOKEN env var.

Get the configured debug features based on environment.

Check if the debug panel CSS should be included. This is less strict - we include CSS in dev/test or if debug is configured (but not necessarily authenticated).

Link to this section Functions

Link to this function

debug_enabled?(params \\ %{}, session \\ %{})

Check if debug mode should be enabled based on environment and security requirements.

Debug is opt-in in all environments and requires a request flag:

  • selecto_debug=true (or 1/on/yes) in params or session
  • debug=true (or 1/on/yes) in params or session
  • providing debug_token also counts as an explicit request

In development/test: request flag is sufficient. In production: request flag + explicit configuration + valid token.

Link to this function

generate_secure_token()

Generate a secure random token for production debug access. Run this in IEx to generate a token for your SELECTO_DEBUG_TOKEN env var.

example

Example

iex> SelectoComponents.Debug.ProductionConfig.generate_secure_token()
"7K9mP3nX5vB2qL8wF4hJ6sD1gR0tY..."
Link to this function

get_debug_config(domain_module, view_type, params \\ %{}, session \\ %{})

Get the configured debug features based on environment.

Link to this function

include_debug_assets?()

Check if the debug panel CSS should be included. This is less strict - we include CSS in dev/test or if debug is configured (but not necessarily authenticated).