rack-oauth_echo 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
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/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rack-oauth_echo.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Alberto Bajo
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Rack::OAuthEcho
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rack-oauth_echo'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rack-oauth_echo
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ module Rack
2
+ module OAuthEcho
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,45 @@
1
+ require "rack/oauth_echo/version"
2
+
3
+ module Rack
4
+ module OAuthEcho
5
+ class Middleware
6
+ def initialize(app)
7
+ @app = app
8
+ end
9
+
10
+ def call(env)
11
+ if valid_header?(env)
12
+ json_response = auth_request(env) if valid_header?(env)
13
+ if json_response.status == 200
14
+ env['rack-oauth_echo.user_hash'] = auth_request(env).body
15
+ @app.call(env)
16
+ else
17
+ [json_response.status, {}, "Could not authenticate you."]
18
+ end
19
+ else
20
+ @app.call(env)
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def valid_header?(env)
27
+ env.has_key?('X-Verify-Credentials-Authorization') ||
28
+ env.has_key?('X-Auth-Service-Provider')
29
+ end
30
+
31
+ def auth_request(env)
32
+ conn = Faraday.new do |conn|
33
+ conn.response :json, :content_type => /\bjson$/
34
+ conn.headers['Authorization'] =
35
+ env['X-Verify-Credentials-Authorization']
36
+
37
+ conn.adapter Faraday.default_adapter
38
+ end
39
+
40
+ conn.get env['X-Auth-Service-Provider']
41
+ end
42
+
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/rack/oauth_echo/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Alberto Bajo"]
6
+ gem.email = ["albertobajo@gmail.com"]
7
+ gem.description = %q{OAuth Echo authentication by a rack middleware}
8
+ gem.summary = %q{Rack::OAuthEcho it a small, simple middleware for
9
+ authenticate OAuth Echo requests.}
10
+ gem.homepage = "http://github.com/albertobajo/rack-oauth_echo"
11
+
12
+ gem.files = `git ls-files`.split($\)
13
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.name = "rack-oauth_echo"
16
+ gem.require_paths = ["lib"]
17
+ gem.version = Rack::OAuthEcho::VERSION
18
+
19
+ gem.add_dependency "faraday_middleware", "~> 0.8.8"
20
+ gem.add_dependency "rack", "~> 1.4.1"
21
+
22
+ gem.add_development_dependency "fakeweb", "~> 1.3.0"
23
+ gem.add_development_dependency "json", "~> 1.7.4"
24
+ gem.add_development_dependency "rack-test", "~> 0.6.1"
25
+ gem.add_development_dependency "rspec", "~> 2.11.0"
26
+ gem.add_development_dependency "simple_oauth", "~> 0.1.9"
27
+ gem.add_development_dependency "spork", "~> 0.9.2"
28
+ gem.add_development_dependency "vcr", "~> 2.2.4"
29
+ end
@@ -0,0 +1,82 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.twitter.com/1/account/verify_credentials.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ authorization:
11
+ - bad header
12
+ accept-encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ accept:
15
+ - ! '*/*'
16
+ user-agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 401
21
+ message: !binary |-
22
+ VW5hdXRob3JpemVk
23
+ headers:
24
+ !binary "ZGF0ZQ==":
25
+ - !binary |-
26
+ TW9uLCAzMCBKdWwgMjAxMiAxMjoyNTowNyBHTVQ=
27
+ !binary "c3RhdHVz":
28
+ - !binary |-
29
+ NDAxIFVuYXV0aG9yaXplZA==
30
+ !binary "eC1ydW50aW1l":
31
+ - !binary |-
32
+ MC4wMDQxMQ==
33
+ !binary "Y2FjaGUtY29udHJvbA==":
34
+ - !binary |-
35
+ bm8tY2FjaGUsIG1heC1hZ2U9MzAw
36
+ !binary "Y29udGVudC10eXBl":
37
+ - !binary |-
38
+ YXBwbGljYXRpb24vanNvbjsgY2hhcnNldD11dGYtOA==
39
+ !binary "d3d3LWF1dGhlbnRpY2F0ZQ==":
40
+ - !binary |-
41
+ T0F1dGggcmVhbG09Imh0dHBzOi8vYXBpLnR3aXR0ZXIuY29tIg==
42
+ !binary "c2V0LWNvb2tpZQ==":
43
+ - !binary |-
44
+ az0xMC4zNi4yMy4xMDIuMTM0MzY1MTEwNzQwMDg3MDsgcGF0aD0vOyBleHBp
45
+ cmVzPU1vbiwgMDYtQXVnLTEyIDEyOjI1OjA3IEdNVDsgZG9tYWluPS50d2l0
46
+ dGVyLmNvbQ==
47
+ - !binary |-
48
+ Z3Vlc3RfaWQ9djElM0ExMzQzNjUxMTA3NDA1NDQ1NzY7IGRvbWFpbj0udHdp
49
+ dHRlci5jb207IHBhdGg9LzsgZXhwaXJlcz1UaHUsIDMxLUp1bC0yMDE0IDAw
50
+ OjI1OjA3IEdNVA==
51
+ - !binary |-
52
+ X3R3aXR0ZXJfc2Vzcz1CQWg3Q0NJS1pteGhjMmhKUXpvblFXTjBhVzl1UTI5
53
+ dWRISnZiR3hsY2pvNlJteGhjMmc2T2tac1lYTm8lMjUwQVNHRnphSHNBQmpv
54
+ S1FIVnpaV1I3QURvUFkzSmxZWFJsWkY5aGRHd3JDRSUyNTJGUzJOYzRBVG9I
55
+ YVdRaUpUVmslMjUwQU1UaG1PRGM1TjJSa1ptWmxNbU15WkRCbU1HVm1OREl6
56
+ TkRrM01UUTEtLTA4MGE3NWVmYmM0NWQwY2Y3NDQxODIwOTk2NzJmZDY2YmFl
57
+ NmYyM2U7IGRvbWFpbj0udHdpdHRlci5jb207IHBhdGg9LzsgSHR0cE9ubHk=
58
+ !binary "ZXhwaXJlcw==":
59
+ - !binary |-
60
+ TW9uLCAzMCBKdWwgMjAxMiAxMjozMDowNyBHTVQ=
61
+ !binary "dmFyeQ==":
62
+ - !binary |-
63
+ QWNjZXB0LUVuY29kaW5n
64
+ !binary "Y29udGVudC1lbmNvZGluZw==":
65
+ - !binary |-
66
+ Z3ppcA==
67
+ !binary "Y29udGVudC1sZW5ndGg=":
68
+ - !binary |-
69
+ MTAx
70
+ !binary "c2VydmVy":
71
+ - !binary |-
72
+ dGZl
73
+ body:
74
+ encoding: ASCII-8BIT
75
+ string: !binary |-
76
+ H4sIAAAAAAAAAxXLwQqAIAwA0F+RnUPp2rXfEGLoIkMczS2I6N+r+3s3kAgL
77
+ TDCz1ewaq0PTjZqWhEruYvMwgNBh1PVzMYwxYEpsTWM4Scp6LUko/wVr93vn
78
+ Bs8L+8HgvlkAAAA=
79
+ http_version: !binary |-
80
+ MS4x
81
+ recorded_at: Mon, 30 Jul 2012 12:25:06 GMT
82
+ recorded_with: VCR 2.2.4
@@ -0,0 +1,82 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.twitter.com/1/account/verify_credentials.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ authorization:
11
+ - bad header
12
+ accept-encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ accept:
15
+ - ! '*/*'
16
+ user-agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 401
21
+ message: !binary |-
22
+ VW5hdXRob3JpemVk
23
+ headers:
24
+ !binary "ZGF0ZQ==":
25
+ - !binary |-
26
+ TW9uLCAzMCBKdWwgMjAxMiAxMjoyNTowOSBHTVQ=
27
+ !binary "c3RhdHVz":
28
+ - !binary |-
29
+ NDAxIFVuYXV0aG9yaXplZA==
30
+ !binary "Y29udGVudC10eXBl":
31
+ - !binary |-
32
+ YXBwbGljYXRpb24vanNvbjsgY2hhcnNldD11dGYtOA==
33
+ !binary "Y2FjaGUtY29udHJvbA==":
34
+ - !binary |-
35
+ bm8tY2FjaGUsIG1heC1hZ2U9MzAw
36
+ !binary "eC1ydW50aW1l":
37
+ - !binary |-
38
+ MC4wMDM5Mg==
39
+ !binary "d3d3LWF1dGhlbnRpY2F0ZQ==":
40
+ - !binary |-
41
+ T0F1dGggcmVhbG09Imh0dHBzOi8vYXBpLnR3aXR0ZXIuY29tIg==
42
+ !binary "c2V0LWNvb2tpZQ==":
43
+ - !binary |-
44
+ az0xMC4zNC4yNTAuMTE3LjEzNDM2NTExMDkzNDI2Njc7IHBhdGg9LzsgZXhw
45
+ aXJlcz1Nb24sIDA2LUF1Zy0xMiAxMjoyNTowOSBHTVQ7IGRvbWFpbj0udHdp
46
+ dHRlci5jb20=
47
+ - !binary |-
48
+ Z3Vlc3RfaWQ9djElM0ExMzQzNjUxMTA5MzQ3NTE5NzU7IGRvbWFpbj0udHdp
49
+ dHRlci5jb207IHBhdGg9LzsgZXhwaXJlcz1UaHUsIDMxLUp1bC0yMDE0IDAw
50
+ OjI1OjA5IEdNVA==
51
+ - !binary |-
52
+ X3R3aXR0ZXJfc2Vzcz1CQWg3Q0RvUFkzSmxZWFJsWkY5aGRHd3JDT1haMk5j
53
+ NEFTSUtabXhoYzJoSlF6b25RV04wYVc5dVEyOXUlMjUwQWRISnZiR3hsY2pv
54
+ NlJteGhjMmc2T2tac1lYTm9TR0Z6YUhzQUJqb0tRSFZ6WldSN0FEb0hhV1Fp
55
+ SlRZdyUyNTBBTVRZeE1qazVNV0pqWmpOaE1qTmhZbU0zWXpZMk9Ua3daalps
56
+ T0RGai0tODg0NTA4ZDZhMzk5ZTg3MTY5NzAwODM2ZGFjMzExYmE3OWFlMzZl
57
+ MzsgZG9tYWluPS50d2l0dGVyLmNvbTsgcGF0aD0vOyBIdHRwT25seQ==
58
+ !binary "ZXhwaXJlcw==":
59
+ - !binary |-
60
+ TW9uLCAzMCBKdWwgMjAxMiAxMjozMDowOSBHTVQ=
61
+ !binary "dmFyeQ==":
62
+ - !binary |-
63
+ QWNjZXB0LUVuY29kaW5n
64
+ !binary "Y29udGVudC1lbmNvZGluZw==":
65
+ - !binary |-
66
+ Z3ppcA==
67
+ !binary "Y29udGVudC1sZW5ndGg=":
68
+ - !binary |-
69
+ MTAx
70
+ !binary "c2VydmVy":
71
+ - !binary |-
72
+ dGZl
73
+ body:
74
+ encoding: ASCII-8BIT
75
+ string: !binary |-
76
+ H4sIAAAAAAAAAxXLwQqAIAwA0F+RnUPp2rXfEGLoIkMczS2I6N+r+3s3kAgL
77
+ TDCz1ewaq0PTjZqWhEruYvMwgNBh1PVzMYwxYEpsTWM4Scp6LUko/wVr93vn
78
+ Bs8L+8HgvlkAAAA=
79
+ http_version: !binary |-
80
+ MS4x
81
+ recorded_at: Mon, 30 Jul 2012 12:25:08 GMT
82
+ recorded_with: VCR 2.2.4
@@ -0,0 +1,241 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.twitter.com/1/account/verify_credentials.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ accept-encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ accept:
13
+ - ! '*/*'
14
+ user-agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ date:
22
+ - Mon, 30 Jul 2012 12:25:03 GMT
23
+ status:
24
+ - 200 OK
25
+ etag:
26
+ - ! '"9fe80e1f4151f6e94e47c947bedface3"'
27
+ x-runtime:
28
+ - '0.04246'
29
+ pragma:
30
+ - no-cache
31
+ cache-control:
32
+ - no-cache, no-store, must-revalidate, pre-check=0, post-check=0
33
+ x-access-level:
34
+ - read-write
35
+ x-ratelimit-class:
36
+ - api_identified
37
+ x-ratelimit-remaining:
38
+ - '349'
39
+ x-transaction:
40
+ - e8d57b0f86c199ce
41
+ x-ratelimit-reset:
42
+ - '1343654703'
43
+ expires:
44
+ - Tue, 31 Mar 1981 05:00:00 GMT
45
+ x-frame-options:
46
+ - SAMEORIGIN
47
+ x-ratelimit-limit:
48
+ - '350'
49
+ x-transaction-mask:
50
+ - a6183ffa5f8ca943ff1b53b5644ef11440ad50ea
51
+ x-mid:
52
+ - bdc5d4ad020e396c56952e513b0a36526fc24d19
53
+ last-modified:
54
+ - Mon, 30 Jul 2012 12:25:03 GMT
55
+ content-type:
56
+ - application/json; charset=utf-8
57
+ set-cookie:
58
+ - k=10.34.126.113.1343651103310940; path=/; expires=Mon, 06-Aug-12 12:25:03
59
+ GMT; domain=.twitter.com
60
+ - guest_id=v1%3A134365110331523023; domain=.twitter.com; path=/; expires=Thu,
61
+ 31-Jul-2014 00:25:03 GMT
62
+ - dnt=; domain=.twitter.com; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT
63
+ - lang=en; path=/
64
+ - lang=en; path=/
65
+ - lang=en; path=/
66
+ - twid=u%3D16893620%7CIHx9kxnNmH820HabKi2djgPA8rg%3D; domain=.twitter.com; path=/;
67
+ secure
68
+ - _twitter_sess=BAh7CSIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo%250ASGFzaHsABjoKQHVzZWR7ADoPY3JlYXRlZF9hdGwrCGLC2Nc4AToMY3NyZl9p%250AZCIlZDEzMWFhNzY2NDJmNDNlMTljODNmZmY5MTI5NDczNzA6B2lkIiVlOTUy%250ANWIwNjE5NjdhMDQwNTRhNzE5ODk0MTI4NjNjNg%253D%253D--4905d4dcc8a7ddcb016670d5a13a4563aaeee26e;
69
+ domain=.twitter.com; path=/; HttpOnly
70
+ vary:
71
+ - Accept-Encoding
72
+ content-encoding:
73
+ - gzip
74
+ transfer-encoding:
75
+ - chunked
76
+ server:
77
+ - tfe
78
+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7v0EJev1g
97
+ 2BdgzmioDQNWwaKNomUM9H0na2CGNS0ZEcfsp2FOMtA1SMc2xjK4bUMw1qxB
98
+ FoxKZ7xpwCpgH97xp6PxQvHe8enu4U+/ARPK9FIVBwAA
99
+ http_version: '1.1'
100
+ recorded_at: Mon, 30 Jul 2012 12:25:02 GMT
101
+ - request:
102
+ method: get
103
+ uri: https://api.twitter.com/1/account/verify_credentials.json
104
+ body:
105
+ encoding: US-ASCII
106
+ string: ''
107
+ headers:
108
+ accept-encoding:
109
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
110
+ accept:
111
+ - ! '*/*'
112
+ user-agent:
113
+ - Ruby
114
+ response:
115
+ status:
116
+ code: 200
117
+ message: !binary |-
118
+ T0s=
119
+ headers:
120
+ !binary "ZGF0ZQ==":
121
+ - !binary |-
122
+ TW9uLCAzMCBKdWwgMjAxMiAxMjoyNTowNSBHTVQ=
123
+ !binary "c3RhdHVz":
124
+ - !binary |-
125
+ MjAwIE9L
126
+ !binary "eC1ydW50aW1l":
127
+ - !binary |-
128
+ MC4wNDQ4Nw==
129
+ !binary "eC1hY2Nlc3MtbGV2ZWw=":
130
+ - !binary |-
131
+ cmVhZC13cml0ZQ==
132
+ !binary "eC1yYXRlbGltaXQtY2xhc3M=":
133
+ - !binary |-
134
+ YXBpX2lkZW50aWZpZWQ=
135
+ !binary "eC1taWQ=":
136
+ - !binary |-
137
+ MTIzODY5MzJkMmU3YjNjYzAyMzYxMzljNTdiZjAwMjc2OThjMjYyYw==
138
+ !binary "bGFzdC1tb2RpZmllZA==":
139
+ - !binary |-
140
+ TW9uLCAzMCBKdWwgMjAxMiAxMjoyNTowNSBHTVQ=
141
+ !binary "eC1yYXRlbGltaXQtcmVzZXQ=":
142
+ - !binary |-
143
+ MTM0MzY1NDcwMw==
144
+ !binary "eC10cmFuc2FjdGlvbg==":
145
+ - !binary |-
146
+ ZDFiYmE5Njg4NmYyMzhmYQ==
147
+ !binary "cHJhZ21h":
148
+ - !binary |-
149
+ bm8tY2FjaGU=
150
+ !binary "ZXhwaXJlcw==":
151
+ - !binary |-
152
+ VHVlLCAzMSBNYXIgMTk4MSAwNTowMDowMCBHTVQ=
153
+ !binary "Y2FjaGUtY29udHJvbA==":
154
+ - !binary |-
155
+ bm8tY2FjaGUsIG5vLXN0b3JlLCBtdXN0LXJldmFsaWRhdGUsIHByZS1jaGVj
156
+ az0wLCBwb3N0LWNoZWNrPTA=
157
+ !binary "ZXRhZw==":
158
+ - !binary |-
159
+ IjlmZTgwZTFmNDE1MWY2ZTk0ZTQ3Yzk0N2JlZGZhY2UzIg==
160
+ !binary "eC1yYXRlbGltaXQtcmVtYWluaW5n":
161
+ - !binary |-
162
+ MzQ4
163
+ !binary "eC1mcmFtZS1vcHRpb25z":
164
+ - !binary |-
165
+ U0FNRU9SSUdJTg==
166
+ !binary "eC1yYXRlbGltaXQtbGltaXQ=":
167
+ - !binary |-
168
+ MzUw
169
+ !binary "Y29udGVudC10eXBl":
170
+ - !binary |-
171
+ YXBwbGljYXRpb24vanNvbjsgY2hhcnNldD11dGYtOA==
172
+ !binary "eC10cmFuc2FjdGlvbi1tYXNr":
173
+ - !binary |-
174
+ YTYxODNmZmE1ZjhjYTk0M2ZmMWI1M2I1NjQ0ZWYxMTQ0MGFkNTBlYQ==
175
+ !binary "c2V0LWNvb2tpZQ==":
176
+ - !binary |-
177
+ az0xMC4zNC4yMzQuMTE2LjEzNDM2NTExMDU0NjQ2NDk7IHBhdGg9LzsgZXhw
178
+ aXJlcz1Nb24sIDA2LUF1Zy0xMiAxMjoyNTowNSBHTVQ7IGRvbWFpbj0udHdp
179
+ dHRlci5jb20=
180
+ - !binary |-
181
+ Z3Vlc3RfaWQ9djElM0ExMzQzNjUxMTA1NDY5NjAwMTU7IGRvbWFpbj0udHdp
182
+ dHRlci5jb207IHBhdGg9LzsgZXhwaXJlcz1UaHUsIDMxLUp1bC0yMDE0IDAw
183
+ OjI1OjA1IEdNVA==
184
+ - !binary |-
185
+ ZG50PTsgZG9tYWluPS50d2l0dGVyLmNvbTsgcGF0aD0vOyBleHBpcmVzPVRo
186
+ dSwgMDEtSmFuLTE5NzAgMDA6MDA6MDAgR01U
187
+ - !binary |-
188
+ bGFuZz1lbjsgcGF0aD0v
189
+ - !binary |-
190
+ bGFuZz1lbjsgcGF0aD0v
191
+ - !binary |-
192
+ bGFuZz1lbjsgcGF0aD0v
193
+ - !binary |-
194
+ dHdpZD11JTNEMTY4OTM2MjAlN0NJSHg5a3huTm1IODIwSGFiS2kyZGpnUEE4
195
+ cmclM0Q7IGRvbWFpbj0udHdpdHRlci5jb207IHBhdGg9Lzsgc2VjdXJl
196
+ - !binary |-
197
+ X3R3aXR0ZXJfc2Vzcz1CQWg3Q1NJS1pteGhjMmhKUXpvblFXTjBhVzl1UTI5
198
+ dWRISnZiR3hsY2pvNlJteGhjMmc2T2tac1lYTm8lMjUwQVNHRnphSHNBQmpv
199
+ S1FIVnpaV1I3QURvUFkzSmxZWFJsWkY5aGRHd3JDTTNLMk5jNEFUb01ZM055
200
+ Wmw5cCUyNTBBWkNJbE1XSXhZelJpTmpoak1UZzJPVEpqWWprME56QmhPV1ps
201
+ TkRCak1UZ3lOamM2QjJsa0lpVXpZVFUwJTI1MEFPRFV6TnpreFkyTm1aakF3
202
+ TkRsaU1HSTBOV1UwWTJFek9UTXpOUSUyNTNEJTI1M0QtLTA0NjgzZGM5ZTdh
203
+ NjBlZDRjOTE5OTczYzdlNjQ2NTNmZDg2OGIwYjg7IGRvbWFpbj0udHdpdHRl
204
+ ci5jb207IHBhdGg9LzsgSHR0cE9ubHk=
205
+ !binary "dmFyeQ==":
206
+ - !binary |-
207
+ QWNjZXB0LUVuY29kaW5n
208
+ !binary "Y29udGVudC1lbmNvZGluZw==":
209
+ - !binary |-
210
+ Z3ppcA==
211
+ !binary "Y29udGVudC1sZW5ndGg=":
212
+ - !binary |-
213
+ Nzky
214
+ !binary "c2VydmVy":
215
+ - !binary |-
216
+ dGZl
217
+ body:
218
+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io
236
+ DQNWwaKNomUM9H0na2CGNS0ZEcfsp2FOMtA1SMc2xjK4bUMw1qxBFoxKZ7xp
237
+ wCpgH97xp6PxQvHe8enu4U+/ARPK9FIVBwAA
238
+ http_version: !binary |-
239
+ MS4x
240
+ recorded_at: Mon, 30 Jul 2012 12:25:04 GMT
241
+ recorded_with: VCR 2.2.4
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rack::OAuthEcho::Middleware, vcr: { record: :once } do
4
+
5
+ def app
6
+ app = lambda { |env| [200, {}, "Hello, World!"] }
7
+ Rack::OAuthEcho::Middleware.new(app)
8
+ end
9
+
10
+ describe "OAuth Echo" do
11
+ context "valid headers" do
12
+ let(:headers) do
13
+ method = :get
14
+ uri = "https://api.twitter.com/1/account/verify_credentials.json"
15
+ params = {}
16
+ credentials = {
17
+ consumer_key: "___",
18
+ consumer_secret: "___",
19
+ token: "___",
20
+ token_secret: "___"
21
+ }
22
+
23
+ {
24
+ 'X-Auth-Service-Provider' =>
25
+ "https://api.twitter.com/1/account/verify_credentials.json",
26
+ 'X-Verify-Credentials-Authorization' =>
27
+ SimpleOAuth::Header.new(method, uri, params, credentials).to_s
28
+ }
29
+ end
30
+
31
+ before(:each) { get "/", {}, headers }
32
+
33
+ it "should retrieve user_hash" do
34
+ user_hash = last_request.env['rack-oauth_echo.user_hash']
35
+ user_hash['id'].should eq(16893620)
36
+ user_hash['screen_name'].should eq("albertobajo")
37
+ end
38
+ end
39
+
40
+ context "without headers" do
41
+ before(:each) { get "/" }
42
+
43
+ it "should skip assignment" do
44
+ last_request.env['rack-oauth_echo.user_hash'].should be_nil
45
+ end
46
+ end
47
+
48
+ context "invalid headers" do
49
+ let(:headers) do
50
+ {
51
+ 'X-Auth-Service-Provider' =>
52
+ "https://api.twitter.com/1/account/verify_credentials.json",
53
+ 'X-Verify-Credentials-Authorization' => 'bad header'
54
+ }
55
+ end
56
+
57
+ before(:each) { get "/", {}, headers }
58
+
59
+ it "should return a 401 status" do
60
+ last_response.status.should eq(401)
61
+ end
62
+
63
+ it "should return an error msg" do
64
+ last_response.body.include?("Could not authenticate you.").
65
+ should be_true
66
+ end
67
+
68
+ end
69
+ end
70
+
71
+ end
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'spork'
4
+
5
+ require 'fakeweb'
6
+ require 'faraday_middleware'
7
+ require 'rack/test'
8
+ require 'rack/oauth_echo'
9
+ require 'simple_oauth'
10
+ require 'vcr'
11
+
12
+ Spork.prefork do
13
+ # Requires supporting ruby files with custom matchers and macros, etc,
14
+ # in spec/support/ and its subdirectories.
15
+ Dir[Dir.pwd << ("/spec/support/**/*.rb")].each {|f| require f}
16
+
17
+ RSpec.configure do |c|
18
+ c.include Rack::Test::Methods
19
+ c.treat_symbols_as_metadata_keys_with_true_values = true
20
+ end
21
+ end
22
+
23
+ Spork.each_run do
24
+ # This code will be run each time you run your specs.
25
+
26
+ end
@@ -0,0 +1 @@
1
+ FakeWeb.allow_net_connect = false
@@ -0,0 +1,5 @@
1
+ VCR.configure do |c|
2
+ c.cassette_library_dir = 'spec/cassettes'
3
+ c.hook_into :fakeweb
4
+ c.configure_rspec_metadata!
5
+ end
metadata ADDED
@@ -0,0 +1,214 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-oauth_echo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alberto Bajo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: faraday_middleware
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.8.8
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.8.8
30
+ - !ruby/object:Gem::Dependency
31
+ name: rack
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.4.1
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.4.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: fakeweb
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.3.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: json
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.7.4
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.7.4
78
+ - !ruby/object:Gem::Dependency
79
+ name: rack-test
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 0.6.1
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.6.1
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 2.11.0
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 2.11.0
110
+ - !ruby/object:Gem::Dependency
111
+ name: simple_oauth
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 0.1.9
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 0.1.9
126
+ - !ruby/object:Gem::Dependency
127
+ name: spork
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 0.9.2
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 0.9.2
142
+ - !ruby/object:Gem::Dependency
143
+ name: vcr
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: 2.2.4
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 2.2.4
158
+ description: OAuth Echo authentication by a rack middleware
159
+ email:
160
+ - albertobajo@gmail.com
161
+ executables: []
162
+ extensions: []
163
+ extra_rdoc_files: []
164
+ files:
165
+ - .gitignore
166
+ - .rspec
167
+ - Gemfile
168
+ - LICENSE
169
+ - README.md
170
+ - Rakefile
171
+ - lib/rack/oauth_echo.rb
172
+ - lib/rack/oauth_echo/version.rb
173
+ - rack-oauth_echo.gemspec
174
+ - spec/cassettes/Rack_OAuthEcho_Middleware/OAuth_Echo/invalid_headers/should_return_a_401_status.yml
175
+ - spec/cassettes/Rack_OAuthEcho_Middleware/OAuth_Echo/invalid_headers/should_return_an_error_msg.yml
176
+ - spec/cassettes/Rack_OAuthEcho_Middleware/OAuth_Echo/valid_headers/should_retrieve_user_hash.yml
177
+ - spec/lib/rack/oauth_echo_spec.rb
178
+ - spec/spec_helper.rb
179
+ - spec/support/fakeweb.rb
180
+ - spec/support/vcr.rb
181
+ homepage: http://github.com/albertobajo/rack-oauth_echo
182
+ licenses: []
183
+ post_install_message:
184
+ rdoc_options: []
185
+ require_paths:
186
+ - lib
187
+ required_ruby_version: !ruby/object:Gem::Requirement
188
+ none: false
189
+ requirements:
190
+ - - ! '>='
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ required_rubygems_version: !ruby/object:Gem::Requirement
194
+ none: false
195
+ requirements:
196
+ - - ! '>='
197
+ - !ruby/object:Gem::Version
198
+ version: '0'
199
+ requirements: []
200
+ rubyforge_project:
201
+ rubygems_version: 1.8.24
202
+ signing_key:
203
+ specification_version: 3
204
+ summary: Rack::OAuthEcho it a small, simple middleware for authenticate OAuth Echo
205
+ requests.
206
+ test_files:
207
+ - spec/cassettes/Rack_OAuthEcho_Middleware/OAuth_Echo/invalid_headers/should_return_a_401_status.yml
208
+ - spec/cassettes/Rack_OAuthEcho_Middleware/OAuth_Echo/invalid_headers/should_return_an_error_msg.yml
209
+ - spec/cassettes/Rack_OAuthEcho_Middleware/OAuth_Echo/valid_headers/should_retrieve_user_hash.yml
210
+ - spec/lib/rack/oauth_echo_spec.rb
211
+ - spec/spec_helper.rb
212
+ - spec/support/fakeweb.rb
213
+ - spec/support/vcr.rb
214
+ has_rdoc: