multipass 1.2.3 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -2
- data/VERSION.yml +2 -2
- data/lib/multipass.rb +10 -4
- data/multipass.gemspec +17 -23
- data/test/multipass_test.rb +18 -5
- metadata +40 -43
- data/.gitignore +0 -2
data/Rakefile
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
require 'yaml'
|
2
3
|
require 'rake'
|
3
4
|
|
4
5
|
begin
|
@@ -7,14 +8,14 @@ begin
|
|
7
8
|
gem.name = "multipass"
|
8
9
|
gem.summary = 'Bare bones implementation of encoding and decoding MultiPass values for SSO.'
|
9
10
|
gem.email = "technoweenie@gmail.com"
|
10
|
-
gem.homepage = "
|
11
|
+
gem.homepage = "https://github.com/entp/multipass"
|
11
12
|
gem.authors = ["rick"]
|
12
13
|
gem.add_dependency 'ezcrypto'
|
13
14
|
|
14
15
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
16
|
end
|
16
17
|
rescue LoadError
|
17
|
-
puts "Jeweler not available. Install it with:
|
18
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
18
19
|
end
|
19
20
|
|
20
21
|
require 'rake/testtask'
|
data/VERSION.yml
CHANGED
data/lib/multipass.rb
CHANGED
@@ -67,13 +67,13 @@ class MultiPass
|
|
67
67
|
def decode(data)
|
68
68
|
json = options = nil
|
69
69
|
json = @crypto_key.decrypt(self.class.decode_64(data, @url_safe))
|
70
|
-
|
70
|
+
|
71
71
|
if json.nil?
|
72
72
|
raise MultiPass::DecryptError.new(data)
|
73
73
|
end
|
74
74
|
|
75
75
|
options = decode_json(data, json)
|
76
|
-
|
76
|
+
|
77
77
|
if !options.is_a?(Hash)
|
78
78
|
raise MultiPass::JSONError.new(data, json, options)
|
79
79
|
end
|
@@ -82,7 +82,13 @@ class MultiPass
|
|
82
82
|
options[key.to_sym] = unencode_javascript_unicode_escape(options.delete(key))
|
83
83
|
end
|
84
84
|
|
85
|
-
|
85
|
+
# Force everything coming out of json into a Time object if it isn't already
|
86
|
+
# with YAJL, it parses dates for us (ugh)
|
87
|
+
if options.has_key?(:expires) && options[:expires].is_a?(String) && !options[:expires].empty?
|
88
|
+
options[:expires] = Time.parse(options[:expires])
|
89
|
+
end
|
90
|
+
|
91
|
+
if options[:expires].nil? || (options[:expires] != '' && Time.now.utc > options[:expires])
|
86
92
|
raise MultiPass::ExpiredError.new(data, json, options)
|
87
93
|
end
|
88
94
|
|
@@ -150,4 +156,4 @@ class MultiPass
|
|
150
156
|
raise MultiPass::JSONError.new(data, s)
|
151
157
|
end
|
152
158
|
end
|
153
|
-
end
|
159
|
+
end
|
data/multipass.gemspec
CHANGED
@@ -1,44 +1,38 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "1.2
|
7
|
+
s.name = "multipass"
|
8
|
+
s.version = "1.3.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["rick"]
|
12
|
-
s.date =
|
13
|
-
s.email =
|
12
|
+
s.date = "2012-08-09"
|
13
|
+
s.email = "technoweenie@gmail.com"
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
16
|
-
|
16
|
+
"README"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
"
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
"multipass.gemspec",
|
26
|
-
"test/multipass_test.rb"
|
27
|
-
]
|
28
|
-
s.homepage = %q{http://github.com/entp/multipass}
|
29
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
30
|
-
s.require_paths = ["lib"]
|
31
|
-
s.rubygems_version = %q{1.3.5}
|
32
|
-
s.summary = %q{Bare bones implementation of encoding and decoding MultiPass values for SSO.}
|
33
|
-
s.test_files = [
|
19
|
+
"LICENSE",
|
20
|
+
"README",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION.yml",
|
23
|
+
"lib/multipass.rb",
|
24
|
+
"multipass.gemspec",
|
34
25
|
"test/multipass_test.rb"
|
35
26
|
]
|
27
|
+
s.homepage = "https://github.com/entp/multipass"
|
28
|
+
s.require_paths = ["lib"]
|
29
|
+
s.rubygems_version = "1.8.23"
|
30
|
+
s.summary = "Bare bones implementation of encoding and decoding MultiPass values for SSO."
|
36
31
|
|
37
32
|
if s.respond_to? :specification_version then
|
38
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
39
33
|
s.specification_version = 3
|
40
34
|
|
41
|
-
if Gem::Version.new(Gem::
|
35
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
42
36
|
s.add_runtime_dependency(%q<ezcrypto>, [">= 0"])
|
43
37
|
else
|
44
38
|
s.add_dependency(%q<ezcrypto>, [">= 0"])
|
data/test/multipass_test.rb
CHANGED
@@ -1,10 +1,21 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
2
4
|
require 'rubygems'
|
3
5
|
require 'test/unit'
|
4
6
|
require 'multipass'
|
5
7
|
#require 'active_support'
|
6
8
|
|
9
|
+
module MultiPassTestHelper
|
10
|
+
def assert_multipass(expected, actual)
|
11
|
+
assert_equal expected[:email], actual[:email]
|
12
|
+
assert_equal expected[:expires].to_s, actual[:expires].to_s
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
7
16
|
module MultiPassTests
|
17
|
+
include MultiPassTestHelper
|
18
|
+
|
8
19
|
def test_encodes_multipass
|
9
20
|
expected = MultiPass.encode_64(@key.encrypt(@output.to_json), @mp.url_safe?)
|
10
21
|
assert_equal expected, @mp.encode(@input)
|
@@ -12,12 +23,12 @@ module MultiPassTests
|
|
12
23
|
|
13
24
|
def test_decodes_multipass
|
14
25
|
encoded = @mp.encode(@input)
|
15
|
-
|
26
|
+
assert_multipass @input, @mp.decode(encoded)
|
16
27
|
end
|
17
28
|
|
18
29
|
def test_decodes_multipass_with_class_method
|
19
30
|
encoded = @mp.encode(@input)
|
20
|
-
|
31
|
+
assert_multipass @input, MultiPass.decode('example', 'abc', encoded)
|
21
32
|
end
|
22
33
|
|
23
34
|
def test_decodes_unicode
|
@@ -80,6 +91,8 @@ class UrlSafeMultiPassTest < Test::Unit::TestCase
|
|
80
91
|
end
|
81
92
|
|
82
93
|
class ErrorTest < Test::Unit::TestCase
|
94
|
+
include MultiPassTestHelper
|
95
|
+
|
83
96
|
def setup
|
84
97
|
@key = EzCrypto::Key.with_password('example', 'abc')
|
85
98
|
@mp = MultiPass.new('example', 'abc')
|
@@ -133,12 +146,12 @@ class ErrorTest < Test::Unit::TestCase
|
|
133
146
|
|
134
147
|
def test_expiration_error_stores_options
|
135
148
|
begin
|
136
|
-
opt = {:expires =>
|
149
|
+
opt = {:expires => Time.now - 5, :email => 'ricky@bobby.com'}
|
137
150
|
json = opt.to_json
|
138
151
|
data = @key.encrypt64(json)
|
139
152
|
@mp.decode data
|
140
153
|
rescue MultiPass::ExpiredError => e
|
141
|
-
|
154
|
+
assert_multipass opt, e.options
|
142
155
|
end
|
143
156
|
end
|
144
|
-
end
|
157
|
+
end
|
metadata
CHANGED
@@ -1,38 +1,40 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: multipass
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.2
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- rick
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-08-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: ezcrypto
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
17
22
|
type: :runtime
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
description:
|
26
31
|
email: technoweenie@gmail.com
|
27
32
|
executables: []
|
28
|
-
|
29
33
|
extensions: []
|
30
|
-
|
31
|
-
extra_rdoc_files:
|
34
|
+
extra_rdoc_files:
|
32
35
|
- LICENSE
|
33
36
|
- README
|
34
|
-
files:
|
35
|
-
- .gitignore
|
37
|
+
files:
|
36
38
|
- LICENSE
|
37
39
|
- README
|
38
40
|
- Rakefile
|
@@ -40,33 +42,28 @@ files:
|
|
40
42
|
- lib/multipass.rb
|
41
43
|
- multipass.gemspec
|
42
44
|
- test/multipass_test.rb
|
43
|
-
|
44
|
-
homepage: http://github.com/entp/multipass
|
45
|
+
homepage: https://github.com/entp/multipass
|
45
46
|
licenses: []
|
46
|
-
|
47
47
|
post_install_message:
|
48
|
-
rdoc_options:
|
49
|
-
|
50
|
-
require_paths:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
51
50
|
- lib
|
52
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
64
63
|
requirements: []
|
65
|
-
|
66
64
|
rubyforge_project:
|
67
|
-
rubygems_version: 1.
|
65
|
+
rubygems_version: 1.8.23
|
68
66
|
signing_key:
|
69
67
|
specification_version: 3
|
70
68
|
summary: Bare bones implementation of encoding and decoding MultiPass values for SSO.
|
71
|
-
test_files:
|
72
|
-
- test/multipass_test.rb
|
69
|
+
test_files: []
|
data/.gitignore
DELETED