onddo/boxbilling-cookbook

View on GitHub
templates/default/api-config.php.erb

Summary

Maintainability
Test Coverage
<?php

// Generated by Chef

/**
 * This config applies to API:
 * - Restrict access to API by filtering IPs
 * - Limit request per timespan
 */
return array(
    // all requests made to API must have referer request header with the same url as BB_URL
    'require_referer_header'   =>  <%= @config['require_referer_header'].to_s %>,

    // empty array will allow all IPs to access API
    'allowed_ips'       =>  array(<%= @config['allowed_ips'].map {|x| "'#{x}'" }.join(', ') %>),

    // Time span for limit in seconds
    'rate_span'         =>  <%= @config['rate_span'] %>,

    // How many requests allowed per time span
    'rate_limit'        =>  <%= @config['rate_limit'] %>,
);