signatron 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Y2VlOGMwNDEzNTk5ZDY0ZWQ0YTI1YTgxYzVjYzFlNmRkMDNkNTYzYg==
5
+ data.tar.gz: !binary |-
6
+ Y2JkODBmYTEzMjgwNDlkMjU4MjcwZjA1ODQ4NDg2MzA1ZmFkMTUxYg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NzY1ZmUzNmQ1MjFjYzJiNzRiNWYyMWY1NmFhZWU0NWNiOTlkOGU3ZDAzMDZk
10
+ NDQyOGQ0YmNmMjg1Zjk1OGZiMTQxZDQ4MzY5ZGE0YjJkMzQxNDhlOWI3Nzlk
11
+ ODk2YTE5ZDI1Y2VlOTNmYTkzOTJkNGJlZDg2ZWE1NGM1NmNhNmE=
12
+ data.tar.gz: !binary |-
13
+ ODBmNWQzNWE4OTUzZjdjNmM0YzJhMzU5MjYzYTQyMDg4ZWJmYzljOWUwNDE2
14
+ YmQ2ZDVmYjc1YTdhMDY5YTY5NTUzZGEyY2VkYTM4ZjU5YjdiYTY4ODhmMGUz
15
+ Zjk0YjI5MjQ5ZGM5NDAyNTY4ZTI3ZmI4ODUwYTcwOTNmNGE0NjU=
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in signatron.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,3 @@
1
+ module Signatron
2
+ VERSION = '0.0.9'
3
+ end
data/lib/signatron.rb ADDED
@@ -0,0 +1,40 @@
1
+ require 'base64'
2
+ require 'yaml'
3
+ require 'hmac-sha1'
4
+
5
+ module Signatron
6
+ def self.verify(body, timestamp, timeout, signature)
7
+ setup
8
+
9
+ begin
10
+ raise unless timestamp.to_i > Time.now.to_i - timeout
11
+
12
+ proper_signature = self.sign body, timestamp, timeout
13
+ signature == proper_signature
14
+ rescue
15
+ false
16
+ end
17
+ end
18
+
19
+ def self.sign(body, timestamp, timeout)
20
+ setup
21
+
22
+ data = body + '&' + timestamp.to_i.to_s + '&' + timeout.to_s
23
+ @hmac.update data
24
+ Base64.strict_encode64 @hmac.digest
25
+ end
26
+
27
+ private
28
+
29
+ @initialized = false
30
+
31
+ def self.setup
32
+ return if @initialized
33
+
34
+ settings = YAML::load_file "#{Rails.root}/config/sign-a-tron.yml"
35
+ @key = Base64.decode64 settings['key']
36
+ @hmac = HMAC::SHA1.new @key
37
+
38
+ @initialized = true
39
+ end
40
+ end
data/signatron.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'signatron/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'signatron'
7
+ spec.version = Signatron::VERSION
8
+ spec.authors = ['Gabriel Kirkpatrick', 'James Billingham']
9
+ spec.email = ['g@be-k.biz', 'james@billingham.net']
10
+ spec.summary = 'Signing for internal secure requests'
11
+
12
+ spec.files = `git ls-files`.split($/)
13
+ spec.require_paths = ['lib']
14
+
15
+ spec.add_dependency 'ruby-hmac'
16
+ spec.add_dependency 'rails', '>= 3'
17
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: signatron
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.9
5
+ platform: ruby
6
+ authors:
7
+ - Gabriel Kirkpatrick
8
+ - James Billingham
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ruby-hmac
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ! '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ! '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rails
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '3'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '3'
42
+ description:
43
+ email:
44
+ - g@be-k.biz
45
+ - james@billingham.net
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - .gitignore
51
+ - Gemfile
52
+ - Rakefile
53
+ - lib/signatron.rb
54
+ - lib/signatron/version.rb
55
+ - signatron.gemspec
56
+ homepage:
57
+ licenses: []
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.0.3
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: Signing for internal secure requests
79
+ test_files: []