Sha256: 58d2c29b20ce6bcc75b54a76a81668962edbc6ff088da9bac2bb6d552dd7de5a
Contents?: true
Size: 745 Bytes
Versions: 2
Compression:
Stored size: 745 Bytes
Contents
module Gibbon module Helpers def get_data_center_from_api_key(api_key) # Return an empty string for invalid API keys so Gibbon hits the main endpoint data_center = "" if api_key && api_key["-"] # Remove all non-alphanumberic characters in case someone attempts to inject # a different domain into the API key (e.g. when consuming user form-provided keys) # This approach avoids assuming a 3 letter prefix (e.g. is MC were to create # a us10 DC, this would continue to work), and will continue to hit MC's server # rather than a would-be attacker's servers. data_center = "#{api_key.split('-').last.gsub(/[^0-9a-z ]/i, '')}." end data_center end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gibbon-3.5.0 | lib/gibbon/gibbon_helpers.rb |
gibbon-3.4.4 | lib/gibbon/gibbon_helpers.rb |