{"id":16089665,"url":"https://github.com/leonelgalan/cloudfront-signer","last_synced_at":"2025-03-17T14:17:18.611Z","repository":{"id":31534386,"uuid":"35098944","full_name":"leonelgalan/cloudfront-signer","owner":"leonelgalan","description":"Ruby gem for signing AWS CloudFront private content URLs and streaming paths.","archived":false,"fork":false,"pushed_at":"2020-03-03T21:37:19.000Z","size":80,"stargazers_count":42,"open_issues_count":3,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-03T23:49:42.333Z","etag":null,"topics":["aws","cloudfront","gem","open-source","opensource","ruby"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/cloudfront-signer","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leonelgalan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-05T12:49:08.000Z","updated_at":"2024-05-06T09:41:55.000Z","dependencies_parsed_at":"2022-09-09T20:20:14.913Z","dependency_job_id":null,"html_url":"https://github.com/leonelgalan/cloudfront-signer","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonelgalan%2Fcloudfront-signer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonelgalan%2Fcloudfront-signer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonelgalan%2Fcloudfront-signer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonelgalan%2Fcloudfront-signer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leonelgalan","download_url":"https://codeload.github.com/leonelgalan/cloudfront-signer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244047646,"owners_count":20389206,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","cloudfront","gem","open-source","opensource","ruby"],"created_at":"2024-10-09T14:05:07.206Z","updated_at":"2025-03-17T14:17:18.567Z","avatar_url":"https://github.com/leonelgalan.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cloudfront-signer\n\n[![Build Status](https://travis-ci.org/leonelgalan/cloudfront-signer.svg)](https://travis-ci.org/leonelgalan/cloudfront-signer)\n[![Code Climate](https://codeclimate.com/github/leonelgalan/cloudfront-signer/badges/gpa.svg)](https://codeclimate.com/github/leonelgalan/cloudfront-signer)\n[![Test Coverage](https://codeclimate.com/github/leonelgalan/cloudfront-signer/badges/coverage.svg)](https://codeclimate.com/github/leonelgalan/cloudfront-signer/coverage)\n[![Gem Version](https://badge.fury.io/rb/cloudfront-signer.svg)](http://badge.fury.io/rb/cloudfront-signer)\n[![Dependency Status](https://gemnasium.com/leonelgalan/cloudfront-signer.svg)](https://gemnasium.com/leonelgalan/cloudfront-signer)\n\nSee the [CHANGELOG](https://github.com/leonelgalan/cloudfront-signer/blob/master/CHANGELOG.md)\nfor details of this release.\n\nSee Amazon docs for [Serving Private Content through CloudFront](http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/index.html?PrivateContent.html)\n\nA fork and rewrite started by [Anthony Bouch](https://github.com/58bits) of\nDylan Vaughn's [aws_cf_signer](https://github.com/dylanvaughn/aws_cf_signer).\n\nThis version uses all class methods and a configure method to set options.\n\nSeparate helper methods exist for safe signing of urls and stream paths, each of\nwhich has slightly different requirements. For example, urls must not contain\nany spaces, whereas a stream path might. Also we might not want to html escape a\nurl or path if it is being supplied to a JavaScript block or Flash object.\n\n## Installation\n\nThis gem has been published as _cloudfront-signer_. Use `gem install\ncloudfront-signer` to install this gem.\n\nThe signing class must be configured - supplying the path to a signing key, or\nsupplying the signing key directly as a string along with the `key_pair_id`.\nCreate the initializer by running:\n\n```sh\nbundle exec rails generate cloudfront:install\n```\n\nCustomize the resulting *config/initializers/cloudfront\\_signer.rb* file.\n\n### Generated *cloudfront\\_signer.rb*\n\n```ruby\nAws::CF::Signer.configure do |config|\n  config.key_path = '/path/to/keyfile.pem'\n  # or config.key = ENV.fetch('PRIVATE_KEY')\n  config.key_pair_id  = 'XXYYZZ'\n  config.default_expires = 3600\nend\n```\n\n## Usage\n\nCall the class `sign_url` or `sign_path` method with optional policy settings.\n\n```ruby\nAws::CF::Signer.sign_url 'http://mydomain/path/to/my/content'\n```\n\n```ruby\nAws::CF::Signer.sign_path 'path/to/my/content', expires: Time.now + 600\n```\n\nBoth `sign_url` and `sign_path` have _safe_ versions that HTML encode the result\nallowing signed paths or urls to be placed in HTML markup. The 'non'-safe\nversions can be used for placing signed urls or paths in JavaScript blocks or\nFlash params.\n\n___\n\nCall class method `signed_params` to get raw parameters. These values can be\nused to set signing cookies (\n[Serving Private Content through CloudFront: Using Signed Cookies](http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-signed-cookies.html)\n). See [commit message](https://github.com/leonelgalan/cloudfront-signer/commit/fedcc3182e32133e4bd0ad0b79c0106168896c91)\nfor additional details.\n\n```ruby\nAws::CF::Signer.signed_params 'path/to/my/content'\n```\n\n### Custom Policies\n\nSee Example Custom Policy 1 at above AWS doc link\n\n```ruby\nurl = Aws::CF::Signer.sign_url 'http://d604721fxaaqy9.cloudfront.net/training/orientation.avi',\n                               expires: 'Sat, 14 Nov 2009 22:20:00 GMT',\n                               resource: 'http://d604721fxaaqy9.cloudfront.net/training/*',\n                               ip_range: '145.168.143.0/24'\n```\n\nSee Example Custom Policy 2 at above AWS doc link\n\n```ruby\nAws::CF::Signer.sign_url 'http://d84l721fxaaqy9.cloudfront.net/downloads/pictures.tgz',\n                         starting: 'Thu, 30 Apr 2009 06:43:10 GMT',\n                         expires: 'Fri, 16 Oct 2009 06:31:56 GMT',\n                         resource: 'http://*',\n                         ip_range: '216.98.35.1/32'\n```\n\nYou can also pass in a path to a policy file. This will supersede any other\npolicy options\n\n```ruby\nAws::CF::Signer.sign_url 'http://d84l721fxaaqy9.cloudfront.net/downloads/pictures.tgz',\n                         policy_file: '/path/to/policy/file.txt'\n```\n\n## Patches/Pull Requests\n\n* Fork the project.\n* Make your feature addition or bug fix.\n* Add tests for it.\n* Commit\n* Send me a pull request. Bonus points for topic branches.\n\n## Attributions\n\nHat tip to [Anthony Bouch](https://github.com/58bits) for contributing to\nDylan's effort. Only reading both gem's code I was able to figure out the\nsigning needed for the newly introduced signed cookies.\n\n\u003e Dylan blazed a trail here - however, after several attempts, I was unable to\ncontact Dylan in order to suggest that we combine our efforts to produce a\nsingle gem - hence the re-write and new gem here. - _Anthony Bouch_\n\nParts of signing code taken from a question on\n[Stack Overflow](http://stackoverflow.com/questions/2632457/create-signed-urls-for-cloudfront-with-ruby)\nasked by [Ben Wiseley](http://stackoverflow.com/users/315829/ben-wiseley), and\nanswered by [Blaz Lipuscek](http://stackoverflow.com/users/267804/blaz-lipuscek)\nand [Manual M](http://stackoverflow.com/users/327914/manuel-m).\n\n## License\n\n_cloudfront-signer_ is distributed under the MIT License, portions copyright ©\n2015 Dylan Vaughn, STL, Anthony Bouch, Leonel Galán\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonelgalan%2Fcloudfront-signer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleonelgalan%2Fcloudfront-signer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonelgalan%2Fcloudfront-signer/lists"}