snuffleupagus 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/.travis.yml +15 -0
- data/Gemfile.lock +31 -0
- data/Rakefile +5 -0
- data/lib/snuffleupagus/auth_token.rb +6 -9
- data/lib/snuffleupagus/version.rb +1 -1
- data/snuffleupagus.gemspec +9 -5
- data/spec/snuffleupagus_spec.rb +1 -1
- metadata +35 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68e2db1fb837ccce5226567bc8ad644d001d4bdb
|
4
|
+
data.tar.gz: 6aa0a6f6360a55c75ed1bf1a8680e8c36743c27e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f65cce422e5ed05068a9f8e72c723298d1b7cbd581201014a091bc86ec46a9975c6d19c55521bc9e2510b78f946c87d42c1788749b85430223775d5739b8ea42
|
7
|
+
data.tar.gz: abe49c714541338737ef2ca9a11f65b0a9d1c0a710d35c8e42b6b6e7d3963cf8486a89802fdea0bdcefba643b0a2a94848cfab949f7ff7f936563ae5b3f1cde3
|
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
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
@@ -1,7 +1,7 @@
|
|
1
1
|
module Snuffleupagus
|
2
|
-
#
|
2
|
+
# Handles basic time-limited authentication token creation / validation
|
3
3
|
#
|
4
|
-
#
|
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
|
68
|
+
Array.new(8) { rand(255).chr }.join
|
72
69
|
end
|
73
70
|
|
74
71
|
def encode(data)
|
data/snuffleupagus.gemspec
CHANGED
@@ -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 = [
|
8
|
-
s.email = [
|
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 '
|
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
|
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
|
data/spec/snuffleupagus_spec.rb
CHANGED
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.
|
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.
|
97
|
+
summary: snuffleupagus-0.0.4
|
67
98
|
test_files: []
|