snuffleupagus 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2673336e0bf2e923a6203b9068b5f6bb630a934
4
- data.tar.gz: 56c409eeba11a75ceae8a975665dcbdf8f86a7a7
3
+ metadata.gz: 68e2db1fb837ccce5226567bc8ad644d001d4bdb
4
+ data.tar.gz: 6aa0a6f6360a55c75ed1bf1a8680e8c36743c27e
5
5
  SHA512:
6
- metadata.gz: 96fce7e91624f86d0b067338e82e9036f9e08940fc559a723609c0adc2c41db4b9ee3e593233802606c904d28652cd430ef1c2a72dbbf07be728c58ca5e607f4
7
- data.tar.gz: 2327d6f3a086bfd3595906c69149c9d392a1e3aee79b6b58e7878dccf29307595fa5b64c236683f9818b2a1d68ceae2ff80d23b20d6b9548fe5abbd8d658ada7
6
+ metadata.gz: f65cce422e5ed05068a9f8e72c723298d1b7cbd581201014a091bc86ec46a9975c6d19c55521bc9e2510b78f946c87d42c1788749b85430223775d5739b8ea42
7
+ data.tar.gz: abe49c714541338737ef2ca9a11f65b0a9d1c0a710d35c8e42b6b6e7d3963cf8486a89802fdea0bdcefba643b0a2a94848cfab949f7ff7f936563ae5b3f1cde3
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ Metrics/BlockLength:
2
+ Exclude:
3
+ - 'spec/**/*'
4
+
5
+ Metrics/LineLength:
6
+ IgnoredPatterns: ['\A +#']
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
7
+ - 2.3
8
+ - 2.4
9
+ - 2.5
10
+
11
+ install:
12
+ - bundle install --retry=3
13
+
14
+ script:
15
+ - bundle exec rubocop
data/Gemfile.lock CHANGED
@@ -6,12 +6,43 @@ PATH
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
+ ast (2.4.0)
10
+ diff-lcs (1.3)
11
+ parallel (1.12.1)
12
+ parser (2.5.0.2)
13
+ ast (~> 2.4.0)
14
+ powerpack (0.1.1)
15
+ rainbow (3.0.0)
16
+ rspec (3.7.0)
17
+ rspec-core (~> 3.7.0)
18
+ rspec-expectations (~> 3.7.0)
19
+ rspec-mocks (~> 3.7.0)
20
+ rspec-core (3.7.1)
21
+ rspec-support (~> 3.7.0)
22
+ rspec-expectations (3.7.0)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.7.0)
25
+ rspec-mocks (3.7.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.7.0)
28
+ rspec-support (3.7.1)
29
+ rubocop (0.52.1)
30
+ parallel (~> 1.10)
31
+ parser (>= 2.4.0.2, < 3.0)
32
+ powerpack (~> 0.1)
33
+ rainbow (>= 2.2.2, < 4.0)
34
+ ruby-progressbar (~> 1.7)
35
+ unicode-display_width (~> 1.0, >= 1.0.1)
36
+ ruby-progressbar (1.9.0)
9
37
  timecop (0.4.4)
38
+ unicode-display_width (1.3.0)
10
39
 
11
40
  PLATFORMS
12
41
  ruby
13
42
 
14
43
  DEPENDENCIES
44
+ rspec
45
+ rubocop
15
46
  snuffleupagus!
16
47
  timecop
17
48
 
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:spec)
4
+
5
+ task default: :spec
@@ -1,7 +1,7 @@
1
1
  module Snuffleupagus
2
- # Handles basic time-limited authentication token creation / validation
2
+ # Handles basic time-limited authentication token creation / validation
3
3
  #
4
- # Uses Gibberish::AES with 256 bit CBC encryption
4
+ # Uses OpenSSL AES with 256 bit CBC encryption
5
5
  #
6
6
  # ## Basic Usage
7
7
  #
@@ -18,10 +18,6 @@ module Snuffleupagus
18
18
  # #=> true
19
19
  #
20
20
  class AuthToken
21
-
22
- # tokens are only valid for 2 minutes
23
- MAX_VALID_TIME_DIFFERENCE = 120
24
-
25
21
  def initialize(key)
26
22
  @key = key
27
23
  @cipher = OpenSSL::Cipher::AES256.new :CBC
@@ -37,13 +33,14 @@ module Snuffleupagus
37
33
  match = /^#{CONSTANT}([0-9]+)$/.match decoded
38
34
  return false unless match
39
35
  (match[1].to_i - Time.now.to_i).abs < MAX_VALID_TIME_DIFFERENCE
