Last active
April 18, 2018 13:24
-
-
Save yoelblum/1b1c42ca33b199d08a4e44563010c51c to your computer and use it in GitHub Desktop.
Leaseweb Ruby Secure URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def leaseweb_secure_url | |
cname = 'your.cdn.name' | |
path = path_to_file | |
secret = 'YourSecret' | |
expire = (Time.now.to_i + 86400).to_s | |
ip = '' | |
secure_url = secret + ip + path + expire | |
secure_url_md5 = Digest::MD5.digest(secure_url) | |
secure_url_base64 = Base64.strict_encode64(secure_url_md5) | |
secure_url_base64 = secure_url_base64.gsub('+', '-').gsub('/', '_') | |
secure_url_base64 = secure_url_base64.gsub('=', '') | |
"http://#{cname}#{path}?st=#{secure_url_base64}&e=#{expire}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://kb.leaseweb.com/display/KB/Pull+Zones%3A+CDN#PullZones:CDN-SecuritySettings