doorkeeper 2.1.4 → 3.1.0
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/.hound.yml +4 -0
- data/.travis.yml +5 -24
- data/CONTRIBUTING.md +23 -13
- data/Gemfile +3 -7
- data/{CHANGELOG.md → NEWS.md} +137 -42
- data/README.md +60 -46
- data/RELEASING.md +5 -3
- data/app/assets/stylesheets/doorkeeper/admin/application.css +1 -5
- data/app/controllers/doorkeeper/applications_controller.rb +2 -2
- data/app/helpers/doorkeeper/dashboard_helper.rb +1 -1
- data/app/validators/redirect_uri_validator.rb +1 -1
- data/app/views/doorkeeper/applications/_form.html.erb +13 -2
- data/app/views/doorkeeper/applications/show.html.erb +3 -2
- data/app/views/doorkeeper/authorizations/new.html.erb +1 -1
- data/app/views/layouts/doorkeeper/admin.html.erb +5 -2
- data/config/locales/en.yml +4 -32
- data/doorkeeper.gemspec +4 -8
- data/lib/doorkeeper/config.rb +20 -29
- data/lib/doorkeeper/engine.rb +7 -1
- data/lib/doorkeeper/errors.rb +12 -0
- data/lib/doorkeeper/grape/helpers.rb +1 -1
- data/lib/doorkeeper/helpers/controller.rb +6 -0
- data/lib/doorkeeper/models/access_grant_mixin.rb +3 -2
- data/lib/doorkeeper/models/access_token_mixin.rb +12 -4
- data/lib/doorkeeper/models/application_mixin.rb +11 -18
- data/lib/doorkeeper/models/concerns/revocable.rb +2 -2
- data/lib/doorkeeper/oauth/authorization/token.rb +15 -6
- data/lib/doorkeeper/oauth/authorization_code_request.rb +10 -5
- data/lib/doorkeeper/oauth/client.rb +9 -8
- data/lib/doorkeeper/oauth/client_credentials/creator.rb +3 -4
- data/lib/doorkeeper/oauth/error.rb +5 -1
- data/lib/doorkeeper/oauth/helpers/scope_checker.rb +1 -1
- data/lib/doorkeeper/oauth/refresh_token_request.rb +17 -7
- data/lib/doorkeeper/orm/active_record/access_grant.rb +2 -2
- data/lib/doorkeeper/orm/active_record/access_token.rb +2 -2
- data/lib/doorkeeper/orm/active_record/application.rb +2 -2
- data/lib/doorkeeper/orm/active_record.rb +22 -0
- data/lib/doorkeeper/rails/helpers.rb +19 -29
- data/lib/doorkeeper/request/authorization_code.rb +10 -15
- data/lib/doorkeeper/request/client_credentials.rb +9 -15
- data/lib/doorkeeper/request/code.rb +7 -13
- data/lib/doorkeeper/request/password.rb +10 -15
- data/lib/doorkeeper/request/refresh_token.rb +11 -13
- data/lib/doorkeeper/request/strategy.rb +17 -0
- data/lib/doorkeeper/request/token.rb +7 -13
- data/lib/doorkeeper/request.rb +18 -8
- data/lib/doorkeeper/server.rb +2 -2
- data/lib/doorkeeper/version.rb +1 -1
- data/lib/doorkeeper.rb +0 -4
- data/lib/generators/doorkeeper/templates/README +0 -20
- data/lib/generators/doorkeeper/templates/initializer.rb +5 -3
- data/lib/generators/doorkeeper/templates/migration.rb +8 -0
- data/spec/controllers/applications_controller_spec.rb +0 -1
- data/spec/controllers/protected_resources_controller_spec.rb +115 -14
- data/spec/controllers/token_info_controller_spec.rb +0 -4
- data/spec/controllers/tokens_controller_spec.rb +34 -3
- data/spec/dummy/app/models/user.rb +2 -24
- data/spec/dummy/config/application.rb +2 -1
- data/spec/dummy/config/initializers/doorkeeper.rb +0 -2
- data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +24 -0
- data/spec/lib/config_spec.rb +20 -4
- data/spec/lib/models/revocable_spec.rb +2 -2
- data/spec/lib/oauth/authorization_code_request_spec.rb +1 -1
- data/spec/lib/oauth/client/credentials_spec.rb +2 -2
- data/spec/lib/oauth/client_credentials/creator_spec.rb +25 -1
- data/spec/lib/oauth/error_response_spec.rb +7 -7
- data/spec/lib/oauth/error_spec.rb +9 -5
- data/spec/lib/oauth/helpers/scope_checker_spec.rb +3 -3
- data/spec/lib/oauth/password_access_token_request_spec.rb +1 -1
- data/spec/lib/oauth/pre_authorization_spec.rb +9 -10
- data/spec/lib/oauth/refresh_token_request_spec.rb +26 -6
- data/spec/lib/oauth/scopes_spec.rb +1 -1
- data/spec/lib/oauth/token_request_spec.rb +6 -3
- data/spec/lib/request/strategy_spec.rb +53 -0
- data/spec/lib/server_spec.rb +4 -2
- data/spec/models/doorkeeper/access_grant_spec.rb +5 -5
- data/spec/models/doorkeeper/access_token_spec.rb +102 -5
- data/spec/models/doorkeeper/application_spec.rb +13 -16
- data/spec/requests/applications/applications_request_spec.rb +1 -1
- data/spec/requests/endpoints/authorization_spec.rb +2 -1
- data/spec/requests/endpoints/token_spec.rb +9 -9
- data/spec/requests/flows/authorization_code_errors_spec.rb +4 -4
- data/spec/requests/flows/authorization_code_spec.rb +36 -2
- data/spec/requests/flows/implicit_grant_spec.rb +14 -5
- data/spec/requests/flows/password_spec.rb +14 -20
- data/spec/requests/flows/refresh_token_spec.rb +15 -7
- data/spec/requests/flows/revoke_token_spec.rb +9 -31
- data/spec/requests/protected_resources/metal_spec.rb +3 -3
- data/spec/requests/protected_resources/private_api_spec.rb +11 -0
- data/spec/routing/custom_controller_routes_spec.rb +1 -2
- data/spec/routing/default_routes_spec.rb +1 -2
- data/spec/routing/scoped_routes_spec.rb +0 -1
- data/spec/spec_helper_integration.rb +10 -7
- data/spec/support/helpers/access_token_request_helper.rb +1 -1
- data/spec/support/helpers/authorization_request_helper.rb +1 -1
- data/spec/support/helpers/config_helper.rb +1 -1
- data/spec/support/helpers/model_helper.rb +1 -1
- data/spec/support/helpers/request_spec_helper.rb +1 -1
- data/spec/support/helpers/url_helper.rb +1 -1
- data/spec/support/shared/models_shared_examples.rb +1 -1
- data/spec/validators/redirect_uri_validator_spec.rb +5 -0
- metadata +127 -98
- data/gemfiles/Gemfile.common.rb +0 -14
- data/gemfiles/Gemfile.mongo_mapper.rb +0 -5
- data/gemfiles/Gemfile.mongoid2.rb +0 -5
- data/gemfiles/Gemfile.mongoid3.rb +0 -4
- data/gemfiles/Gemfile.mongoid4.rb +0 -5
- data/lib/doorkeeper/generators/doorkeeper/mongo_mapper/indexes_generator.rb +0 -12
- data/lib/doorkeeper/generators/doorkeeper/mongo_mapper/templates/indexes.rb +0 -3
- data/lib/doorkeeper/orm/mongo_mapper/access_grant.rb +0 -24
- data/lib/doorkeeper/orm/mongo_mapper/access_token.rb +0 -43
- data/lib/doorkeeper/orm/mongo_mapper/application.rb +0 -29
- data/lib/doorkeeper/orm/mongo_mapper.rb +0 -11
- data/lib/doorkeeper/orm/mongoid2/access_grant.rb +0 -22
- data/lib/doorkeeper/orm/mongoid2/access_token.rb +0 -37
- data/lib/doorkeeper/orm/mongoid2/application.rb +0 -25
- data/lib/doorkeeper/orm/mongoid2/concerns/scopes.rb +0 -30
- data/lib/doorkeeper/orm/mongoid2.rb +0 -11
- data/lib/doorkeeper/orm/mongoid3/access_grant.rb +0 -22
- data/lib/doorkeeper/orm/mongoid3/access_token.rb +0 -37
- data/lib/doorkeeper/orm/mongoid3/application.rb +0 -25
- data/lib/doorkeeper/orm/mongoid3/concerns/scopes.rb +0 -30
- data/lib/doorkeeper/orm/mongoid3.rb +0 -11
- data/lib/doorkeeper/orm/mongoid4/access_grant.rb +0 -22
- data/lib/doorkeeper/orm/mongoid4/access_token.rb +0 -37
- data/lib/doorkeeper/orm/mongoid4/application.rb +0 -25
- data/lib/doorkeeper/orm/mongoid4/concerns/scopes.rb +0 -17
- data/lib/doorkeeper/orm/mongoid4.rb +0 -11
- data/spec/dummy/config/mongo.yml +0 -11
- data/spec/dummy/config/mongoid2.yml +0 -9
- data/spec/dummy/config/mongoid3.yml +0 -18
- data/spec/dummy/config/mongoid4.yml +0 -19
- data/spec/support/orm/mongo_mapper.rb +0 -10
- data/spec/support/orm/mongoid.rb +0 -10
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'doorkeeper/orm/mongoid3/concerns/scopes'
|
2
|
-
|
3
|
-
module Doorkeeper
|
4
|
-
class AccessToken
|
5
|
-
include Mongoid::Document
|
6
|
-
include Mongoid::Timestamps
|
7
|
-
|
8
|
-
include AccessTokenMixin
|
9
|
-
include Models::Mongoid3::Scopes
|
10
|
-
|
11
|
-
self.store_in collection: :oauth_access_tokens
|
12
|
-
|
13
|
-
field :resource_owner_id, type: Moped::BSON::ObjectId
|
14
|
-
field :application_id, type: Moped::BSON::ObjectId
|
15
|
-
field :token, type: String
|
16
|
-
field :refresh_token, type: String
|
17
|
-
field :expires_in, type: Integer
|
18
|
-
field :revoked_at, type: DateTime
|
19
|
-
|
20
|
-
index({ token: 1 }, { unique: true })
|
21
|
-
index({ refresh_token: 1 }, { unique: true, sparse: true })
|
22
|
-
|
23
|
-
def self.delete_all_for(application_id, resource_owner)
|
24
|
-
where(application_id: application_id,
|
25
|
-
resource_owner_id: resource_owner.id).delete_all
|
26
|
-
end
|
27
|
-
private_class_method :delete_all_for
|
28
|
-
|
29
|
-
def self.order_method
|
30
|
-
:order_by
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.created_at_desc
|
34
|
-
[:created_at, :desc]
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Doorkeeper
|
2
|
-
class Application
|
3
|
-
include Mongoid::Document
|
4
|
-
include Mongoid::Timestamps
|
5
|
-
include Models::Mongoid3::Scopes
|
6
|
-
|
7
|
-
include ApplicationMixin
|
8
|
-
|
9
|
-
self.store_in collection: :oauth_applications
|
10
|
-
|
11
|
-
field :name, type: String
|
12
|
-
field :uid, type: String
|
13
|
-
field :secret, type: String
|
14
|
-
field :redirect_uri, type: String
|
15
|
-
|
16
|
-
index({ uid: 1 }, { unique: true })
|
17
|
-
|
18
|
-
has_many :authorized_tokens, class_name: 'Doorkeeper::AccessToken'
|
19
|
-
|
20
|
-
def self.authorized_for(resource_owner)
|
21
|
-
ids = AccessToken.where(resource_owner_id: resource_owner.id, revoked_at: nil).map(&:application_id)
|
22
|
-
find(ids)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Doorkeeper
|
2
|
-
module Models
|
3
|
-
module Mongoid3
|
4
|
-
module Scopes
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
# It's strange that if not define these after included will raise error
|
8
|
-
# in Mongoid 2 and 3, but 4 works well see:
|
9
|
-
# https://travis-ci.org/jasl/doorkeeper/builds/31586902
|
10
|
-
included do
|
11
|
-
def scopes
|
12
|
-
OAuth::Scopes.from_string(self[:scopes])
|
13
|
-
end
|
14
|
-
|
15
|
-
def scopes_string
|
16
|
-
self[:scopes]
|
17
|
-
end
|
18
|
-
|
19
|
-
def includes_scope?(*required_scopes)
|
20
|
-
required_scopes.blank? || required_scopes.any? { |s| scopes.exists?(s.to_s) }
|
21
|
-
end
|
22
|
-
|
23
|
-
def scopes=(value)
|
24
|
-
write_attribute :scopes, value if value.present?
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'doorkeeper/orm/mongoid4/concerns/scopes'
|
2
|
-
|
3
|
-
module Doorkeeper
|
4
|
-
class AccessGrant
|
5
|
-
include Mongoid::Document
|
6
|
-
include Mongoid::Timestamps
|
7
|
-
|
8
|
-
include AccessGrantMixin
|
9
|
-
include Models::Mongoid4::Scopes
|
10
|
-
|
11
|
-
self.store_in collection: :oauth_access_grants
|
12
|
-
|
13
|
-
field :resource_owner_id, type: BSON::ObjectId
|
14
|
-
field :application_id, type: BSON::ObjectId
|
15
|
-
field :token, type: String
|
16
|
-
field :expires_in, type: Integer
|
17
|
-
field :redirect_uri, type: String
|
18
|
-
field :revoked_at, type: DateTime
|
19
|
-
|
20
|
-
index({ token: 1 }, { unique: true })
|
21
|
-
end
|
22
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'doorkeeper/orm/mongoid4/concerns/scopes'
|
2
|
-
|
3
|
-
module Doorkeeper
|
4
|
-
class AccessToken
|
5
|
-
include Mongoid::Document
|
6
|
-
include Mongoid::Timestamps
|
7
|
-
|
8
|
-
include AccessTokenMixin
|
9
|
-
include Models::Mongoid4::Scopes
|
10
|
-
|
11
|
-
self.store_in collection: :oauth_access_tokens
|
12
|
-
|
13
|
-
field :resource_owner_id, type: BSON::ObjectId
|
14
|
-
field :application_id, type: BSON::ObjectId
|
15
|
-
field :token, type: String
|
16
|
-
field :refresh_token, type: String
|
17
|
-
field :expires_in, type: Integer
|
18
|
-
field :revoked_at, type: DateTime
|
19
|
-
|
20
|
-
index({ token: 1 }, { unique: true })
|
21
|
-
index({ refresh_token: 1 }, { unique: true, sparse: true })
|
22
|
-
|
23
|
-
def self.delete_all_for(application_id, resource_owner)
|
24
|
-
where(application_id: application_id,
|
25
|
-
resource_owner_id: resource_owner.id).delete_all
|
26
|
-
end
|
27
|
-
private_class_method :delete_all_for
|
28
|
-
|
29
|
-
def self.order_method
|
30
|
-
:order_by
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.created_at_desc
|
34
|
-
[:created_at, :desc]
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Doorkeeper
|
2
|
-
class Application
|
3
|
-
include Mongoid::Document
|
4
|
-
include Mongoid::Timestamps
|
5
|
-
include Models::Mongoid4::Scopes
|
6
|
-
|
7
|
-
include ApplicationMixin
|
8
|
-
|
9
|
-
self.store_in collection: :oauth_applications
|
10
|
-
|
11
|
-
field :name, type: String
|
12
|
-
field :uid, type: String
|
13
|
-
field :secret, type: String
|
14
|
-
field :redirect_uri, type: String
|
15
|
-
|
16
|
-
index({ uid: 1 }, { unique: true })
|
17
|
-
|
18
|
-
has_many :authorized_tokens, class_name: 'Doorkeeper::AccessToken'
|
19
|
-
|
20
|
-
def self.authorized_for(resource_owner)
|
21
|
-
ids = AccessToken.where(resource_owner_id: resource_owner.id, revoked_at: nil).map(&:application_id)
|
22
|
-
find(ids)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Doorkeeper
|
2
|
-
module Models
|
3
|
-
module Mongoid4
|
4
|
-
module Scopes
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
included do
|
8
|
-
field :scopes, type: String
|
9
|
-
end
|
10
|
-
|
11
|
-
def scopes=(value)
|
12
|
-
write_attribute :scopes, value if value.present?
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/spec/dummy/config/mongo.yml
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
development:
|
2
|
-
sessions:
|
3
|
-
default:
|
4
|
-
database: doorkeeper-mongoid3-development
|
5
|
-
hosts:
|
6
|
-
- localhost:27017
|
7
|
-
options:
|
8
|
-
consistency: :strong
|
9
|
-
safe: true
|
10
|
-
test:
|
11
|
-
sessions:
|
12
|
-
default:
|
13
|
-
database: doorkeeper-mongoid3-test
|
14
|
-
hosts:
|
15
|
-
- localhost:27017
|
16
|
-
options:
|
17
|
-
consistency: :strong
|
18
|
-
safe: true
|
@@ -1,19 +0,0 @@
|
|
1
|
-
development:
|
2
|
-
sessions:
|
3
|
-
default:
|
4
|
-
database: doorkeeper-mongoid4-development
|
5
|
-
hosts:
|
6
|
-
- localhost:27017
|
7
|
-
options:
|
8
|
-
write:
|
9
|
-
w: 1
|
10
|
-
|
11
|
-
test:
|
12
|
-
sessions:
|
13
|
-
default:
|
14
|
-
database: doorkeeper-mongoid4-test
|
15
|
-
hosts:
|
16
|
-
- localhost:27017
|
17
|
-
options:
|
18
|
-
write:
|
19
|
-
w: 1
|
@@ -1,10 +0,0 @@
|
|
1
|
-
DatabaseCleaner[:mongo_mapper].strategy = :truncation
|
2
|
-
DatabaseCleaner[:mongo_mapper].clean_with :truncation
|
3
|
-
|
4
|
-
RSpec.configure do |config|
|
5
|
-
config.before :suite do
|
6
|
-
Doorkeeper::Application.create_indexes
|
7
|
-
Doorkeeper::AccessGrant.create_indexes
|
8
|
-
Doorkeeper::AccessToken.create_indexes
|
9
|
-
end
|
10
|
-
end
|
data/spec/support/orm/mongoid.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
DatabaseCleaner[:mongoid].strategy = :truncation
|
2
|
-
DatabaseCleaner[:mongoid].clean_with :truncation
|
3
|
-
|
4
|
-
RSpec.configure do |config|
|
5
|
-
config.before do
|
6
|
-
Doorkeeper::Application.create_indexes
|
7
|
-
Doorkeeper::AccessGrant.create_indexes
|
8
|
-
Doorkeeper::AccessToken.create_indexes
|
9
|
-
end
|
10
|
-
end
|