Giter Site home page Giter Site logo

aws_cf_signer's Introduction

aws_cf_signer

A port of Dylan Vaughn’s excellent signing gem - github.com/stlondemand/aws_cf_signer

This version uses all class methods and a configure method to initialize options.

Installation

The original gem was published - use gem install aws_cf_signer to install that version.
For this version place a copy of aws_cf_signer.rb in your lib directory.
Then create an initializer that sets the pem path and optionally overrides defaults.

e.g. 

  require 'aws_cf_signer'

  AWS::CloudFront::Signer.configure! "#{Rails.root}/config/pk-APKAIKURNAUNR2BDSFDMA.pem"

Usage

# Call the class sign method with optional policy settings.

AWS::CloudFront::Signer.sign 'path/to/my/content'

or 

AWS::CloudFront::Signer.sign 'path/to/my/content', :expires => Time.now + 600

# Custom Policies

# See Example Custom Policy 1 at above AWS doc link
url = AWS::CloudFront::Signer.sign('http://d604721fxaaqy9.cloudfront.net/training/orientation.avi',
  :expires   => 'Sat, 14 Nov 2009 22:20:00 GMT',
  :resource => 'http://d604721fxaaqy9.cloudfront.net/training/*',
  :ip_range => '145.168.143.0/24'
)

# See Example Custom Policy 2 at above AWS doc link
url = AWS::CloudFront::Signer.sign('http://d84l721fxaaqy9.cloudfront.net/downloads/pictures.tgz',
  :starting => 'Thu, 30 Apr 2009 06:43:10 GMT',
  :expires   => 'Fri, 16 Oct 2009 06:31:56 GMT',
  :resource => 'http://*',
  :ip_range => '216.98.35.1/32'
)

# You can also pass in a path to a policy file
# This will supersede any other policy options
url = AWS::CloudFront::Signer.sign('http://d84l721fxaaqy9.cloudfront.net/downloads/pictures.tgz', :policy_file => '/path/to/policy/file.txt')

Note on Patches/Pull Requests (from Dylan’s original repository)

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Attributions

Parts of signing code taken from a question on Stack Overflow asked by Ben Wiseley, and answered by Blaz Lipuscek and Manual M:

License

aws_cf_signer is distributed under the MIT License, copyright © 2010 STL

aws_cf_signer's People

Stargazers

John Maxwell avatar

Watchers

John Maxwell avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.