devise_oauth 2.0.3 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +11 -2
- data/Gemfile.lock +89 -95
- data/app/helpers/devise/oauth/helpers.rb +1 -1
- data/app/models/devise/oauth/access_token.rb +1 -3
- data/app/models/devise/oauth/authorization.rb +0 -3
- data/app/models/devise/oauth/client.rb +4 -4
- data/devise_oauth.gemspec +1 -1
- data/lib/devise/oauth/blockable.rb +2 -2
- data/lib/devise/oauth/version.rb +1 -1
- data/spec/controllers/access_tokens_controller_spec.rb +20 -20
- data/spec/controllers/authorizations_controller_spec.rb +5 -5
- data/spec/controllers/protected_resources_controller_spec.rb +9 -9
- data/spec/dummy/app/models/user.rb +1 -1
- data/spec/dummy/config/application.rb +11 -13
- data/spec/dummy/config/environments/development.rb +0 -3
- data/spec/dummy/config/environments/test.rb +0 -6
- data/spec/dummy/config/initializers/devise.rb +2 -0
- data/spec/dummy/config/initializers/secret_token.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1e86574db1909861569cfdc7097b30882e9f78a
|
4
|
+
data.tar.gz: 0d109ef93ffba3d2b48dc56db29eaae48a4a3b6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b03082e883b382f9276f333d8e0fc8d4e309982ebdfe28ace95edb1cb556ecf1863d0e1e92bad359225b72bfc31d6bcf0d8b733ca1899d711fddc4724383e44d
|
7
|
+
data.tar.gz: c87adde666a1ddb29643eaabf9819ebd46584b41613d6976a43a6f91e966c16bd436e75333931a1988de8a99d19ec1c0b99460b5386037ebaba6de4e2f8a4be7
|
data/Gemfile
CHANGED
@@ -6,12 +6,21 @@ source 'http://rubygems.org'
|
|
6
6
|
gemspec
|
7
7
|
|
8
8
|
# jquery-rails is used by the dummy application
|
9
|
+
|
9
10
|
gem 'jquery-rails'
|
10
11
|
gem 'devise'
|
11
12
|
|
12
13
|
gem 'database_cleaner'
|
13
14
|
gem 'factory_girl_rails'
|
14
|
-
|
15
|
-
|
15
|
+
|
16
|
+
# group :test do
|
17
|
+
gem "shoulda-matchers"
|
18
|
+
# end
|
19
|
+
|
20
|
+
# `rspec-rails` needs to be in the development group so that Rails generators work.
|
21
|
+
# group :development, :test do
|
22
|
+
gem "rspec-rails", "~> 2.12"
|
23
|
+
# end
|
24
|
+
|
16
25
|
|
17
26
|
gem 'cancan'
|
data/Gemfile.lock
CHANGED
@@ -1,124 +1,118 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
devise_oauth (
|
4
|
+
devise_oauth (3.0.0)
|
5
5
|
devise (>= 2.1)
|
6
|
-
rails (>= 3.
|
6
|
+
rails (>= 3.0.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actionmailer (
|
12
|
-
actionpack (=
|
13
|
-
mail (~> 2.
|
14
|
-
actionpack (
|
15
|
-
|
16
|
-
|
17
|
-
builder (~> 3.0.0)
|
11
|
+
actionmailer (4.0.1)
|
12
|
+
actionpack (= 4.0.1)
|
13
|
+
mail (~> 2.5.4)
|
14
|
+
actionpack (4.0.1)
|
15
|
+
activesupport (= 4.0.1)
|
16
|
+
builder (~> 3.1.0)
|
18
17
|
erubis (~> 2.7.0)
|
19
|
-
|
20
|
-
rack (~>
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
devise (2.1.0)
|
18
|
+
rack (~> 1.5.2)
|
19
|
+
rack-test (~> 0.6.2)
|
20
|
+
activemodel (4.0.1)
|
21
|
+
activesupport (= 4.0.1)
|
22
|
+
builder (~> 3.1.0)
|
23
|
+
activerecord (4.0.1)
|
24
|
+
activemodel (= 4.0.1)
|
25
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
26
|
+
activesupport (= 4.0.1)
|
27
|
+
arel (~> 4.0.0)
|
28
|
+
activerecord-deprecated_finders (1.0.3)
|
29
|
+
activesupport (4.0.1)
|
30
|
+
i18n (~> 0.6, >= 0.6.4)
|
31
|
+
minitest (~> 4.2)
|
32
|
+
multi_json (~> 1.3)
|
33
|
+
thread_safe (~> 0.1)
|
34
|
+
tzinfo (~> 0.3.37)
|
35
|
+
arel (4.0.1)
|
36
|
+
atomic (1.1.14)
|
37
|
+
bcrypt-ruby (3.1.2)
|
38
|
+
builder (3.1.4)
|
39
|
+
cancan (1.6.10)
|
40
|
+
database_cleaner (1.2.0)
|
41
|
+
devise (3.2.0)
|
44
42
|
bcrypt-ruby (~> 3.0)
|
45
|
-
orm_adapter (~> 0.
|
46
|
-
railties (
|
47
|
-
|
48
|
-
|
43
|
+
orm_adapter (~> 0.1)
|
44
|
+
railties (>= 3.2.6, < 5)
|
45
|
+
thread_safe (~> 0.1)
|
46
|
+
warden (~> 1.2.3)
|
47
|
+
diff-lcs (1.2.4)
|
49
48
|
erubis (2.7.0)
|
50
|
-
factory_girl (3.
|
49
|
+
factory_girl (4.3.0)
|
51
50
|
activesupport (>= 3.0.0)
|
52
|
-
factory_girl_rails (3.
|
53
|
-
factory_girl (~> 3.
|
51
|
+
factory_girl_rails (4.3.0)
|
52
|
+
factory_girl (~> 4.3.0)
|
54
53
|
railties (>= 3.0.0)
|
55
|
-
hike (1.2.
|
56
|
-
i18n (0.6.
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
json (1.7.3)
|
62
|
-
mail (2.4.4)
|
63
|
-
i18n (>= 0.4.0)
|
54
|
+
hike (1.2.3)
|
55
|
+
i18n (0.6.5)
|
56
|
+
jquery-rails (3.0.4)
|
57
|
+
railties (>= 3.0, < 5.0)
|
58
|
+
thor (>= 0.14, < 2.0)
|
59
|
+
mail (2.5.4)
|
64
60
|
mime-types (~> 1.16)
|
65
61
|
treetop (~> 1.4.8)
|
66
|
-
mime-types (1.
|
67
|
-
|
68
|
-
|
62
|
+
mime-types (1.25)
|
63
|
+
minitest (4.7.5)
|
64
|
+
multi_json (1.8.2)
|
65
|
+
orm_adapter (0.4.0)
|
69
66
|
polyglot (0.3.3)
|
70
|
-
rack (1.
|
71
|
-
rack-
|
72
|
-
rack (>= 0.4)
|
73
|
-
rack-ssl (1.3.2)
|
74
|
-
rack
|
75
|
-
rack-test (0.6.1)
|
67
|
+
rack (1.5.2)
|
68
|
+
rack-test (0.6.2)
|
76
69
|
rack (>= 1.0)
|
77
|
-
rails (
|
78
|
-
actionmailer (=
|
79
|
-
actionpack (=
|
80
|
-
activerecord (=
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
railties (
|
86
|
-
actionpack (=
|
87
|
-
activesupport (=
|
88
|
-
rack-ssl (~> 1.3.2)
|
70
|
+
rails (4.0.1)
|
71
|
+
actionmailer (= 4.0.1)
|
72
|
+
actionpack (= 4.0.1)
|
73
|
+
activerecord (= 4.0.1)
|
74
|
+
activesupport (= 4.0.1)
|
75
|
+
bundler (>= 1.3.0, < 2.0)
|
76
|
+
railties (= 4.0.1)
|
77
|
+
sprockets-rails (~> 2.0.0)
|
78
|
+
railties (4.0.1)
|
79
|
+
actionpack (= 4.0.1)
|
80
|
+
activesupport (= 4.0.1)
|
89
81
|
rake (>= 0.8.7)
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
rspec (2.
|
96
|
-
|
97
|
-
rspec-expectations (~> 2.10.0)
|
98
|
-
rspec-mocks (~> 2.10.0)
|
99
|
-
rspec-core (2.10.1)
|
100
|
-
rspec-expectations (2.10.0)
|
101
|
-
diff-lcs (~> 1.1.3)
|
102
|
-
rspec-mocks (2.10.1)
|
103
|
-
rspec-rails (2.10.1)
|
82
|
+
thor (>= 0.18.1, < 2.0)
|
83
|
+
rake (10.1.0)
|
84
|
+
rspec-core (2.14.7)
|
85
|
+
rspec-expectations (2.14.4)
|
86
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
87
|
+
rspec-mocks (2.14.4)
|
88
|
+
rspec-rails (2.14.0)
|
104
89
|
actionpack (>= 3.0)
|
105
90
|
activesupport (>= 3.0)
|
106
91
|
railties (>= 3.0)
|
107
|
-
rspec (~> 2.
|
108
|
-
|
92
|
+
rspec-core (~> 2.14.0)
|
93
|
+
rspec-expectations (~> 2.14.0)
|
94
|
+
rspec-mocks (~> 2.14.0)
|
95
|
+
shoulda-matchers (2.4.0)
|
109
96
|
activesupport (>= 3.0.0)
|
110
|
-
sprockets (2.
|
97
|
+
sprockets (2.10.0)
|
111
98
|
hike (~> 1.2)
|
99
|
+
multi_json (~> 1.0)
|
112
100
|
rack (~> 1.0)
|
113
101
|
tilt (~> 1.1, != 1.3.0)
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
102
|
+
sprockets-rails (2.0.1)
|
103
|
+
actionpack (>= 3.0)
|
104
|
+
activesupport (>= 3.0)
|
105
|
+
sprockets (~> 2.8)
|
106
|
+
sqlite3 (1.3.8)
|
107
|
+
thor (0.18.1)
|
108
|
+
thread_safe (0.1.3)
|
109
|
+
atomic
|
110
|
+
tilt (1.4.1)
|
111
|
+
treetop (1.4.15)
|
118
112
|
polyglot
|
119
113
|
polyglot (>= 0.3.1)
|
120
|
-
tzinfo (0.3.
|
121
|
-
warden (1.
|
114
|
+
tzinfo (0.3.38)
|
115
|
+
warden (1.2.3)
|
122
116
|
rack (>= 1.0)
|
123
117
|
|
124
118
|
PLATFORMS
|
@@ -131,6 +125,6 @@ DEPENDENCIES
|
|
131
125
|
devise_oauth!
|
132
126
|
factory_girl_rails
|
133
127
|
jquery-rails
|
134
|
-
rspec-rails (
|
128
|
+
rspec-rails (~> 2.12)
|
135
129
|
shoulda-matchers
|
136
130
|
sqlite3
|
@@ -17,7 +17,7 @@ module Devise::Oauth::Helpers
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def access_blocked?
|
20
|
-
@access = Devise::Oauth::Access.
|
20
|
+
@access = Devise::Oauth::Access.find_or_create_by(client_id: @client.id, resource_owner_id: @resource_owner.id)
|
21
21
|
blocked_token if @access.blocked?
|
22
22
|
end
|
23
23
|
|
@@ -5,8 +5,6 @@ class Devise::Oauth::AccessToken < ActiveRecord::Base
|
|
5
5
|
validates :client_id, presence: true
|
6
6
|
validates :resource_owner_id, presence: true
|
7
7
|
|
8
|
-
attr_accessible :client, :resource_owner, :scope
|
9
|
-
|
10
8
|
before_create :generate_refresh_token if Devise::Oauth.generate_refresh_token
|
11
9
|
|
12
10
|
before_create :generate_value
|
@@ -24,7 +22,7 @@ class Devise::Oauth::AccessToken < ActiveRecord::Base
|
|
24
22
|
|
25
23
|
generate_value
|
26
24
|
setup_expiration
|
27
|
-
|
25
|
+
|
28
26
|
save
|
29
27
|
token_response(Devise::Oauth.regenerate_refresh_token)
|
30
28
|
end
|
@@ -11,8 +11,6 @@ class Devise::Oauth::Authorization < ActiveRecord::Base
|
|
11
11
|
include Devise::Oauth::Scopable
|
12
12
|
include Devise::Oauth::Blockable
|
13
13
|
|
14
|
-
attr_accessible :client, :resource_owner, :scope
|
15
|
-
|
16
14
|
def expired?(at = Time.now)
|
17
15
|
self.expires_at < at
|
18
16
|
end
|
@@ -54,5 +52,4 @@ class Devise::Oauth::Authorization < ActiveRecord::Base
|
|
54
52
|
self.expires_at = Time.now + Devise::Oauth.authorization_code_expires_in
|
55
53
|
end
|
56
54
|
|
57
|
-
|
58
55
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
module Devise::Oauth
|
1
|
+
module Devise::Oauth
|
2
2
|
class Client < ActiveRecord::Base
|
3
3
|
def self.client_ownable?
|
4
4
|
Devise::Oauth.client_owner.constantize.devise_modules.include? :client_ownable
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
belongs_to :owner, class_name: Devise::Oauth.client_owner if self.client_ownable?
|
8
|
-
|
8
|
+
|
9
9
|
has_many :access_tokens, class_name: "Devise::Oauth::AccessToken", dependent: :destroy
|
10
10
|
has_many :authorizations, class_name: "Devise::Oauth::Authorization", dependent: :destroy
|
11
11
|
has_many :accesses, class_name: "Devise::Oauth::Access", dependent: :destroy
|
@@ -44,6 +44,6 @@ module Devise::Oauth
|
|
44
44
|
|
45
45
|
def generate_secret
|
46
46
|
self.secret = Devise::Oauth.friendly_token
|
47
|
-
end
|
47
|
+
end
|
48
48
|
end
|
49
49
|
end
|
data/devise_oauth.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
|
-
s.add_dependency "rails", ">= 3.
|
19
|
+
s.add_dependency "rails", ">= 3.0.0"
|
20
20
|
s.add_dependency "devise", ">= 2.1"
|
21
21
|
|
22
22
|
s.add_development_dependency "sqlite3"
|
@@ -17,11 +17,11 @@ module Devise::Oauth::Blockable
|
|
17
17
|
|
18
18
|
module ClassMethods
|
19
19
|
def block_access!(client_id, resource_owner_id)
|
20
|
-
|
20
|
+
where(client_id: client_id, resource_owner_id: resource_owner_id).update_all(blocked_at: Time.now)
|
21
21
|
end
|
22
22
|
|
23
23
|
def block_client!(client_id)
|
24
|
-
update_all(
|
24
|
+
where(client_id: client_id).update_all(blocked_at: Time.now)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/lib/devise/oauth/version.rb
CHANGED
@@ -7,7 +7,7 @@ shared_examples "client is blocked flow" do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it { should respond_with :unprocessable_entity }
|
10
|
-
it { should
|
10
|
+
it { response.content_type.should == "application/json" }
|
11
11
|
it "should have error 'invalid_request'" do
|
12
12
|
res = JSON.load(response.body)
|
13
13
|
res['error'].should == "invalid_request"
|
@@ -21,7 +21,7 @@ shared_examples "access is blocked (resource owner block a client) flow" do
|
|
21
21
|
post :create, attributes
|
22
22
|
end
|
23
23
|
it { should respond_with :unprocessable_entity }
|
24
|
-
it { should
|
24
|
+
it { response.content_type.should == "application/json" }
|
25
25
|
end
|
26
26
|
|
27
27
|
shared_examples "invalid client_id flow" do
|
@@ -31,7 +31,7 @@ shared_examples "invalid client_id flow" do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it { should respond_with :unprocessable_entity }
|
34
|
-
it { should
|
34
|
+
it { response.content_type.should == "application/json" }
|
35
35
|
|
36
36
|
it "should have error 'invalid_request'" do
|
37
37
|
res = JSON.load(response.body)
|
@@ -41,22 +41,22 @@ shared_examples "invalid client_id flow" do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
describe Devise::Oauth::AccessTokensController do
|
44
|
-
before(:each) {
|
44
|
+
before(:each) {
|
45
45
|
@routes = Devise::Oauth::Engine.routes
|
46
46
|
@user = create(:user)
|
47
47
|
@client = create(:client)
|
48
48
|
@authorization = create(:authorization, client: @client, resource_owner: @user)
|
49
|
-
@access = create(:access, client: @client, resource_owner: @user)
|
49
|
+
@access = create(:access, client: @client, resource_owner: @user)
|
50
50
|
}
|
51
51
|
|
52
52
|
let(:user) { @user }
|
53
53
|
let(:client) { @client }
|
54
54
|
let(:authorization) { @authorization }
|
55
55
|
let(:access) { @access}
|
56
|
-
|
56
|
+
|
57
57
|
context "Authorization code" do
|
58
|
-
let(:attributes) {
|
59
|
-
{
|
58
|
+
let(:attributes) {
|
59
|
+
{
|
60
60
|
grant_type: "authorization_code",
|
61
61
|
client_id: client.identifier,
|
62
62
|
client_secret: client.secret,
|
@@ -72,7 +72,7 @@ describe Devise::Oauth::AccessTokensController do
|
|
72
72
|
let (:access_token) { @access_token = Devise::Oauth::AccessToken.last }
|
73
73
|
|
74
74
|
it { should respond_with :ok }
|
75
|
-
it { should
|
75
|
+
it { response.content_type.should == "application/json" }
|
76
76
|
it "should create new access token" do
|
77
77
|
access_token.should be_present
|
78
78
|
end
|
@@ -89,7 +89,7 @@ describe Devise::Oauth::AccessTokensController do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
it { should respond_with :unprocessable_entity }
|
92
|
-
it { should
|
92
|
+
it { response.content_type.should == "application/json" }
|
93
93
|
it "should have error 'invalid_request'" do
|
94
94
|
res = JSON.load(response.body)
|
95
95
|
res['error'].should == "invalid_request"
|
@@ -104,7 +104,7 @@ describe Devise::Oauth::AccessTokensController do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
it { should respond_with :unprocessable_entity }
|
107
|
-
it { should
|
107
|
+
it { response.content_type.should == "application/json" }
|
108
108
|
|
109
109
|
it "should have error 'invalid_request'" do
|
110
110
|
res = JSON.load(response.body)
|
@@ -120,7 +120,7 @@ describe Devise::Oauth::AccessTokensController do
|
|
120
120
|
|
121
121
|
context "Password credentials" do
|
122
122
|
let(:attributes) {
|
123
|
-
{
|
123
|
+
{
|
124
124
|
grant_type: "password",
|
125
125
|
client_id: client.identifier,
|
126
126
|
client_secret: client.secret,
|
@@ -131,13 +131,13 @@ describe Devise::Oauth::AccessTokensController do
|
|
131
131
|
}
|
132
132
|
|
133
133
|
context "main flow" do
|
134
|
-
before do
|
134
|
+
before do
|
135
135
|
post :create, attributes
|
136
136
|
end
|
137
137
|
let (:access_token) { @access_token = Devise::Oauth::AccessToken.last }
|
138
138
|
|
139
139
|
it { should respond_with :ok }
|
140
|
-
it { should
|
140
|
+
it { response.content_type.should == "application/json" }
|
141
141
|
it "should create new access token" do
|
142
142
|
access_token.should be_present
|
143
143
|
end
|
@@ -154,7 +154,7 @@ describe Devise::Oauth::AccessTokensController do
|
|
154
154
|
end
|
155
155
|
## TODO: bad request? or may be unauthorized?
|
156
156
|
it { should respond_with :bad_request }
|
157
|
-
it { should
|
157
|
+
it { response.content_type.should == "application/json" }
|
158
158
|
end
|
159
159
|
|
160
160
|
it_behaves_like "client is blocked flow"
|
@@ -166,22 +166,22 @@ describe Devise::Oauth::AccessTokensController do
|
|
166
166
|
let(:token) { create(:access_token, resource_owner: user, client: client) }
|
167
167
|
|
168
168
|
let(:attributes) {
|
169
|
-
{
|
169
|
+
{
|
170
170
|
grant_type: "refresh_token",
|
171
171
|
refresh_token: token.refresh_token,
|
172
172
|
client_id: client.identifier,
|
173
|
-
client_secret: client.secret
|
173
|
+
client_secret: client.secret
|
174
174
|
}
|
175
175
|
}
|
176
176
|
|
177
177
|
context "main flow" do
|
178
|
-
before do
|
178
|
+
before do
|
179
179
|
post :create, attributes
|
180
180
|
end
|
181
181
|
let (:access_token) { @access_token = Devise::Oauth::AccessToken.last }
|
182
182
|
|
183
183
|
it { should respond_with :ok }
|
184
|
-
it { should
|
184
|
+
it { response.content_type.should == "application/json" }
|
185
185
|
it "should create new access token" do
|
186
186
|
access_token.should be_present
|
187
187
|
end
|
@@ -197,7 +197,7 @@ describe Devise::Oauth::AccessTokensController do
|
|
197
197
|
post :create, attributes
|
198
198
|
end
|
199
199
|
it { should respond_with :bad_request }
|
200
|
-
it { should
|
200
|
+
it { response.content_type.should == "application/json" }
|
201
201
|
# page.should have_content "Refresh token not found"
|
202
202
|
end
|
203
203
|
|
@@ -3,12 +3,12 @@ require 'spec_helper'
|
|
3
3
|
describe Devise::Oauth::AuthorizationsController do
|
4
4
|
render_views
|
5
5
|
|
6
|
-
before(:each) {
|
6
|
+
before(:each) {
|
7
7
|
@routes = Devise::Oauth::Engine.routes
|
8
8
|
@user = create(:user)
|
9
9
|
@client = create(:client)
|
10
10
|
@authorization = create(:authorization, client: @client, resource_owner: @user)
|
11
|
-
@access = create(:access, client: @client, resource_owner: @user)
|
11
|
+
@access = create(:access, client: @client, resource_owner: @user)
|
12
12
|
}
|
13
13
|
|
14
14
|
let(:user) { @user }
|
@@ -30,7 +30,7 @@ describe Devise::Oauth::AuthorizationsController do
|
|
30
30
|
before { get :show, attributes }
|
31
31
|
|
32
32
|
it { should respond_with :ok }
|
33
|
-
it { should
|
33
|
+
it { response.content_type.should == "text/html" }
|
34
34
|
it { should render_template 'devise/oauth/authorizations/show' }
|
35
35
|
it { should render_with_layout 'application' }
|
36
36
|
it "renders client name" do
|
@@ -40,13 +40,13 @@ describe Devise::Oauth::AuthorizationsController do
|
|
40
40
|
context "#grant" do
|
41
41
|
before { post :create, attributes }
|
42
42
|
it { should respond_with :redirect }
|
43
|
-
it { should
|
43
|
+
it { response.content_type.should == "text/html" }
|
44
44
|
end
|
45
45
|
|
46
46
|
context "#deny" do
|
47
47
|
before { delete :destroy, attributes }
|
48
48
|
it { should respond_with :redirect }
|
49
|
-
it { should
|
49
|
+
it { response.content_type.should == "text/html" }
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ProtectedResourcesController do
|
4
|
-
before(:each) {
|
4
|
+
before(:each) {
|
5
5
|
@user = create(:user)
|
6
6
|
@client = create(:client)
|
7
7
|
@authorization = create(:authorization, client: @client, resource_owner: @user)
|
@@ -14,9 +14,9 @@ describe ProtectedResourcesController do
|
|
14
14
|
let(:authorization) { @authorization }
|
15
15
|
let(:access) { @access }
|
16
16
|
let(:token) { @token }
|
17
|
-
|
17
|
+
|
18
18
|
context "Access protected resources with default scope" do
|
19
|
-
let(:attributes) {
|
19
|
+
let(:attributes) {
|
20
20
|
{ access_token: @token.value }
|
21
21
|
}
|
22
22
|
|
@@ -26,7 +26,7 @@ describe ProtectedResourcesController do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it { should respond_with :ok }
|
29
|
-
it { should
|
29
|
+
it { response.content_type.should == "application/json" }
|
30
30
|
end
|
31
31
|
|
32
32
|
context "can't write protected resources" do
|
@@ -35,7 +35,7 @@ describe ProtectedResourcesController do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it { should respond_with :forbidden }
|
38
|
-
it { should
|
38
|
+
it { response.content_type.should == "application/json" }
|
39
39
|
end
|
40
40
|
|
41
41
|
context "can't access protected resource with invalid access token" do
|
@@ -74,16 +74,16 @@ describe ProtectedResourcesController do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
it { should respond_with :ok }
|
77
|
-
it { should
|
77
|
+
it { response.content_type.should == "application/json" }
|
78
78
|
end
|
79
79
|
|
80
80
|
context "can write protected resources" do
|
81
81
|
before do
|
82
|
-
post :create, attributes
|
82
|
+
post :create, attributes
|
83
83
|
end
|
84
84
|
|
85
85
|
it { should respond_with :ok }
|
86
|
-
it { should
|
87
|
-
end
|
86
|
+
it { response.content_type.should == "application/json" }
|
87
|
+
end
|
88
88
|
end
|
89
89
|
end
|
@@ -8,6 +8,6 @@ class User < ActiveRecord::Base
|
|
8
8
|
:access_token_authenticatable, :client_ownable, :resource_ownable
|
9
9
|
|
10
10
|
# Setup accessible (or protected) attributes for your model
|
11
|
-
attr_accessible :email, :password, :password_confirmation, :remember_me
|
11
|
+
# attr_accessible :email, :password, :password_confirmation, :remember_me
|
12
12
|
# attr_accessible :title, :body
|
13
13
|
end
|
@@ -1,14 +1,19 @@
|
|
1
1
|
require File.expand_path('../boot', __FILE__)
|
2
2
|
|
3
|
+
require 'rails/all'
|
3
4
|
# Pick the frameworks you want:
|
4
|
-
require "active_record/railtie"
|
5
|
-
require "action_controller/railtie"
|
6
|
-
require "action_mailer/railtie"
|
7
|
-
require "active_resource/railtie"
|
8
|
-
require "sprockets/railtie"
|
5
|
+
# require "active_record/railtie"
|
6
|
+
# require "action_controller/railtie"
|
7
|
+
# require "action_mailer/railtie"
|
8
|
+
# require "active_resource/railtie"
|
9
|
+
# require "sprockets/railtie"
|
10
|
+
|
11
|
+
Bundler.require(*Rails.groups)
|
12
|
+
|
9
13
|
# require "rails/test_unit/railtie"
|
10
14
|
|
11
15
|
Bundler.require
|
16
|
+
|
12
17
|
require "devise_Oauth"
|
13
18
|
|
14
19
|
module Dummy
|
@@ -49,12 +54,6 @@ module Dummy
|
|
49
54
|
# like if you have constraints or database-specific column types
|
50
55
|
# config.active_record.schema_format = :sql
|
51
56
|
|
52
|
-
# Enforce whitelist mode for mass assignment.
|
53
|
-
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
54
|
-
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
55
|
-
# parameters by using an attr_accessible or attr_protected declaration.
|
56
|
-
config.active_record.whitelist_attributes = true
|
57
|
-
|
58
57
|
# Enable the asset pipeline
|
59
58
|
config.assets.enabled = true
|
60
59
|
|
@@ -63,5 +62,4 @@ module Dummy
|
|
63
62
|
|
64
63
|
Devise::Oauth.scopes = [:read, :write]
|
65
64
|
end
|
66
|
-
end
|
67
|
-
|
65
|
+
end
|
@@ -22,9 +22,6 @@ Dummy::Application.configure do
|
|
22
22
|
# Only use best-standards-support built into browsers
|
23
23
|
config.action_dispatch.best_standards_support = :builtin
|
24
24
|
|
25
|
-
# Raise exception on mass assignment protection for Active Record models
|
26
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
27
|
-
|
28
25
|
# Log the query plan for queries taking more than this (works
|
29
26
|
# with SQLite, MySQL, and PostgreSQL)
|
30
27
|
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
@@ -11,9 +11,6 @@ Dummy::Application.configure do
|
|
11
11
|
config.serve_static_assets = true
|
12
12
|
config.static_cache_control = "public, max-age=3600"
|
13
13
|
|
14
|
-
# Log error messages when you accidentally call methods on nil
|
15
|
-
config.whiny_nils = true
|
16
|
-
|
17
14
|
# Show full error reports and disable caching
|
18
15
|
config.consider_all_requests_local = true
|
19
16
|
config.action_controller.perform_caching = false
|
@@ -29,9 +26,6 @@ Dummy::Application.configure do
|
|
29
26
|
# ActionMailer::Base.deliveries array.
|
30
27
|
config.action_mailer.delivery_method = :test
|
31
28
|
|
32
|
-
# Raise exception on mass assignment protection for Active Record models
|
33
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
34
|
-
|
35
29
|
# Print deprecation notices to the stderr
|
36
30
|
config.active_support.deprecation = :stderr
|
37
31
|
end
|
@@ -15,6 +15,8 @@ Devise.setup do |config|
|
|
15
15
|
# available as additional gems.
|
16
16
|
require 'devise/orm/active_record'
|
17
17
|
|
18
|
+
config.secret_key = 'f827b3e43dd22bf713a287e4816bdf23549cd32bd3ca29fbe2e347e6b5d9acb247b86a72fcb4be1f827b1e1855bdd94b6c6c0558af8ae0185cf1bba076a4d133'
|
19
|
+
|
18
20
|
# ==> Configuration for any authentication mechanism
|
19
21
|
# Configure which keys are used when authenticating a user. The default is
|
20
22
|
# just :email. You can configure it to use [:username, :subdomain], so for
|
@@ -4,4 +4,4 @@
|
|
4
4
|
# If you change this key, all old signed cookies will become invalid!
|
5
5
|
# Make sure the secret is at least 30 characters and all random,
|
6
6
|
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
-
Dummy::Application.config.
|
7
|
+
Dummy::Application.config.secret_key_base = 'a3b9441a0e35db28706fb05e2409e3786e6cbbe3f5a1541046a4cc627ddbd30de79650ab99d9212583d8f2f494cfb88232e675020d415548aaa178fc25fe98c0'
|
data/spec/spec_helper.rb
CHANGED
@@ -3,7 +3,6 @@ require File.expand_path("../dummy/config/environment", __FILE__)
|
|
3
3
|
require 'rspec/rails'
|
4
4
|
require 'devise/test_helpers'
|
5
5
|
|
6
|
-
|
7
6
|
ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
|
8
7
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
9
8
|
# in spec/support/ and its subdirectories.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yury Korolev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.
|
19
|
+
version: 3.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.
|
26
|
+
version: 3.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: devise
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|