songkick-oauth2-provider 0.10.2 → 0.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/History.txt +7 -0
- data/README.rdoc +18 -11
- data/example/README.rdoc +1 -1
- data/example/application.rb +9 -9
- data/example/schema.rb +1 -1
- data/example/views/authorize.erb +2 -2
- data/example/views/layout.erb +4 -4
- data/example/views/login.erb +2 -2
- data/example/views/new_client.erb +1 -1
- data/example/views/new_user.erb +1 -1
- data/lib/songkick/oauth2/model.rb +8 -6
- data/lib/songkick/oauth2/model/authorization.rb +31 -31
- data/lib/songkick/oauth2/model/client.rb +15 -15
- data/lib/songkick/oauth2/model/client_owner.rb +2 -2
- data/lib/songkick/oauth2/model/hashing.rb +3 -3
- data/lib/songkick/oauth2/model/helpers.rb +16 -0
- data/lib/songkick/oauth2/model/resource_owner.rb +4 -4
- data/lib/songkick/oauth2/provider.rb +16 -16
- data/lib/songkick/oauth2/provider/access_token.rb +20 -15
- data/lib/songkick/oauth2/provider/authorization.rb +43 -42
- data/lib/songkick/oauth2/provider/error.rb +4 -4
- data/lib/songkick/oauth2/provider/exchange.rb +46 -46
- data/lib/songkick/oauth2/router.rb +13 -13
- data/lib/songkick/oauth2/schema.rb +11 -3
- data/lib/songkick/oauth2/schema/20120828112156_songkick_oauth2_schema_original_schema.rb +2 -2
- data/lib/songkick/oauth2/schema/20121024180930_songkick_oauth2_schema_add_authorization_index.rb +3 -3
- data/lib/songkick/oauth2/schema/20121025180447_songkick_oauth2_schema_add_unique_indexes.rb +7 -7
- data/spec/request_helpers.rb +25 -21
- data/spec/songkick/oauth2/model/authorization_spec.rb +56 -56
- data/spec/songkick/oauth2/model/client_spec.rb +9 -9
- data/spec/songkick/oauth2/model/helpers_spec.rb +26 -0
- data/spec/songkick/oauth2/model/resource_owner_spec.rb +13 -13
- data/spec/songkick/oauth2/provider/access_token_spec.rb +32 -20
- data/spec/songkick/oauth2/provider/authorization_spec.rb +73 -62
- data/spec/songkick/oauth2/provider/exchange_spec.rb +72 -72
- data/spec/songkick/oauth2/provider_spec.rb +101 -101
- data/spec/spec_helper.rb +5 -3
- data/spec/test_app/helper.rb +11 -7
- data/spec/test_app/provider/application.rb +12 -12
- data/spec/test_app/provider/views/authorize.erb +2 -2
- metadata +71 -93
data/spec/spec_helper.rb
CHANGED
@@ -2,6 +2,8 @@ require 'rubygems'
|
|
2
2
|
require 'bundler/setup'
|
3
3
|
|
4
4
|
require 'active_record'
|
5
|
+
require 'protected_attributes' if defined?(ActiveRecord::VERSION) && ActiveRecord::VERSION::MAJOR > 3
|
6
|
+
|
5
7
|
require 'songkick/oauth2/provider'
|
6
8
|
|
7
9
|
case ENV['DB']
|
@@ -20,7 +22,7 @@ case ENV['DB']
|
|
20
22
|
else
|
21
23
|
dbfile = File.expand_path('../test.sqlite3', __FILE__)
|
22
24
|
File.unlink(dbfile) if File.file?(dbfile)
|
23
|
-
|
25
|
+
|
24
26
|
ActiveRecord::Base.establish_connection(
|
25
27
|
:adapter => 'sqlite3',
|
26
28
|
:database => dbfile)
|
@@ -60,12 +62,12 @@ RSpec.configure do |config|
|
|
60
62
|
time = Time.now
|
61
63
|
Time.stub(:now).and_return time
|
62
64
|
end
|
63
|
-
|
65
|
+
|
64
66
|
config.after do
|
65
67
|
[ Songkick::OAuth2::Model::Client,
|
66
68
|
Songkick::OAuth2::Model::Authorization,
|
67
69
|
TestApp::User
|
68
|
-
|
70
|
+
|
69
71
|
].each { |k| k.delete_all }
|
70
72
|
end
|
71
73
|
end
|
data/spec/test_app/helper.rb
CHANGED
@@ -1,16 +1,20 @@
|
|
1
1
|
module TestApp
|
2
|
-
|
2
|
+
|
3
3
|
class User < ActiveRecord::Base
|
4
4
|
self.table_name = :users
|
5
|
-
|
5
|
+
|
6
6
|
include Songkick::OAuth2::Model::ResourceOwner
|
7
7
|
include Songkick::OAuth2::Model::ClientOwner
|
8
|
-
|
8
|
+
|
9
9
|
def self.[](name)
|
10
|
-
|
10
|
+
if respond_to?(:find_or_create_by)
|
11
|
+
find_or_create_by(:name => name)
|
12
|
+
else
|
13
|
+
find_or_create_by_name(name)
|
14
|
+
end
|
11
15
|
end
|
12
16
|
end
|
13
|
-
|
17
|
+
|
14
18
|
module Helper
|
15
19
|
module RackRunner
|
16
20
|
def start(port)
|
@@ -20,7 +24,7 @@ module TestApp
|
|
20
24
|
end
|
21
25
|
sleep 0.1 until @server
|
22
26
|
end
|
23
|
-
|
27
|
+
|
24
28
|
def stop
|
25
29
|
@server.stop if @server
|
26
30
|
@server = nil
|
@@ -28,6 +32,6 @@ module TestApp
|
|
28
32
|
end
|
29
33
|
end
|
30
34
|
end
|
31
|
-
|
35
|
+
|
32
36
|
end
|
33
37
|
|
@@ -3,20 +3,20 @@ require File.expand_path('../../helper', __FILE__)
|
|
3
3
|
|
4
4
|
module TestApp
|
5
5
|
class Provider < Sinatra::Base
|
6
|
-
|
6
|
+
|
7
7
|
extend Helper::RackRunner
|
8
|
-
|
8
|
+
|
9
9
|
Songkick::OAuth2::Provider.realm = 'Demo App'
|
10
|
-
|
10
|
+
|
11
11
|
set :views, File.dirname(__FILE__) + '/views'
|
12
|
-
|
12
|
+
|
13
13
|
def handle_authorize
|
14
14
|
@oauth2 = Songkick::OAuth2::Provider.parse(User['Bob'], env)
|
15
15
|
redirect(@oauth2.redirect_uri, @oauth2.response_status) if @oauth2.redirect?
|
16
|
-
|
16
|
+
|
17
17
|
headers @oauth2.response_headers
|
18
18
|
status @oauth2.response_status
|
19
|
-
|
19
|
+
|
20
20
|
if body = @oauth2.response_body
|
21
21
|
body
|
22
22
|
elsif @oauth2.valid?
|
@@ -25,14 +25,14 @@ module TestApp
|
|
25
25
|
'WAT'
|
26
26
|
end
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def protect_resource_for(user = nil, scopes = [])
|
30
30
|
access_token = Songkick::OAuth2::Provider.access_token(user, scopes, env)
|
31
31
|
headers access_token.response_headers
|
32
32
|
status access_token.response_status
|
33
33
|
yield access_token
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def serve_protected_resource
|
37
37
|
@user = User['Bob']
|
38
38
|
protect_resource_for(@user, ['profile']) do |auth|
|
@@ -43,11 +43,11 @@ module TestApp
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
[:get, :post].each do |method|
|
48
48
|
__send__(method, '/authorize') { handle_authorize }
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
post '/allow' do
|
52
52
|
@user = User['bob']
|
53
53
|
@oauth2 = Songkick::OAuth2::Provider::Authorization.new(@user, params)
|
@@ -58,11 +58,11 @@ module TestApp
|
|
58
58
|
end
|
59
59
|
redirect @oauth2.redirect_uri, @oauth2.response_status
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
[:get, :post].each do |method|
|
63
63
|
__send__(method, '/user_profile') { serve_protected_resource }
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -10,10 +10,10 @@
|
|
10
10
|
<% @oauth2.params.each do |key, value| %>
|
11
11
|
<input type="hidden" name="<%= key %>" value="<%= value %>">
|
12
12
|
<% end %>
|
13
|
-
|
13
|
+
|
14
14
|
<input type="checkbox" name="allow" id="allow" value="1">
|
15
15
|
<label for="allow">Allow this application</label>
|
16
|
-
|
16
|
+
|
17
17
|
<input type="submit" value="Go!">
|
18
18
|
</form>
|
19
19
|
|
metadata
CHANGED
@@ -1,192 +1,169 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: songkick-oauth2-provider
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
5
|
-
prerelease:
|
4
|
+
version: 0.10.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- James Coglan
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2017-10-24 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activerecord
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
|
-
name: bcrypt
|
28
|
+
name: bcrypt
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: json
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rack
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: appraisal
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- - ~>
|
73
|
+
- - "~>"
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: 0.4.0
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- - ~>
|
80
|
+
- - "~>"
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: 0.4.0
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
84
|
+
name: factory_girl
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- - ~>
|
87
|
+
- - "~>"
|
100
88
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
89
|
+
version: '2.0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- - ~>
|
94
|
+
- - "~>"
|
108
95
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
96
|
+
version: '2.0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
|
-
name:
|
98
|
+
name: i18n
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - "~>"
|
116
102
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
103
|
+
version: 0.6.4
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - "~>"
|
124
109
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
110
|
+
version: 0.6.4
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
112
|
+
name: rspec
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
|
-
- -
|
115
|
+
- - ">="
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: '0'
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
|
-
- -
|
122
|
+
- - ">="
|
140
123
|
- !ruby/object:Gem::Version
|
141
124
|
version: '0'
|
142
125
|
- !ruby/object:Gem::Dependency
|
143
126
|
name: sinatra
|
144
127
|
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
128
|
requirements:
|
147
|
-
- -
|
129
|
+
- - "~>"
|
148
130
|
- !ruby/object:Gem::Version
|
149
|
-
version: 1.3
|
131
|
+
version: '1.3'
|
150
132
|
type: :development
|
151
133
|
prerelease: false
|
152
134
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
135
|
requirements:
|
155
|
-
- -
|
136
|
+
- - "~>"
|
156
137
|
- !ruby/object:Gem::Version
|
157
|
-
version: 1.3
|
138
|
+
version: '1.3'
|
158
139
|
- !ruby/object:Gem::Dependency
|
159
|
-
name:
|
140
|
+
name: sqlite3
|
160
141
|
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
142
|
requirements:
|
163
|
-
- -
|
143
|
+
- - ">="
|
164
144
|
- !ruby/object:Gem::Version
|
165
145
|
version: '0'
|
166
146
|
type: :development
|
167
147
|
prerelease: false
|
168
148
|
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
149
|
requirements:
|
171
|
-
- -
|
150
|
+
- - ">="
|
172
151
|
- !ruby/object:Gem::Version
|
173
152
|
version: '0'
|
174
153
|
- !ruby/object:Gem::Dependency
|
175
|
-
name:
|
154
|
+
name: thin
|
176
155
|
requirement: !ruby/object:Gem::Requirement
|
177
|
-
none: false
|
178
156
|
requirements:
|
179
|
-
- -
|
157
|
+
- - ">="
|
180
158
|
- !ruby/object:Gem::Version
|
181
|
-
version: '
|
159
|
+
version: '0'
|
182
160
|
type: :development
|
183
161
|
prerelease: false
|
184
162
|
version_requirements: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
163
|
requirements:
|
187
|
-
- -
|
164
|
+
- - ">="
|
188
165
|
- !ruby/object:Gem::Version
|
189
|
-
version: '
|
166
|
+
version: '0'
|
190
167
|
description:
|
191
168
|
email: james@songkick.com
|
192
169
|
executables: []
|
@@ -196,77 +173,78 @@ extra_rdoc_files:
|
|
196
173
|
files:
|
197
174
|
- History.txt
|
198
175
|
- README.rdoc
|
176
|
+
- example/README.rdoc
|
177
|
+
- example/application.rb
|
178
|
+
- example/config.ru
|
179
|
+
- example/environment.rb
|
180
|
+
- example/models/connection.rb
|
181
|
+
- example/models/note.rb
|
182
|
+
- example/models/user.rb
|
199
183
|
- example/public/style.css
|
200
|
-
- example/
|
201
|
-
- example/views/
|
202
|
-
- example/views/new_user.erb
|
203
|
-
- example/views/layout.erb
|
184
|
+
- example/schema.rb
|
185
|
+
- example/views/authorize.erb
|
204
186
|
- example/views/create_user.erb
|
205
187
|
- example/views/error.erb
|
206
|
-
- example/views/
|
188
|
+
- example/views/home.erb
|
189
|
+
- example/views/layout.erb
|
190
|
+
- example/views/login.erb
|
207
191
|
- example/views/new_client.erb
|
192
|
+
- example/views/new_user.erb
|
208
193
|
- example/views/show_client.erb
|
209
|
-
-
|
210
|
-
- example/models/connection.rb
|
211
|
-
- example/models/user.rb
|
212
|
-
- example/schema.rb
|
213
|
-
- example/environment.rb
|
214
|
-
- example/application.rb
|
215
|
-
- example/README.rdoc
|
216
|
-
- example/config.ru
|
194
|
+
- lib/songkick/oauth2/model.rb
|
217
195
|
- lib/songkick/oauth2/model/authorization.rb
|
196
|
+
- lib/songkick/oauth2/model/client.rb
|
218
197
|
- lib/songkick/oauth2/model/client_owner.rb
|
219
|
-
- lib/songkick/oauth2/model/resource_owner.rb
|
220
198
|
- lib/songkick/oauth2/model/hashing.rb
|
221
|
-
- lib/songkick/oauth2/model/
|
199
|
+
- lib/songkick/oauth2/model/helpers.rb
|
200
|
+
- lib/songkick/oauth2/model/resource_owner.rb
|
222
201
|
- lib/songkick/oauth2/provider.rb
|
202
|
+
- lib/songkick/oauth2/provider/access_token.rb
|
223
203
|
- lib/songkick/oauth2/provider/authorization.rb
|
224
|
-
- lib/songkick/oauth2/provider/exchange.rb
|
225
204
|
- lib/songkick/oauth2/provider/error.rb
|
226
|
-
- lib/songkick/oauth2/provider/
|
205
|
+
- lib/songkick/oauth2/provider/exchange.rb
|
206
|
+
- lib/songkick/oauth2/router.rb
|
227
207
|
- lib/songkick/oauth2/schema.rb
|
228
|
-
- lib/songkick/oauth2/schema/20121024180930_songkick_oauth2_schema_add_authorization_index.rb
|
229
208
|
- lib/songkick/oauth2/schema/20120828112156_songkick_oauth2_schema_original_schema.rb
|
209
|
+
- lib/songkick/oauth2/schema/20121024180930_songkick_oauth2_schema_add_authorization_index.rb
|
230
210
|
- lib/songkick/oauth2/schema/20121025180447_songkick_oauth2_schema_add_unique_indexes.rb
|
231
|
-
- lib/songkick/oauth2/router.rb
|
232
|
-
- lib/songkick/oauth2/model.rb
|
233
|
-
- spec/test_app/provider/views/authorize.erb
|
234
211
|
- spec/factories.rb
|
235
212
|
- spec/request_helpers.rb
|
236
|
-
- spec/test_app/helper.rb
|
237
|
-
- spec/test_app/provider/application.rb
|
238
213
|
- spec/songkick/oauth2/model/authorization_spec.rb
|
239
214
|
- spec/songkick/oauth2/model/client_spec.rb
|
215
|
+
- spec/songkick/oauth2/model/helpers_spec.rb
|
240
216
|
- spec/songkick/oauth2/model/resource_owner_spec.rb
|
241
|
-
- spec/songkick/oauth2/provider/exchange_spec.rb
|
242
|
-
- spec/songkick/oauth2/provider/authorization_spec.rb
|
243
217
|
- spec/songkick/oauth2/provider/access_token_spec.rb
|
218
|
+
- spec/songkick/oauth2/provider/authorization_spec.rb
|
219
|
+
- spec/songkick/oauth2/provider/exchange_spec.rb
|
244
220
|
- spec/songkick/oauth2/provider_spec.rb
|
245
221
|
- spec/spec_helper.rb
|
222
|
+
- spec/test_app/helper.rb
|
223
|
+
- spec/test_app/provider/application.rb
|
224
|
+
- spec/test_app/provider/views/authorize.erb
|
246
225
|
homepage: http://github.com/songkick/oauth2-provider
|
247
226
|
licenses: []
|
227
|
+
metadata: {}
|
248
228
|
post_install_message:
|
249
229
|
rdoc_options:
|
250
|
-
- --main
|
230
|
+
- "--main"
|
251
231
|
- README.rdoc
|
252
232
|
require_paths:
|
253
233
|
- lib
|
254
234
|
required_ruby_version: !ruby/object:Gem::Requirement
|
255
|
-
none: false
|
256
235
|
requirements:
|
257
|
-
- -
|
236
|
+
- - ">="
|
258
237
|
- !ruby/object:Gem::Version
|
259
238
|
version: '0'
|
260
239
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
261
|
-
none: false
|
262
240
|
requirements:
|
263
|
-
- -
|
241
|
+
- - ">="
|
264
242
|
- !ruby/object:Gem::Version
|
265
243
|
version: '0'
|
266
244
|
requirements: []
|
267
245
|
rubyforge_project:
|
268
|
-
rubygems_version:
|
246
|
+
rubygems_version: 2.5.1
|
269
247
|
signing_key:
|
270
|
-
specification_version:
|
248
|
+
specification_version: 4
|
271
249
|
summary: Simple OAuth 2.0 provider toolkit
|
272
250
|
test_files: []
|