{"action":"created","issue":{"url":"https://api.github.com/repos/58bits/cloudfront-signer/issues/5","labels_url":"https://api.github.com/repos/58bits/cloudfront-signer/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/58bits/cloudfront-signer/issues/5/comments","events_url":"https://api.github.com/repos/58bits/cloudfront-signer/issues/5/events","html_url":"https://github.com/58bits/cloudfront-signer/pull/5","id":69934556,"number":5,"title":"Separates url building and signing","user":{"login":"leonelgalan","id":727774,"avatar_url":"https://avatars.githubusercontent.com/u/727774?v=3","gravatar_id":"","url":"https://api.github.com/users/leonelgalan","html_url":"https://github.com/leonelgalan","followers_url":"https://api.github.com/users/leonelgalan/followers","following_url":"https://api.github.com/users/leonelgalan/following{/other_user}","gists_url":"https://api.github.com/users/leonelgalan/gists{/gist_id}","starred_url":"https://api.github.com/users/leonelgalan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leonelgalan/subscriptions","organizations_url":"https://api.github.com/users/leonelgalan/orgs","repos_url":"https://api.github.com/users/leonelgalan/repos","events_url":"https://api.github.com/users/leonelgalan/events{/privacy}","received_events_url":"https://api.github.com/users/leonelgalan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-04-21T19:48:33Z","updated_at":"2015-04-28T16:43:37Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/58bits/cloudfront-signer/pulls/5","html_url":"https://github.com/58bits/cloudfront-signer/pull/5","diff_url":"https://github.com/58bits/cloudfront-signer/pull/5.diff","patch_url":"https://github.com/58bits/cloudfront-signer/pull/5.patch"},"body":"## How\r\nTo be used in signing cookies. From within example.com or a subdomain of example.com (this is important, because the browser won't allow Rails to set cookies for a domain other than the one serving the page.)\r\n\r\n```ruby\r\n# In a controller, before serving the images\r\nbefore_action :set_cookie\r\n\r\ndef set_cookie\r\n  signed_params = AWS::CF::Signer.sign(\r\n                    nil,\r\n                    resource: 'http://images.example.com/*',\r\n                    expires: 1.day.from_now\r\n                  )\r\n\r\n  signed_params.each do |name, value|\r\n    cookies[\"CloudFront-#{name}\"] = { value: value,\r\n                                      domain: :all,\r\n                                      httponly: true }\r\n  end\r\nend\r\n```\r\n\r\nA custom policy is built allowing the user access to all images inside _http://images.example.com/_:\r\n\r\n```html\r\n<img src=\"http://images.example.com/image1.jpg\" alt=\"Image 1\" />\r\n<img src=\"http://images.example.com/image2.jpg\" alt=\"Image 2\" />\r\n<img src=\"http://images.example.com/business/image1.jpg\" alt=\"Image 1\" />\r\n```\r\n\r\n## Why\r\nThis is important when:\r\n> You want to provide access to multiple restricted files, for example, all of the files for a video in HLS format or all of the files in the subscribers' area of a website.\r\n\r\nAs described by [Choosing Between Signed URLs and Signed Cookies](http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-choosing-signed-urls-cookies.html)\r\n\r\n___\r\n\r\nThis PR breaks background compatibility of those using `sign` directly, but not `sign_url`, `sign_url_safe`, `sign_path` and `sign_path_safe`. We could simply rename the new method to keep background compatibility, but I thought this made the most sense, semantically:\r\n\r\n* `sign` gets all required parts of the signature as described by CloudFront documents. And can be used independently to support signed cookies.\r\n* `build_url` uses sign to build a signed url."},"comment":{"url":"https://api.github.com/repos/58bits/cloudfront-signer/issues/comments/97131979","html_url":"https://github.com/58bits/cloudfront-signer/pull/5#issuecomment-97131979","issue_url":"https://api.github.com/repos/58bits/cloudfront-signer/issues/5","id":97131979,"user":{"login":"58bits","id":405612,"avatar_url":"https://avatars.githubusercontent.com/u/405612?v=3","gravatar_id":"","url":"https://api.github.com/users/58bits","html_url":"https://github.com/58bits","followers_url":"https://api.github.com/users/58bits/followers","following_url":"https://api.github.com/users/58bits/following{/other_user}","gists_url":"https://api.github.com/users/58bits/gists{/gist_id}","starred_url":"https://api.github.com/users/58bits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/58bits/subscriptions","organizations_url":"https://api.github.com/users/58bits/orgs","repos_url":"https://api.github.com/users/58bits/repos","events_url":"https://api.github.com/users/58bits/events{/privacy}","received_events_url":"https://api.github.com/users/58bits/received_events","type":"User","site_admin":false},"created_at":"2015-04-28T16:43:37Z","updated_at":"2015-04-28T16:43:37Z","body":"Thanks @leonelgalan . So how about I close this PR, and wait for the update? Once you submit the new PR, I'll then publish the gem with the MINOR rev. As for the future, I'm fine with whatever works best. If giving this a new home under @leonelgalan works - then that's great (although a hat tip for the initial re-write would be greatly appreciated ;))"}}