oauth2-rack 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -1
- data/.travis.yml +8 -0
- data/Gemfile +10 -2
- data/Gemfile.lock +62 -0
- data/LICENSE.md +23 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/lib/oauth2/rack/authentication/client/http_basic.rb +4 -2
- data/lib/oauth2/rack/authentication/client/request_params.rb +3 -2
- data/lib/oauth2/rack/authentication/resource_owner/request_params.rb +8 -2
- data/lib/oauth2/rack/version.rb +5 -0
- data/oauth2-rack.gemspec +30 -0
- metadata +33 -20
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,7 +1,15 @@
|
|
1
|
+
source 'http://ruby.taobao.org'
|
1
2
|
source :rubygems
|
2
3
|
|
3
4
|
gemspec
|
4
5
|
|
5
|
-
|
6
|
-
gem '
|
6
|
+
group :linux_development do
|
7
|
+
gem 'libnotify'
|
8
|
+
gem 'rb-inotify'
|
9
|
+
end
|
10
|
+
|
11
|
+
group :mac_development do
|
12
|
+
gem 'rb-fsevent'
|
13
|
+
gem 'growl'
|
14
|
+
end
|
7
15
|
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
oauth2-rack (0.0.2)
|
5
|
+
multi_json
|
6
|
+
rack
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://ruby.taobao.org/
|
10
|
+
remote: http://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.2.6)
|
13
|
+
diff-lcs (1.1.2)
|
14
|
+
faraday (0.7.4)
|
15
|
+
addressable (~> 2.2.6)
|
16
|
+
multipart-post (~> 1.1.0)
|
17
|
+
rack (>= 1.1.0, < 2)
|
18
|
+
ffi (1.0.9)
|
19
|
+
growl (1.0.3)
|
20
|
+
guard (0.6.2)
|
21
|
+
thor (~> 0.14.6)
|
22
|
+
guard-rspec (0.4.3)
|
23
|
+
guard (>= 0.4.0)
|
24
|
+
libnotify (0.5.7)
|
25
|
+
multi_json (1.0.3)
|
26
|
+
multipart-post (1.1.3)
|
27
|
+
oauth2 (0.5.0)
|
28
|
+
faraday (>= 0.6.1, < 0.8)
|
29
|
+
multi_json (~> 1.0.0)
|
30
|
+
rack (1.3.2)
|
31
|
+
rake (0.9.2)
|
32
|
+
rb-fsevent (0.4.3.1)
|
33
|
+
rb-inotify (0.8.6)
|
34
|
+
ffi (>= 0.5.0)
|
35
|
+
rspec (2.6.0)
|
36
|
+
rspec-core (~> 2.6.0)
|
37
|
+
rspec-expectations (~> 2.6.0)
|
38
|
+
rspec-mocks (~> 2.6.0)
|
39
|
+
rspec-core (2.6.4)
|
40
|
+
rspec-expectations (2.6.0)
|
41
|
+
diff-lcs (~> 1.1.2)
|
42
|
+
rspec-mocks (2.6.0)
|
43
|
+
shotgun (0.9)
|
44
|
+
rack (>= 1.0)
|
45
|
+
thor (0.14.6)
|
46
|
+
yard (0.7.2)
|
47
|
+
|
48
|
+
PLATFORMS
|
49
|
+
ruby
|
50
|
+
|
51
|
+
DEPENDENCIES
|
52
|
+
growl
|
53
|
+
guard-rspec
|
54
|
+
libnotify
|
55
|
+
oauth2
|
56
|
+
oauth2-rack!
|
57
|
+
rake
|
58
|
+
rb-fsevent
|
59
|
+
rb-inotify
|
60
|
+
rspec
|
61
|
+
shotgun
|
62
|
+
yard
|
data/LICENSE.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
LICENSE
|
2
|
+
|
3
|
+
The MIT License
|
4
|
+
|
5
|
+
Copyright (c) 2011 Ian Yang
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
9
|
+
in the Software without restriction, including without limitation the rights
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
12
|
+
furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
15
|
+
all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# OAuth2 Rack
|
2
|
+
|
3
|
+
OAuth2 Rack implements OAuth2 provider in Rack.
|
4
|
+
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
|
8
|
+
See an example in `config.ru`.
|
9
|
+
|
10
|
+
## Continuous Integration
|
11
|
+
|
12
|
+
[![Build Status](http://travis-ci.org/doitian/oauth2-rack.png)](http://travis-ci.org/doitian/oauth2-rack)
|
13
|
+
|
14
|
+
## Contributing
|
15
|
+
|
16
|
+
Forck the repository, make your changes and issue a pull request. Do add test
|
17
|
+
cases so I won't break your code in feature releases.
|
18
|
+
|
19
|
+
### Bunder ###
|
20
|
+
|
21
|
+
For Linux:
|
22
|
+
|
23
|
+
bundle install --without mac_development
|
24
|
+
|
25
|
+
For Mac:
|
26
|
+
|
27
|
+
bundle install --without linux_development
|
28
|
+
|
29
|
+
## License
|
30
|
+
|
31
|
+
oauth2-rack is licensed under the MIT License.
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'oauth2/rack'
|
2
2
|
|
3
|
-
# 2.
|
3
|
+
# 2.3.1. Client Password
|
4
4
|
class OAuth2::Rack::Authentication::Client::HTTPBasic
|
5
5
|
HEADER_KEYS = ['HTTP_AUTHORIZATION', 'X-HTTP_AUTHORIZATION', 'X_HTTP_AUTHORIZATION']
|
6
6
|
|
@@ -28,7 +28,9 @@ class OAuth2::Rack::Authentication::Client::HTTPBasic
|
|
28
28
|
end
|
29
29
|
|
30
30
|
client_id, client_secret = credentials.unpack('m*').first.split(':', 2)
|
31
|
-
client = @authenticator.call(:client_id => client_id,
|
31
|
+
client = @authenticator.call(:client_id => client_id,
|
32
|
+
:client_secret => client_secret)
|
33
|
+
|
32
34
|
if client
|
33
35
|
env['oauth2.client'] = client
|
34
36
|
@app.call(env)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'oauth2/rack'
|
2
2
|
|
3
|
-
# 2.
|
3
|
+
# 2.3.1. Client Password
|
4
4
|
# Send client_id and client_secret in request params
|
5
5
|
class OAuth2::Rack::Authentication::Client::RequestParams
|
6
6
|
def initialize(app, opts = {}, &authenticator)
|
@@ -23,7 +23,8 @@ class OAuth2::Rack::Authentication::Client::RequestParams
|
|
23
23
|
return bad_request
|
24
24
|
end
|
25
25
|
|
26
|
-
client = @authenticator.call(:client_id => client_id,
|
26
|
+
client = @authenticator.call(:client_id => client_id,
|
27
|
+
:client_secret => client_secret)
|
27
28
|
if client
|
28
29
|
env['oauth2.client'] = client
|
29
30
|
@app.call(env)
|
@@ -22,7 +22,13 @@ class OAuth2::Rack::Authentication::ResourceOwner::RequestParams
|
|
22
22
|
return bad_request
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
credentials = {
|
26
|
+
:username => username,
|
27
|
+
:password => password
|
28
|
+
}
|
29
|
+
credentials[:client] = env['oauth2.client'] if env['oauth2.client']
|
30
|
+
resource_owner = @authenticator.call credentials
|
31
|
+
|
26
32
|
if resource_owner
|
27
33
|
env['oauth2.resource_owner'] = resource_owner
|
28
34
|
@app.call(env)
|
@@ -30,7 +36,7 @@ class OAuth2::Rack::Authentication::ResourceOwner::RequestParams
|
|
30
36
|
unauthorized
|
31
37
|
end
|
32
38
|
end
|
33
|
-
|
39
|
+
|
34
40
|
private
|
35
41
|
def authenticate(opts)
|
36
42
|
@authenticator && @authenticator.call(opts)
|
data/oauth2-rack.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "oauth2/rack/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "oauth2-rack"
|
7
|
+
s.version = OAuth2::Rack::VERSION
|
8
|
+
s.authors = ["Ian Yang"]
|
9
|
+
s.email = ["me@iany.me"]
|
10
|
+
s.homepage = "https://github.com/doitian/oauth2-rack"
|
11
|
+
s.summary = %q{Rack middlewares for OAuth2 authorization server and resource server}
|
12
|
+
s.description = %q{Rack middlewares for OAuth2 authorization server and resource server}
|
13
|
+
s.license = 'MIT'
|
14
|
+
s.rubyforge_project = "oauth2-rack"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_runtime_dependency 'multi_json'
|
22
|
+
s.add_runtime_dependency 'rack'
|
23
|
+
|
24
|
+
s.add_development_dependency 'rake'
|
25
|
+
s.add_development_dependency 'rspec'
|
26
|
+
s.add_development_dependency 'yard'
|
27
|
+
s.add_development_dependency 'shotgun'
|
28
|
+
s.add_development_dependency 'guard-rspec'
|
29
|
+
s.add_development_dependency 'oauth2'
|
30
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oauth2-rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-28 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152835660 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152835660
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rack
|
27
|
-
requirement: &
|
27
|
+
requirement: &2152835060 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2152835060
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &2152834500 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2152834500
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &2152828640 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2152828640
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: yard
|
60
|
-
requirement: &
|
60
|
+
requirement: &2152828100 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2152828100
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: shotgun
|
71
|
-
requirement: &
|
71
|
+
requirement: &2152827500 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2152827500
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: guard-rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &2152826840 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2152826840
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: oauth2
|
93
|
-
requirement: &
|
93
|
+
requirement: &2152826100 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *2152826100
|
102
102
|
description: Rack middlewares for OAuth2 authorization server and resource server
|
103
103
|
email:
|
104
104
|
- me@iany.me
|
@@ -108,8 +108,12 @@ extra_rdoc_files: []
|
|
108
108
|
files:
|
109
109
|
- .gitignore
|
110
110
|
- .rspec
|
111
|
+
- .travis.yml
|
111
112
|
- Gemfile
|
113
|
+
- Gemfile.lock
|
112
114
|
- Guardfile
|
115
|
+
- LICENSE.md
|
116
|
+
- README.md
|
113
117
|
- Rakefile
|
114
118
|
- config.ru
|
115
119
|
- examples/ruby-client/password_authorization.rb
|
@@ -126,6 +130,8 @@ files:
|
|
126
130
|
- lib/oauth2/rack/authorization/client_credentials/access_token_issuer.rb
|
127
131
|
- lib/oauth2/rack/authorization/password.rb
|
128
132
|
- lib/oauth2/rack/authorization/password/access_token_issuer.rb
|
133
|
+
- lib/oauth2/rack/version.rb
|
134
|
+
- oauth2-rack.gemspec
|
129
135
|
- spec/oauth2/rack/authentication/client/http_basic_spec.rb
|
130
136
|
- spec/oauth2/rack/authentication/client/request_params_spec.rb
|
131
137
|
- spec/oauth2/rack/authentication/resource_owner/request_params_spec.rb
|
@@ -134,7 +140,8 @@ files:
|
|
134
140
|
- spec/spec_helper.rb
|
135
141
|
- spec/support/rake_test_helper.rb
|
136
142
|
homepage: https://github.com/doitian/oauth2-rack
|
137
|
-
licenses:
|
143
|
+
licenses:
|
144
|
+
- MIT
|
138
145
|
post_install_message:
|
139
146
|
rdoc_options: []
|
140
147
|
require_paths:
|
@@ -145,15 +152,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
152
|
- - ! '>='
|
146
153
|
- !ruby/object:Gem::Version
|
147
154
|
version: '0'
|
155
|
+
segments:
|
156
|
+
- 0
|
157
|
+
hash: -4282263229156932656
|
148
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
159
|
none: false
|
150
160
|
requirements:
|
151
161
|
- - ! '>='
|
152
162
|
- !ruby/object:Gem::Version
|
153
163
|
version: '0'
|
164
|
+
segments:
|
165
|
+
- 0
|
166
|
+
hash: -4282263229156932656
|
154
167
|
requirements: []
|
155
168
|
rubyforge_project: oauth2-rack
|
156
|
-
rubygems_version: 1.8.
|
169
|
+
rubygems_version: 1.8.10
|
157
170
|
signing_key:
|
158
171
|
specification_version: 3
|
159
172
|
summary: Rack middlewares for OAuth2 authorization server and resource server
|