40
- rescue
36
+ rescue StandardError
41
37
  false
42
38
  end
43
39
 
44
40
  private
45
41
 
46
42
  CONSTANT = 'date:'.freeze
43
+ MAX_VALID_TIME_DIFFERENCE = 120 # tokens are only valid for 2 minutes
47
44
 
48
45
  attr_reader :cipher
49
46
 
@@ -51,7 +48,7 @@ module Snuffleupagus
51
48
  salt = generate_salt
52
49
  setup_cipher(:encrypt, salt)
53
50
  e = cipher.update(data) + cipher.final
54
- "Salted__#{salt}#{e}" #OpenSSL compatible
51
+ "Salted__#{salt}#{e}" # OpenSSL compatible
55
52
  end
56
53
 
57
54
  def decrypt(data)
@@ -68,7 +65,7 @@ module Snuffleupagus
68
65
  end
69
66
 
70
67
  def generate_salt
71
- 8.times.map { rand(255).chr }.join
68
+ Array.new(8) { rand(255).chr }.join
72
69
  end
73
70
 
74
71
  def encode(data)
@@ -1,3 +1,3 @@
1
1
  module Snuffleupagus
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'.freeze
3
3
  end
@@ -4,16 +4,20 @@ Gem::Specification.new do |s|
4
4
  s.name = 'snuffleupagus'
5
5
  s.version = Snuffleupagus::VERSION
6
6
  s.platform = Gem::Platform::RUBY
7
- s.authors = [ 'Andrew Bromwich' ]
8
- s.email = [ 'abromwich@studiosity.com' ]
7
+ s.authors = ['Andrew Bromwich']
8
+ s.email = ['abromwich@studiosity.com']
9
9
  s.homepage = 'https://studiosity.com'
10
10
  s.description = 'Simple auth token generator/validator'
11
11
  s.summary = "snuffleupagus-#{s.version}"
12
12
  s.required_rubygems_version = '> 1.3.6'
13
13
 
14
- s.add_development_dependency 'timecop'
14
+ s.add_development_dependency 'rspec', '~> 0'
15
+ s.add_development_dependency 'rubocop', '~> 0'
16
+ s.add_development_dependency 'timecop', '~> 0'
15
17
 
16
- s.files = `git ls-files`.split($\)
17
- s.executables = `git ls-files`.split("\n").map{ |f| f =~ /^bin\/(.*)/ ? $1 : nil }.compact
18
+ s.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
19
+ s.executables = `git ls-files`.split("\n").map do |f|
20
+ f =~ %r{^bin/(.*)} ? Regexp.last_match(1) : nil
21
+ end.compact
18
22
  s.require_path = 'lib'
19
23
  end
@@ -9,7 +9,7 @@ describe Snuffleupagus::AuthToken do
9
9
 
10
10
  it { is_expected.to be_a String }
11
11
  it { expect(subject.length).to eq 64 }
12
- it { is_expected.to match /\A[a-f0-9]{64}\z/ }
12
+ it { is_expected.to match(/\A[a-f0-9]{64}\z/) }
13
13
  end
14
14
 
15
15
  describe '#check_token' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snuffleupagus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Bromwich
@@ -10,18 +10,46 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2018-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: timecop
15
43
  requirement: !ruby/object:Gem::Requirement
16
44
  requirements:
17
- - - ">="
45
+ - - "~>"
18
46
  - !ruby/object:Gem::Version
19
47
  version: '0'
20
48
  type: :development
21
49
  prerelease: false
22
50
  version_requirements: !ruby/object:Gem::Requirement
23
51
  requirements:
24
- - - ">="
52
+ - - "~>"
25
53
  - !ruby/object:Gem::Version
26
54
  version: '0'
27
55
  description: Simple auth token generator/validator
@@ -32,9 +60,12 @@ extensions: []
32
60
  extra_rdoc_files: []
33
61
  files:
34
62
  - ".gitignore"
63
+ - ".rubocop.yml"
64
+ - ".travis.yml"
35
65
  - Gemfile
36
66
  - Gemfile.lock
37
67
  - README.md
68
+ - Rakefile
38
69
  - Snuffy.png
39
70
  - lib/snuffleupagus.rb
40
71
  - lib/snuffleupagus/auth_token.rb
@@ -63,5 +94,5 @@ rubyforge_project:
63
94
  rubygems_version: 2.6.14
64
95
  signing_key:
65
96
  specification_version: 4
66
- summary: snuffleupagus-0.0.3
97
+ summary: snuffleupagus-0.0.4
67
98
  test_files: []