doorkeeper 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of doorkeeper might be problematic. Click here for more details.
- data/CHANGELOG.md +5 -0
- data/lib/doorkeeper.rb +4 -0
- data/lib/doorkeeper/doorkeeper_for.rb +0 -47
- data/lib/doorkeeper/engine.rb +6 -0
- data/lib/doorkeeper/helpers/filter.rb +52 -0
- data/lib/doorkeeper/version.rb +1 -1
- data/spec/dummy/app/controllers/metal_controller.rb +11 -0
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/requests/protected_resources/metal_spec.rb +14 -0
- metadata +25 -22
data/CHANGELOG.md
CHANGED
data/lib/doorkeeper.rb
CHANGED
@@ -71,51 +71,4 @@ module Doorkeeper
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
74
|
-
|
75
|
-
module Controller
|
76
|
-
module ClassMethods
|
77
|
-
def doorkeeper_for(*args)
|
78
|
-
doorkeeper_for = DoorkeeperForBuilder.create_doorkeeper_for(*args)
|
79
|
-
|
80
|
-
before_filter doorkeeper_for.filter_options do
|
81
|
-
return if doorkeeper_for.validate_token(doorkeeper_token)
|
82
|
-
render_options = doorkeeper_unauthorized_render_options
|
83
|
-
if render_options.nil? || render_options.empty?
|
84
|
-
head :unauthorized
|
85
|
-
else
|
86
|
-
render_options[:status] = :unauthorized
|
87
|
-
render_options[:layout] = false if render_options[:layout].nil?
|
88
|
-
render render_options
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def self.included(base)
|
95
|
-
base.extend ClassMethods
|
96
|
-
base.send(:private, :doorkeeper_token, :get_doorkeeper_token)
|
97
|
-
end
|
98
|
-
|
99
|
-
def doorkeeper_token
|
100
|
-
@token ||= get_doorkeeper_token
|
101
|
-
end
|
102
|
-
|
103
|
-
def get_doorkeeper_token
|
104
|
-
token = params[:access_token] || params[:bearer_token] || authorization_bearer_token
|
105
|
-
if token
|
106
|
-
AccessToken.find_by_token(token)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def authorization_bearer_token
|
111
|
-
header = request.env['HTTP_AUTHORIZATION']
|
112
|
-
header.gsub(/^Bearer /, '') if header && header.match(/^Bearer /)
|
113
|
-
end
|
114
|
-
|
115
|
-
def doorkeeper_unauthorized_render_options
|
116
|
-
nil
|
117
|
-
end
|
118
|
-
end
|
119
74
|
end
|
120
|
-
|
121
|
-
ActionController::Base.send(:include, Doorkeeper::Controller)
|
data/lib/doorkeeper/engine.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
module Doorkeeper
|
2
|
+
module Helpers
|
3
|
+
module Filter
|
4
|
+
module ClassMethods
|
5
|
+
def doorkeeper_for(*args)
|
6
|
+
doorkeeper_for = DoorkeeperForBuilder.create_doorkeeper_for(*args)
|
7
|
+
|
8
|
+
before_filter doorkeeper_for.filter_options do
|
9
|
+
return if doorkeeper_for.validate_token(doorkeeper_token)
|
10
|
+
render_options = doorkeeper_unauthorized_render_options
|
11
|
+
if render_options.nil? || render_options.empty?
|
12
|
+
head :unauthorized
|
13
|
+
else
|
14
|
+
render_options[:status] = :unauthorized
|
15
|
+
render_options[:layout] = false if render_options[:layout].nil?
|
16
|
+
render render_options
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.included(base)
|
23
|
+
base.extend ClassMethods
|
24
|
+
base.send :private,
|
25
|
+
:doorkeeper_token,
|
26
|
+
:get_doorkeeper_token,
|
27
|
+
:authorization_bearer_token,
|
28
|
+
:doorkeeper_unauthorized_render_options
|
29
|
+
end
|
30
|
+
|
31
|
+
def doorkeeper_token
|
32
|
+
@token ||= get_doorkeeper_token
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_doorkeeper_token
|
36
|
+
token = params[:access_token] || params[:bearer_token] || authorization_bearer_token
|
37
|
+
if token
|
38
|
+
AccessToken.find_by_token(token)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def authorization_bearer_token
|
43
|
+
header = request.env['HTTP_AUTHORIZATION']
|
44
|
+
header.gsub(/^Bearer /, '') if header && header.match(/^Bearer /)
|
45
|
+
end
|
46
|
+
|
47
|
+
def doorkeeper_unauthorized_render_options
|
48
|
+
nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/doorkeeper/version.rb
CHANGED
data/spec/dummy/config/routes.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper_integration'
|
2
|
+
|
3
|
+
feature 'ActionController::Metal API' do
|
4
|
+
background do
|
5
|
+
@client = FactoryGirl.create(:application)
|
6
|
+
@resource = User.create!(:name => "Joe", :password => "sekret")
|
7
|
+
@token = client_is_authorized(@client, @resource)
|
8
|
+
end
|
9
|
+
|
10
|
+
scenario 'client requests protected resource with valid token' do
|
11
|
+
get "/metal.json?access_token=#{@token.token}"
|
12
|
+
should_have_json 'ok', true
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doorkeeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-06-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: railties
|
17
|
-
requirement: &
|
17
|
+
requirement: &70352107713180 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '3.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70352107713180
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: sqlite3
|
28
|
-
requirement: &
|
28
|
+
requirement: &70352107712140 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 1.3.5
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70352107712140
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: rspec-rails
|
39
|
-
requirement: &
|
39
|
+
requirement: &70352107710740 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 2.10.0
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70352107710740
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: capybara
|
50
|
-
requirement: &
|
50
|
+
requirement: &70352107708060 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: 1.1.2
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70352107708060
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: generator_spec
|
61
|
-
requirement: &
|
61
|
+
requirement: &70352107706980 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ~>
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: 0.8.5
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *70352107706980
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: factory_girl
|
72
|
-
requirement: &
|
72
|
+
requirement: &70352107732340 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: 2.6.4
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *70352107732340
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: timecop
|
83
|
-
requirement: &
|
83
|
+
requirement: &70352107731020 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ~>
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: 0.3.5
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *70352107731020
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: database_cleaner
|
94
|
-
requirement: &
|
94
|
+
requirement: &70352107729580 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ~>
|
@@ -99,10 +99,10 @@ dependencies:
|
|
99
99
|
version: 0.7.1
|
100
100
|
type: :development
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *70352107729580
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: bcrypt-ruby
|
105
|
-
requirement: &
|
105
|
+
requirement: &70352107728220 !ruby/object:Gem::Requirement
|
106
106
|
none: false
|
107
107
|
requirements:
|
108
108
|
- - ~>
|
@@ -110,7 +110,7 @@ dependencies:
|
|
110
110
|
version: 3.0.1
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
|
-
version_requirements: *
|
113
|
+
version_requirements: *70352107728220
|
114
114
|
description: Doorkeeper is an OAuth 2 provider for Rails.
|
115
115
|
email:
|
116
116
|
- felipe@applicake.com
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- lib/doorkeeper/config.rb
|
159
159
|
- lib/doorkeeper/doorkeeper_for.rb
|
160
160
|
- lib/doorkeeper/engine.rb
|
161
|
+
- lib/doorkeeper/helpers/filter.rb
|
161
162
|
- lib/doorkeeper/models/expirable.rb
|
162
163
|
- lib/doorkeeper/models/revocable.rb
|
163
164
|
- lib/doorkeeper/models/scopes.rb
|
@@ -202,6 +203,7 @@ files:
|
|
202
203
|
- spec/dummy/app/controllers/application_controller.rb
|
203
204
|
- spec/dummy/app/controllers/full_protected_resources_controller.rb
|
204
205
|
- spec/dummy/app/controllers/home_controller.rb
|
206
|
+
- spec/dummy/app/controllers/metal_controller.rb
|
205
207
|
- spec/dummy/app/controllers/semi_protected_resources_controller.rb
|
206
208
|
- spec/dummy/app/helpers/application_helper.rb
|
207
209
|
- spec/dummy/app/models/user.rb
|
@@ -275,6 +277,7 @@ files:
|
|
275
277
|
- spec/requests/flows/password_spec.rb
|
276
278
|
- spec/requests/flows/refresh_token_spec.rb
|
277
279
|
- spec/requests/flows/skip_authorization_spec.rb
|
280
|
+
- spec/requests/protected_resources/metal_spec.rb
|
278
281
|
- spec/requests/protected_resources/private_api_spec.rb
|
279
282
|
- spec/spec_helper.rb
|
280
283
|
- spec/spec_helper_integration.rb
|
@@ -302,7 +305,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
302
305
|
version: '0'
|
303
306
|
segments:
|
304
307
|
- 0
|
305
|
-
hash:
|
308
|
+
hash: 2607097917564247242
|
306
309
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
307
310
|
none: false
|
308
311
|
requirements:
|
@@ -311,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
311
314
|
version: '0'
|
312
315
|
segments:
|
313
316
|
- 0
|
314
|
-
hash:
|
317
|
+
hash: 2607097917564247242
|
315
318
|
requirements: []
|
316
319
|
rubyforge_project:
|
317
320
|
rubygems_version: 1.8.12
|