simple_api_auth 0.0.2 → 0.0.3
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.
- data/Gemfile.lock +3 -1
- data/lib/simple_api_auth/simple_api_auth.rb +1 -1
- data/simple_api_auth.gemspec +2 -1
- data/spec/lib/simple_api_auth_spec.rb +2 -1
- data/spec/spec_helper.rb +1 -0
- metadata +18 -4
data/Gemfile.lock
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
simple_api_auth (0.0.
|
4
|
+
simple_api_auth (0.0.2)
|
5
5
|
rack
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
10
|
diff-lcs (1.1.2)
|
11
|
+
json (1.5.1)
|
11
12
|
rack (1.2.2)
|
12
13
|
rspec (2.5.0)
|
13
14
|
rspec-core (~> 2.5.0)
|
@@ -22,5 +23,6 @@ PLATFORMS
|
|
22
23
|
ruby
|
23
24
|
|
24
25
|
DEPENDENCIES
|
26
|
+
json
|
25
27
|
rspec (~> 2.5)
|
26
28
|
simple_api_auth!
|
@@ -3,7 +3,7 @@ module SimpleApiAuth
|
|
3
3
|
class Middleware
|
4
4
|
|
5
5
|
@@api_path_matcher = /^\/api\//
|
6
|
-
@@unauthorized_response = [401, {"Content-Type" => "text/plain"}, ["
|
6
|
+
@@unauthorized_response = [401, {"Content-Type" => "text/plain"}, ['{ "message": "Unauthenticated." }']]
|
7
7
|
|
8
8
|
def self.api_key=(key)
|
9
9
|
@@api_key = key
|
data/simple_api_auth.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "simple_api_auth"
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.3"
|
6
6
|
s.platform = Gem::Platform::RUBY
|
7
7
|
s.authors = ["Wen-Tien Chang"]
|
8
8
|
s.email = ["ihower@gmail.com"]
|
@@ -17,4 +17,5 @@ Gem::Specification.new do |s|
|
|
17
17
|
|
18
18
|
s.add_dependency "rack"
|
19
19
|
s.add_development_dependency "rspec", "~> 2.5"
|
20
|
+
s.add_development_dependency "json"
|
20
21
|
end
|
@@ -21,7 +21,7 @@ describe SimpleApiAuth do
|
|
21
21
|
|
22
22
|
it "should pass if request is authorized by header" do
|
23
23
|
|
24
|
-
response = Rack::MockRequest.new(app).get('/api/test', "
|
24
|
+
response = Rack::MockRequest.new(app).get('/api/test', "HTTP_AUTHORIZATION" => "abc" )
|
25
25
|
response.status.should == 200
|
26
26
|
end
|
27
27
|
|
@@ -33,6 +33,7 @@ describe SimpleApiAuth do
|
|
33
33
|
it "should return 401 if request is unauthorized" do
|
34
34
|
response = Rack::MockRequest.new(app).get('/api/test')
|
35
35
|
response.status.should == 401
|
36
|
+
JSON.parse(response.body).should == { "message" => "Unauthenticated." }
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_api_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Wen-Tien Chang
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-12 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -47,6 +47,20 @@ dependencies:
|
|
47
47
|
version: "2.5"
|
48
48
|
type: :development
|
49
49
|
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: json
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
type: :development
|
63
|
+
version_requirements: *id003
|
50
64
|
description: A Rack middleware and Railtie(for Rails3) for API key authentication.
|
51
65
|
email:
|
52
66
|
- ihower@gmail.com
|