doorkeeper 2.2.0 → 2.2.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.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +23 -13
- data/NEWS.md +8 -0
- data/RELEASING.md +3 -1
- data/doorkeeper.gemspec +4 -4
- data/lib/doorkeeper/config.rb +13 -29
- data/lib/doorkeeper/engine.rb +1 -1
- data/lib/doorkeeper/models/access_grant_mixin.rb +1 -1
- data/lib/doorkeeper/models/access_token_mixin.rb +5 -3
- data/lib/doorkeeper/models/application_mixin.rb +2 -2
- data/lib/doorkeeper/oauth/authorization/token.rb +15 -6
- data/lib/doorkeeper/oauth/client.rb +9 -8
- data/lib/doorkeeper/oauth/refresh_token_request.rb +10 -5
- data/lib/doorkeeper/orm/active_record.rb +21 -0
- data/lib/doorkeeper/orm/mongo_mapper.rb +8 -0
- data/lib/doorkeeper/orm/mongo_mapper/application.rb +4 -1
- data/lib/doorkeeper/orm/mongoid2.rb +8 -0
- data/lib/doorkeeper/orm/mongoid3.rb +8 -0
- data/lib/doorkeeper/orm/mongoid4.rb +8 -0
- data/lib/doorkeeper/version.rb +1 -1
- data/spec/controllers/protected_resources_controller_spec.rb +1 -1
- data/spec/lib/config_spec.rb +2 -2
- data/spec/lib/oauth/refresh_token_request_spec.rb +26 -5
- data/spec/models/doorkeeper/access_token_spec.rb +50 -1
- metadata +127 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: deaa5b8594c905718666747b34f68ce23d2ee707
|
4
|
+
data.tar.gz: c6a694f036f968c415ab2ecf9345a91e99273abb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 550da7f4937a9ae9786072d0c23c7fd07347336da752232f03a28200c9edb0793e58763c29efc74b9ea52fd4e2278b926f323c1cd5e5356c8090e8dd24123859
|
7
|
+
data.tar.gz: 13fa74a7326c592fe6f2a2a60ab81318ca923fcc3f6e7a79111ca1ffd718dc27ff76cd2483e38676d28f37443d495573746aca18ce5ae00cf78e064355b16fa2
|
data/CONTRIBUTING.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Contributing
|
2
2
|
|
3
|
-
We love pull requests.
|
3
|
+
We love pull requests from everyone. By participating in this project, you agree
|
4
|
+
to abide by the thoughtbot [code of conduct].
|
5
|
+
|
6
|
+
[code of conduct]: https://thoughtbot.com/open-source-code-of-conduct
|
4
7
|
|
5
8
|
Fork, then clone the repo:
|
6
9
|
|
@@ -14,22 +17,29 @@ Make sure the tests pass:
|
|
14
17
|
|
15
18
|
rake
|
16
19
|
|
17
|
-
Make your change.
|
20
|
+
Make your change.
|
21
|
+
Write tests.
|
22
|
+
Follow our [style guide][style].
|
23
|
+
Make the tests pass:
|
24
|
+
|
25
|
+
[style]: https://github.com/thoughtbot/guides/tree/master/style
|
18
26
|
|
19
27
|
rake
|
20
28
|
|
21
|
-
|
29
|
+
Write a [good commit message][commit].
|
30
|
+
Push to your fork.
|
31
|
+
[Submit a pull request][pr].
|
22
32
|
|
23
|
-
|
24
|
-
|
25
|
-
some changes or improvements or alternatives.
|
33
|
+
[commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
34
|
+
[pr]: https://github.com/doorkeeper-gem/doorkeeper/compare/
|
26
35
|
|
27
|
-
|
36
|
+
If [Hound] catches style violations,
|
37
|
+
fix them.
|
28
38
|
|
29
|
-
|
30
|
-
* Follow our [style guide][style]. Address Hound CI comments unless you have a
|
31
|
-
good reason not to.
|
32
|
-
* Write a [good commit message][commit].
|
39
|
+
[hound]: https://houndci.com
|
33
40
|
|
34
|
-
|
35
|
-
|
41
|
+
Wait for us.
|
42
|
+
We try to at least comment on pull requests within one business day.
|
43
|
+
We may suggest changes.
|
44
|
+
|
45
|
+
Thank you for your contribution!
|
data/NEWS.md
CHANGED
@@ -4,6 +4,14 @@ User-visible changes worth mentioning.
|
|
4
4
|
|
5
5
|
---
|
6
6
|
|
7
|
+
## 2.2.1
|
8
|
+
|
9
|
+
- [#636] `custom_access_token_expires_in` bugfixes
|
10
|
+
- [#641] syntax error fix (Issue #612)
|
11
|
+
- [#633] Send extra details to Custom Token Generator
|
12
|
+
- [#628] Refactor: improve orm adapters to ease extension
|
13
|
+
- [#637] Upgrade to rspec to 3.2
|
14
|
+
|
7
15
|
## 2.2.0 - 2015-04-19
|
8
16
|
|
9
17
|
- [#611] Allow custom access token generators to be used
|
data/RELEASING.md
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
# Releasing doorkeeper
|
2
2
|
|
3
3
|
1. Update `lib/doorkeeper/version.rb` file accordingly.
|
4
|
-
2. Update `
|
4
|
+
2. Update `NEWS.md` to reflect the changes since last release.
|
5
5
|
3. Commit changes. There shouldn’t be code changes, and thus CI doesn’t need to
|
6
6
|
run, you can then add “[ci skip]” to the commit message.
|
7
7
|
4. Tag the release: `git tag vVERSION`
|
8
8
|
5. Push changes: `git push --tags`
|
9
9
|
6. Build and publish the gem:
|
10
|
+
|
10
11
|
```bash
|
11
12
|
gem build doorkeeper.gemspec
|
12
13
|
gem push doorkeeper-*.gem
|
13
14
|
```
|
15
|
+
|
14
16
|
7. Announce the new release, making sure to say “thank you” to the contributors
|
15
17
|
who helped shape this version!
|
data/doorkeeper.gemspec
CHANGED
@@ -8,18 +8,18 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["Felipe Elias Philipp", "Tute Costa"]
|
9
9
|
s.email = %w(tutecosta@gmail.com)
|
10
10
|
s.homepage = "https://github.com/doorkeeper-gem/doorkeeper"
|
11
|
-
s.summary = "
|
12
|
-
s.description = "Doorkeeper is an OAuth 2 provider for Rails."
|
11
|
+
s.summary = "OAuth 2 provider for Rails and Grape"
|
12
|
+
s.description = "Doorkeeper is an OAuth 2 provider for Rails and Grape."
|
13
13
|
s.license = 'MIT'
|
14
14
|
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
|
-
s.test_files = `git ls-files --
|
16
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
19
|
s.add_dependency "railties", ">= 3.2"
|
20
20
|
|
21
21
|
s.add_development_dependency "sqlite3", "~> 1.3.5"
|
22
|
-
s.add_development_dependency "rspec-rails", "~> 3.
|
22
|
+
s.add_development_dependency "rspec-rails", "~> 3.2.0"
|
23
23
|
s.add_development_dependency "capybara", "~> 2.3.0"
|
24
24
|
s.add_development_dependency "generator_spec", "~> 0.9.0"
|
25
25
|
s.add_development_dependency "factory_girl", "~> 4.5.0"
|
data/lib/doorkeeper/config.rb
CHANGED
@@ -7,54 +7,38 @@ module Doorkeeper
|
|
7
7
|
|
8
8
|
def self.configure(&block)
|
9
9
|
@config = Config::Builder.new(&block).build
|
10
|
-
|
11
|
-
|
10
|
+
setup_orm_adapter
|
11
|
+
setup_orm_models
|
12
12
|
setup_application_owner if @config.enable_application_owner?
|
13
|
+
check_requirements
|
13
14
|
end
|
14
15
|
|
15
16
|
def self.configuration
|
16
17
|
@config || (fail MissingConfiguration.new)
|
17
18
|
end
|
18
19
|
|
19
|
-
def self.
|
20
|
-
|
21
|
-
ActiveRecord::Base.connected? &&
|
22
|
-
ActiveRecord::Base.connection.table_exists?(
|
23
|
-
Doorkeeper::Application.table_name
|
24
|
-
) &&
|
25
|
-
!Doorkeeper::Application.new.attributes.include?("scopes")
|
26
|
-
|
27
|
-
puts <<-MSG.squish
|
28
|
-
[doorkeeper] Missing column: `oauth_applications.scopes`.
|
29
|
-
If you are using ActiveRecord run `rails generate doorkeeper:application_scopes
|
30
|
-
&& rake db:migrate` to add it.
|
31
|
-
MSG
|
32
|
-
end
|
20
|
+
def self.check_requirements
|
21
|
+
@orm_adapter.check_requirements!(configuration)
|
33
22
|
end
|
34
23
|
|
35
|
-
def self.
|
36
|
-
|
37
|
-
class_name.constantize.initialize_models!
|
24
|
+
def self.setup_orm_adapter
|
25
|
+
@orm_adapter = "doorkeeper/orm/#{configuration.orm}".classify.constantize
|
38
26
|
rescue NameError => e
|
39
|
-
|
40
|
-
fail e, "ORM adapter not found (#{configuration.orm})", <<-error_msg
|
27
|
+
fail e, "ORM adapter not found (#{configuration.orm})", <<-ERROR_MSG.squish
|
41
28
|
[doorkeeper] ORM adapter not found (#{configuration.orm}), or there was an error
|
42
29
|
trying to load it.
|
43
30
|
|
44
31
|
You probably need to add the related gem for this adapter to work with
|
45
32
|
doorkeeper.
|
33
|
+
ERROR_MSG
|
34
|
+
end
|
46
35
|
|
47
|
-
|
48
|
-
|
49
|
-
error_msg
|
50
|
-
else
|
51
|
-
raise e
|
52
|
-
end
|
36
|
+
def self.setup_orm_models
|
37
|
+
@orm_adapter.initialize_models!
|
53
38
|
end
|
54
39
|
|
55
40
|
def self.setup_application_owner
|
56
|
-
|
57
|
-
Application.send :include, Models::Ownership
|
41
|
+
@orm_adapter.initialize_application_owner!
|
58
42
|
end
|
59
43
|
|
60
44
|
class Config
|
data/lib/doorkeeper/engine.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Doorkeeper
|
2
2
|
class Engine < Rails::Engine
|
3
3
|
initializer "doorkeeper.params.filter" do |app|
|
4
|
-
app.config.filter_parameters +=
|
4
|
+
app.config.filter_parameters += [:client_secret, :code, :token]
|
5
5
|
end
|
6
6
|
|
7
7
|
initializer "doorkeeper.locales" do |app|
|
@@ -31,11 +31,11 @@ module Doorkeeper
|
|
31
31
|
|
32
32
|
module ClassMethods
|
33
33
|
def by_token(token)
|
34
|
-
where(token: token).limit(1).to_a.first
|
34
|
+
where(token: token.to_s).limit(1).to_a.first
|
35
35
|
end
|
36
36
|
|
37
37
|
def by_refresh_token(refresh_token)
|
38
|
-
where(refresh_token: refresh_token).first
|
38
|
+
where(refresh_token: refresh_token.to_s).first
|
39
39
|
end
|
40
40
|
|
41
41
|
def revoke_all_for(application_id, resource_owner)
|
@@ -129,7 +129,9 @@ module Doorkeeper
|
|
129
129
|
|
130
130
|
def generate_token
|
131
131
|
generator = Doorkeeper.configuration.access_token_generator.constantize
|
132
|
-
self.token = generator.generate(resource_owner_id: resource_owner_id
|
132
|
+
self.token = generator.generate(resource_owner_id: resource_owner_id,
|
133
|
+
scopes: scopes, application: application,
|
134
|
+
expires_in: expires_in)
|
133
135
|
rescue NoMethodError
|
134
136
|
raise Errors::UnableToGenerateToken, "#{generator} does not respond to `.generate`."
|
135
137
|
rescue NameError
|
@@ -22,11 +22,11 @@ module Doorkeeper
|
|
22
22
|
|
23
23
|
module ClassMethods
|
24
24
|
def by_uid_and_secret(uid, secret)
|
25
|
-
where(uid: uid, secret: secret).limit(1).to_a.first
|
25
|
+
where(uid: uid.to_s, secret: secret.to_s).limit(1).to_a.first
|
26
26
|
end
|
27
27
|
|
28
28
|
def by_uid(uid)
|
29
|
-
where(uid: uid).limit(1).to_a.first
|
29
|
+
where(uid: uid.to_s).limit(1).to_a.first
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -9,12 +9,9 @@ module Doorkeeper
|
|
9
9
|
@resource_owner = resource_owner
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.access_token_expires_in(server,
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
if custom_expiration
|
17
|
-
custom_expiration
|
12
|
+
def self.access_token_expires_in(server, pre_auth_or_oauth_client)
|
13
|
+
if expiration = custom_expiration(server, pre_auth_or_oauth_client)
|
14
|
+
expiration
|
18
15
|
else
|
19
16
|
server.access_token_expires_in
|
20
17
|
end
|
@@ -38,6 +35,18 @@ module Doorkeeper
|
|
38
35
|
}
|
39
36
|
end
|
40
37
|
|
38
|
+
private
|
39
|
+
|
40
|
+
def self.custom_expiration(server, pre_auth_or_oauth_client)
|
41
|
+
oauth_client = if pre_auth_or_oauth_client.respond_to?(:client)
|
42
|
+
pre_auth_or_oauth_client.client
|
43
|
+
else
|
44
|
+
pre_auth_or_oauth_client
|
45
|
+
end
|
46
|
+
|
47
|
+
server.custom_access_token_expires_in.call(oauth_client)
|
48
|
+
end
|
49
|
+
|
41
50
|
def configuration
|
42
51
|
Doorkeeper.configuration
|
43
52
|
end
|
@@ -4,6 +4,14 @@ require 'doorkeeper/oauth/client/credentials'
|
|
4
4
|
module Doorkeeper
|
5
5
|
module OAuth
|
6
6
|
class Client
|
7
|
+
attr_accessor :application
|
8
|
+
|
9
|
+
delegate :id, :name, :uid, :redirect_uri, :scopes, to: :@application
|
10
|
+
|
11
|
+
def initialize(application)
|
12
|
+
@application = application
|
13
|
+
end
|
14
|
+
|
7
15
|
def self.find(uid, method = Application.method(:by_uid))
|
8
16
|
if application = method.call(uid)
|
9
17
|
new(application)
|
@@ -12,18 +20,11 @@ module Doorkeeper
|
|
12
20
|
|
13
21
|
def self.authenticate(credentials, method = Application.method(:by_uid_and_secret))
|
14
22
|
return false if credentials.blank?
|
23
|
+
|
15
24
|
if application = method.call(credentials.uid, credentials.secret)
|
16
25
|
new(application)
|
17
26
|
end
|
18
27
|
end
|
19
|
-
|
20
|
-
delegate :id, :name, :uid, :redirect_uri, :scopes, to: :@application
|
21
|
-
|
22
|
-
def initialize(application)
|
23
|
-
@application = application
|
24
|
-
end
|
25
|
-
|
26
|
-
attr_accessor :application
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
@@ -11,8 +11,8 @@ module Doorkeeper
|
|
11
11
|
validate :client_match, error: :invalid_grant
|
12
12
|
validate :scope, error: :invalid_scope
|
13
13
|
|
14
|
-
attr_accessor :
|
15
|
-
|
14
|
+
attr_accessor :access_token, :client, :credentials, :refresh_token,
|
15
|
+
:server
|
16
16
|
|
17
17
|
def initialize(server, refresh_token, credentials, parameters = {})
|
18
18
|
@server = server
|
@@ -41,11 +41,16 @@ module Doorkeeper
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def create_access_token
|
44
|
+
expires_in = Authorization::Token.access_token_expires_in(
|
45
|
+
server,
|
46
|
+
client
|
47
|
+
)
|
48
|
+
|
44
49
|
@access_token = AccessToken.create!(
|
45
|
-
application_id:
|
50
|
+
application_id: refresh_token.application_id,
|
46
51
|
resource_owner_id: refresh_token.resource_owner_id,
|
47
|
-
scopes:
|
48
|
-
expires_in:
|
52
|
+
scopes: scopes.to_s,
|
53
|
+
expires_in: expires_in,
|
49
54
|
use_refresh_token: true)
|
50
55
|
end
|
51
56
|
|
@@ -12,6 +12,27 @@ module Doorkeeper
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
def self.initialize_application_owner!
|
17
|
+
require 'doorkeeper/models/concerns/ownership'
|
18
|
+
|
19
|
+
Doorkeeper::Application.send :include, Doorkeeper::Models::Ownership
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.check_requirements!(_config)
|
23
|
+
if ::ActiveRecord::Base.connected? &&
|
24
|
+
::ActiveRecord::Base.connection.table_exists?(
|
25
|
+
Doorkeeper::Application.table_name
|
26
|
+
)
|
27
|
+
unless Doorkeeper::Application.new.attributes.include?("scopes")
|
28
|
+
fail <<-MSG.squish
|
29
|
+
[doorkeeper] Missing column: `oauth_applications.scopes`.
|
30
|
+
Run `rails generate doorkeeper:application_scopes
|
31
|
+
&& rake db:migrate` to add it.
|
32
|
+
MSG
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
15
36
|
end
|
16
37
|
end
|
17
38
|
end
|
@@ -6,6 +6,14 @@ module Doorkeeper
|
|
6
6
|
require 'doorkeeper/orm/mongo_mapper/access_token'
|
7
7
|
require 'doorkeeper/orm/mongo_mapper/application'
|
8
8
|
end
|
9
|
+
|
10
|
+
def self.initialize_application_owner!
|
11
|
+
require 'doorkeeper/models/concerns/ownership'
|
12
|
+
|
13
|
+
Doorkeeper::Application.send :include, Doorkeeper::Models::Ownership
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.check_requirements!(_config); end
|
9
17
|
end
|
10
18
|
end
|
11
19
|
end
|
@@ -18,7 +18,10 @@ module Doorkeeper
|
|
18
18
|
key :scopes, String
|
19
19
|
|
20
20
|
def self.authorized_for(resource_owner)
|
21
|
-
ids = AccessToken.where(
|
21
|
+
ids = AccessToken.where(
|
22
|
+
resource_owner_id: resource_owner.id,
|
23
|
+
revoked_at: nil
|
24
|
+
).map(&:application_id)
|
22
25
|
find(ids)
|
23
26
|
end
|
24
27
|
|
@@ -6,6 +6,14 @@ module Doorkeeper
|
|
6
6
|
require 'doorkeeper/orm/mongoid2/access_token'
|
7
7
|
require 'doorkeeper/orm/mongoid2/application'
|
8
8
|
end
|
9
|
+
|
10
|
+
def self.initialize_application_owner!
|
11
|
+
require 'doorkeeper/models/concerns/ownership'
|
12
|
+
|
13
|
+
Doorkeeper::Application.send :include, Doorkeeper::Models::Ownership
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.check_requirements!(_config); end
|
9
17
|
end
|
10
18
|
end
|
11
19
|
end
|
@@ -6,6 +6,14 @@ module Doorkeeper
|
|
6
6
|
require 'doorkeeper/orm/mongoid3/access_token'
|
7
7
|
require 'doorkeeper/orm/mongoid3/application'
|
8
8
|
end
|
9
|
+
|
10
|
+
def self.initialize_application_owner!
|
11
|
+
require 'doorkeeper/models/concerns/ownership'
|
12
|
+
|
13
|
+
Doorkeeper::Application.send :include, Doorkeeper::Models::Ownership
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.check_requirements!(_config); end
|
9
17
|
end
|
10
18
|
end
|
11
19
|
end
|
@@ -6,6 +6,14 @@ module Doorkeeper
|
|
6
6
|
require 'doorkeeper/orm/mongoid4/access_token'
|
7
7
|
require 'doorkeeper/orm/mongoid4/application'
|
8
8
|
end
|
9
|
+
|
10
|
+
def self.initialize_application_owner!
|
11
|
+
require 'doorkeeper/models/concerns/ownership'
|
12
|
+
|
13
|
+
Doorkeeper::Application.send :include, Doorkeeper::Models::Ownership
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.check_requirements!(_config); end
|
9
17
|
end
|
10
18
|
end
|
11
19
|
end
|
data/lib/doorkeeper/version.rb
CHANGED
@@ -158,7 +158,7 @@ describe 'doorkeeper authorize filter' do
|
|
158
158
|
context 'defined for all actions' do
|
159
159
|
controller {}
|
160
160
|
|
161
|
-
it 'it renders a custom JSON response'
|
161
|
+
it 'it renders a custom JSON response' do
|
162
162
|
expect do
|
163
163
|
controller.class.doorkeeper_for
|
164
164
|
end.to raise_error(
|
data/spec/lib/config_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe Doorkeeper, 'configuration' do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
describe '
|
17
|
+
describe 'setup_orm_adapter' do
|
18
18
|
it 'adds specific error message to NameError exception' do
|
19
19
|
expect do
|
20
20
|
Doorkeeper.configure { orm 'hibernate' }
|
@@ -26,7 +26,7 @@ describe Doorkeeper, 'configuration' do
|
|
26
26
|
|
27
27
|
expect do
|
28
28
|
Doorkeeper.configure { orm 'hibernate' }
|
29
|
-
end.to raise_error(NoMethodError,
|
29
|
+
end.to raise_error(NoMethodError, /ORM adapter not found \(hibernate\)/)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -2,10 +2,16 @@ require 'spec_helper_integration'
|
|
2
2
|
|
3
3
|
module Doorkeeper::OAuth
|
4
4
|
describe RefreshTokenRequest do
|
5
|
-
let(:server)
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
let(:server) do
|
6
|
+
double :server,
|
7
|
+
access_token_expires_in: 2.minutes,
|
8
|
+
custom_access_token_expires_in: -> (_oauth_client) { nil }
|
9
|
+
end
|
10
|
+
let(:refresh_token) do
|
11
|
+
FactoryGirl.create(:access_token, use_refresh_token: true)
|
12
|
+
end
|
13
|
+
let(:client) { refresh_token.application }
|
14
|
+
let(:credentials) { Client::Credentials.new(client.uid, client.secret) }
|
9
15
|
|
10
16
|
subject { RefreshTokenRequest.new server, refresh_token, credentials }
|
11
17
|
|
@@ -13,6 +19,17 @@ module Doorkeeper::OAuth
|
|
13
19
|
expect do
|
14
20
|
subject.authorize
|
15
21
|
end.to change { client.access_tokens.count }.by(1)
|
22
|
+
expect(client.reload.access_tokens.last.expires_in).to eq(120)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'issues a new token for the client with custom expires_in' do
|
26
|
+
server = double :server,
|
27
|
+
access_token_expires_in: 2.minutes,
|
28
|
+
custom_access_token_expires_in: ->(_oauth_client) { 1234 }
|
29
|
+
|
30
|
+
RefreshTokenRequest.new(server, refresh_token, credentials).authorize
|
31
|
+
|
32
|
+
expect(client.reload.access_tokens.last.expires_in).to eq(1234)
|
16
33
|
end
|
17
34
|
|
18
35
|
it 'revokes the previous token' do
|
@@ -61,7 +78,11 @@ module Doorkeeper::OAuth
|
|
61
78
|
end
|
62
79
|
|
63
80
|
context 'with scopes' do
|
64
|
-
let
|
81
|
+
let(:refresh_token) do
|
82
|
+
FactoryGirl.create :access_token,
|
83
|
+
use_refresh_token: true,
|
84
|
+
scopes: 'public write'
|
85
|
+
end
|
65
86
|
let(:parameters) { {} }
|
66
87
|
subject { RefreshTokenRequest.new server, refresh_token, credentials, parameters }
|
67
88
|
|
@@ -33,7 +33,56 @@ module Doorkeeper
|
|
33
33
|
end
|
34
34
|
|
35
35
|
token = FactoryGirl.create :access_token
|
36
|
-
expect(token.token).to match(%r{custom_generator_token_\d})
|
36
|
+
expect(token.token).to match(%r{custom_generator_token_\d+})
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'allows the custom generator to access the application details' do
|
40
|
+
module CustomGeneratorArgs
|
41
|
+
def self.generate(opts = {})
|
42
|
+
"custom_generator_token_#{opts[:application].name}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Doorkeeper.configure do
|
47
|
+
orm DOORKEEPER_ORM
|
48
|
+
access_token_generator "Doorkeeper::CustomGeneratorArgs"
|
49
|
+
end
|
50
|
+
|
51
|
+
token = FactoryGirl.create :access_token
|
52
|
+
expect(token.token).to match(%r{custom_generator_token_Application \d+})
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'allows the custom generator to access the scopes' do
|
56
|
+
module CustomGeneratorArgs
|
57
|
+
def self.generate(opts = {})
|
58
|
+
"custom_generator_token_#{opts[:scopes].count}_#{opts[:scopes]}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
Doorkeeper.configure do
|
63
|
+
orm DOORKEEPER_ORM
|
64
|
+
access_token_generator "Doorkeeper::CustomGeneratorArgs"
|
65
|
+
end
|
66
|
+
|
67
|
+
token = FactoryGirl.create :access_token, scopes: 'public write'
|
68
|
+
|
69
|
+
expect(token.token).to eq 'custom_generator_token_2_public write'
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'allows the custom generator to access the expiry length' do
|
73
|
+
module CustomGeneratorArgs
|
74
|
+
def self.generate(opts = {})
|
75
|
+
"custom_generator_token_#{opts[:expires_in]}"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
Doorkeeper.configure do
|
80
|
+
orm DOORKEEPER_ORM
|
81
|
+
access_token_generator "Doorkeeper::CustomGeneratorArgs"
|
82
|
+
end
|
83
|
+
|
84
|
+
token = FactoryGirl.create :access_token
|
85
|
+
expect(token.token).to eq 'custom_generator_token_7200'
|
37
86
|
end
|
38
87
|
|
39
88
|
it 'raises an error if the custom object does not support generate' do
|
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: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felipe Elias Philipp
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-05-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -45,14 +45,14 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 3.
|
48
|
+
version: 3.2.0
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 3.
|
55
|
+
version: 3.2.0
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: capybara
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -165,7 +165,7 @@ dependencies:
|
|
165
165
|
- - "~>"
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: 0.10.0
|
168
|
-
description: Doorkeeper is an OAuth 2 provider for Rails.
|
168
|
+
description: Doorkeeper is an OAuth 2 provider for Rails and Grape.
|
169
169
|
email:
|
170
170
|
- tutecosta@gmail.com
|
171
171
|
executables: []
|
@@ -447,9 +447,127 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
447
447
|
version: '0'
|
448
448
|
requirements: []
|
449
449
|
rubyforge_project:
|
450
|
-
rubygems_version: 2.4.
|
450
|
+
rubygems_version: 2.4.5
|
451
451
|
signing_key:
|
452
452
|
specification_version: 4
|
453
|
-
summary:
|
454
|
-
test_files:
|
455
|
-
|
453
|
+
summary: OAuth 2 provider for Rails and Grape
|
454
|
+
test_files:
|
455
|
+
- spec/controllers/applications_controller_spec.rb
|
456
|
+
- spec/controllers/authorizations_controller_spec.rb
|
457
|
+
- spec/controllers/protected_resources_controller_spec.rb
|
458
|
+
- spec/controllers/token_info_controller_spec.rb
|
459
|
+
- spec/controllers/tokens_controller_spec.rb
|
460
|
+
- spec/dummy/Rakefile
|
461
|
+
- spec/dummy/app/controllers/application_controller.rb
|
462
|
+
- spec/dummy/app/controllers/custom_authorizations_controller.rb
|
463
|
+
- spec/dummy/app/controllers/full_protected_resources_controller.rb
|
464
|
+
- spec/dummy/app/controllers/home_controller.rb
|
465
|
+
- spec/dummy/app/controllers/metal_controller.rb
|
466
|
+
- spec/dummy/app/controllers/semi_protected_resources_controller.rb
|
467
|
+
- spec/dummy/app/helpers/application_helper.rb
|
468
|
+
- spec/dummy/app/models/user.rb
|
469
|
+
- spec/dummy/app/views/home/index.html.erb
|
470
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
471
|
+
- spec/dummy/config.ru
|
472
|
+
- spec/dummy/config/application.rb
|
473
|
+
- spec/dummy/config/boot.rb
|
474
|
+
- spec/dummy/config/database.yml
|
475
|
+
- spec/dummy/config/environment.rb
|
476
|
+
- spec/dummy/config/environments/development.rb
|
477
|
+
- spec/dummy/config/environments/production.rb
|
478
|
+
- spec/dummy/config/environments/test.rb
|
479
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
480
|
+
- spec/dummy/config/initializers/doorkeeper.rb
|
481
|
+
- spec/dummy/config/initializers/secret_token.rb
|
482
|
+
- spec/dummy/config/initializers/session_store.rb
|
483
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
484
|
+
- spec/dummy/config/locales/doorkeeper.en.yml
|
485
|
+
- spec/dummy/config/mongo.yml
|
486
|
+
- spec/dummy/config/mongoid2.yml
|
487
|
+
- spec/dummy/config/mongoid3.yml
|
488
|
+
- spec/dummy/config/mongoid4.yml
|
489
|
+
- spec/dummy/config/routes.rb
|
490
|
+
- spec/dummy/db/migrate/20111122132257_create_users.rb
|
491
|
+
- spec/dummy/db/migrate/20120312140401_add_password_to_users.rb
|
492
|
+
- spec/dummy/db/migrate/20130902165751_create_doorkeeper_tables.rb
|
493
|
+
- spec/dummy/db/migrate/20130902175349_add_owner_to_application.rb
|
494
|
+
- spec/dummy/db/migrate/20141209001746_add_scopes_to_oauth_applications.rb
|
495
|
+
- spec/dummy/db/schema.rb
|
496
|
+
- spec/dummy/public/404.html
|
497
|
+
- spec/dummy/public/422.html
|
498
|
+
- spec/dummy/public/500.html
|
499
|
+
- spec/dummy/public/favicon.ico
|
500
|
+
- spec/dummy/script/rails
|
501
|
+
- spec/factories.rb
|
502
|
+
- spec/generators/application_owner_generator_spec.rb
|
503
|
+
- spec/generators/install_generator_spec.rb
|
504
|
+
- spec/generators/migration_generator_spec.rb
|
505
|
+
- spec/generators/templates/routes.rb
|
506
|
+
- spec/generators/views_generator_spec.rb
|
507
|
+
- spec/lib/config_spec.rb
|
508
|
+
- spec/lib/doorkeeper_spec.rb
|
509
|
+
- spec/lib/models/expirable_spec.rb
|
510
|
+
- spec/lib/models/revocable_spec.rb
|
511
|
+
- spec/lib/models/scopes_spec.rb
|
512
|
+
- spec/lib/oauth/authorization/uri_builder_spec.rb
|
513
|
+
- spec/lib/oauth/authorization_code_request_spec.rb
|
514
|
+
- spec/lib/oauth/client/credentials_spec.rb
|
515
|
+
- spec/lib/oauth/client/methods_spec.rb
|
516
|
+
- spec/lib/oauth/client_credentials/creator_spec.rb
|
517
|
+
- spec/lib/oauth/client_credentials/issuer_spec.rb
|
518
|
+
- spec/lib/oauth/client_credentials/validation_spec.rb
|
519
|
+
- spec/lib/oauth/client_credentials_integration_spec.rb
|
520
|
+
- spec/lib/oauth/client_credentials_request_spec.rb
|
521
|
+
- spec/lib/oauth/client_spec.rb
|
522
|
+
- spec/lib/oauth/code_request_spec.rb
|
523
|
+
- spec/lib/oauth/error_response_spec.rb
|
524
|
+
- spec/lib/oauth/error_spec.rb
|
525
|
+
- spec/lib/oauth/forbidden_token_response_spec.rb
|
526
|
+
- spec/lib/oauth/helpers/scope_checker_spec.rb
|
527
|
+
- spec/lib/oauth/helpers/unique_token_spec.rb
|
528
|
+
- spec/lib/oauth/helpers/uri_checker_spec.rb
|
529
|
+
- spec/lib/oauth/invalid_token_response_spec.rb
|
530
|
+
- spec/lib/oauth/password_access_token_request_spec.rb
|
531
|
+
- spec/lib/oauth/pre_authorization_spec.rb
|
532
|
+
- spec/lib/oauth/refresh_token_request_spec.rb
|
533
|
+
- spec/lib/oauth/scopes_spec.rb
|
534
|
+
- spec/lib/oauth/token_request_spec.rb
|
535
|
+
- spec/lib/oauth/token_response_spec.rb
|
536
|
+
- spec/lib/oauth/token_spec.rb
|
537
|
+
- spec/lib/server_spec.rb
|
538
|
+
- spec/models/doorkeeper/access_grant_spec.rb
|
539
|
+
- spec/models/doorkeeper/access_token_spec.rb
|
540
|
+
- spec/models/doorkeeper/application_spec.rb
|
541
|
+
- spec/requests/applications/applications_request_spec.rb
|
542
|
+
- spec/requests/applications/authorized_applications_spec.rb
|
543
|
+
- spec/requests/endpoints/authorization_spec.rb
|
544
|
+
- spec/requests/endpoints/token_spec.rb
|
545
|
+
- spec/requests/flows/authorization_code_errors_spec.rb
|
546
|
+
- spec/requests/flows/authorization_code_spec.rb
|
547
|
+
- spec/requests/flows/client_credentials_spec.rb
|
548
|
+
- spec/requests/flows/implicit_grant_errors_spec.rb
|
549
|
+
- spec/requests/flows/implicit_grant_spec.rb
|
550
|
+
- spec/requests/flows/password_spec.rb
|
551
|
+
- spec/requests/flows/refresh_token_spec.rb
|
552
|
+
- spec/requests/flows/revoke_token_spec.rb
|
553
|
+
- spec/requests/flows/skip_authorization_spec.rb
|
554
|
+
- spec/requests/protected_resources/metal_spec.rb
|
555
|
+
- spec/requests/protected_resources/private_api_spec.rb
|
556
|
+
- spec/routing/custom_controller_routes_spec.rb
|
557
|
+
- spec/routing/default_routes_spec.rb
|
558
|
+
- spec/routing/scoped_routes_spec.rb
|
559
|
+
- spec/spec_helper.rb
|
560
|
+
- spec/spec_helper_integration.rb
|
561
|
+
- spec/support/dependencies/factory_girl.rb
|
562
|
+
- spec/support/helpers/access_token_request_helper.rb
|
563
|
+
- spec/support/helpers/authorization_request_helper.rb
|
564
|
+
- spec/support/helpers/config_helper.rb
|
565
|
+
- spec/support/helpers/model_helper.rb
|
566
|
+
- spec/support/helpers/request_spec_helper.rb
|
567
|
+
- spec/support/helpers/url_helper.rb
|
568
|
+
- spec/support/orm/active_record.rb
|
569
|
+
- spec/support/orm/mongo_mapper.rb
|
570
|
+
- spec/support/orm/mongoid.rb
|
571
|
+
- spec/support/shared/controllers_shared_context.rb
|
572
|
+
- spec/support/shared/models_shared_examples.rb
|
573
|
+
- spec/validators/redirect_uri_validator_spec.rb
|