Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of old hashrockets syntax - use new one #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# cloudfront-signer
## New Repository
As discussed in [#5](https://github.com/58bits/cloudfront-signer/pull/5) the new home for this gem is [leonelgalan/cloudfront-signer](https://github.com/leonelgalan/cloudfront-signer). The new repository, won't be a fork, allowing users to post issues.
As discussed in [#5](https://github.com/58bits/cloudfront-signer/pull/5) the new home for this gem is [leonelgalan/cloudfront-signer](https://github.com/leonelgalan/cloudfront-signer). The new repository, won't be a fork, allowing users to post issues.

---

Expand Down Expand Up @@ -47,15 +47,15 @@ Call the class `sign_url` or `sign_path` method with optional policy settings.

or

AWS::CF::Signer.sign_url 'http://mydomain/path/to/my/content', :expires => Time.now + 600
AWS::CF::Signer.sign_url 'http://mydomain/path/to/my/content', expires: Time.now + 600

Streaming paths can be signed with the `sign_path` method.

AWS::CF::Signer.sign_path 'path/to/my/content'

or

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


Both `sign_url` and `sign_path` have _safe_ versions that HTML encode the result allowing signed paths or urls to be placed in HTML markup. The 'non'-safe versions can be used for placing signed urls or paths in JavaScript blocks or Flash params.
Expand All @@ -66,23 +66,23 @@ Both `sign_url` and `sign_path` have _safe_ versions that HTML encode the result
See Example Custom Policy 1 at above AWS doc link

url = AWS::CF::Signer.sign_url('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'
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::CF::Signer.sign_url('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'
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::CF::Signer.sign_url('http://d84l721fxaaqy9.cloudfront.net/downloads/pictures.tgz', :policy_file => '/path/to/policy/file.txt')
url = AWS::CF::Signer.sign_url('http://d84l721fxaaqy9.cloudfront.net/downloads/pictures.tgz', policy_file: '/path/to/policy/file.txt')


## Patches/Pull Requests
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = ["--colour", "--format", "nested"]
end

task :default => :spec
task default: :spec

8 changes: 4 additions & 4 deletions lib/cloudfront-signer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def self.is_configured?
#
# Returns a String
def self.sign_url(subject, policy_options = {})
self.sign(subject, {:remove_spaces => true}, policy_options)
self.sign(subject, {remove_spaces: true}, policy_options)
end


Expand All @@ -139,22 +139,22 @@ def self.sign_url(subject, policy_options = {})
#
# Returns a String
def self.sign_url_safe(subject, policy_options = {})
self.sign(subject, {:remove_spaces => true, :html_escape => true}, policy_options)
self.sign(subject, {remove_spaces: true, html_escape: true}, policy_options)
end

# Public: Sign a stream path part or filename (spaces are allowed in stream paths
# and so are not removed).
#
# Returns a String
def self.sign_path(subject, policy_options ={})
self.sign(subject, {:remove_spaces => false}, policy_options)
self.sign(subject, {remove_spaces: false}, policy_options)
end

# Public: Sign a stream path or filename and HTML encode the result.
#
# Returns a String
def self.sign_path_safe(subject, policy_options ={})
self.sign(subject, {:remove_spaces => false, :html_escape => true}, policy_options)
self.sign(subject, {remove_spaces: false, html_escape: true}, policy_options)
end

# Public: Builds a signed url or stream resource name with optional configuration and
Expand Down
2 changes: 1 addition & 1 deletion spec/signer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@

it "should optionally expire in ten minutes" do
url = "http://somedomain.com/sign me"
result = AWS::CF::Signer.sign_url(url, :expires => Time.now + 600)
result = AWS::CF::Signer.sign_url(url, expires: Time.now + 600)
get_query_value(result, 'Expires').to_i.should eql((Time.now + 600 ).to_i)
end

Expand Down