Sha256: 99924ca0c7e807832ef89719d7f04419b56aa599a7fb1d098811a283560b693a
Contents?: true
Size: 1.13 KB
Versions: 6
Compression:
Stored size: 1.13 KB
Contents
require 'base64' require 'uri' require 'time' require 'json' require 'openssl' module Aws module CloudFront # Allows you to create signed cookie for Amazon CloudFront resources # # signer = Aws::CloudFront::CookieSigner.new( # key_pair_id: "cf-keypair-id", # private_key_path: "./cf_private_key.pem" # ) # cookies = signer.signed_cookie(url, # policy: policy.to_json # ) # class CookieSigner include Signer # create a signed Amazon CloudFront URL # @param [String] url # @option params [Time, DateTime, Date, String, Integer<timestamp>] :expires # @option params [String<JSON>] :policy def signed_cookie(url, params = {}) scheme, uri = scheme_and_uri(url) signed_content = signature( resource: resource(scheme, uri), expires: time(params[:expires]), policy: params[:policy] ) cookie_parameters = {} signed_content.each { |k, v| cookie_parameters["CloudFront-#{k}"] = v.to_s.gsub("\n", '') } cookie_parameters end end end end
Version data entries
6 entries across 6 versions & 1 rubygems