doorkeeper 2.2.2 → 3.0.0.rc1
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/.travis.yml +0 -23
- data/NEWS.md +17 -9
- data/README.md +5 -31
- data/config/locales/en.yml +1 -31
- data/doorkeeper.gemspec +0 -3
- data/lib/doorkeeper.rb +0 -4
- data/lib/doorkeeper/models/application_mixin.rb +0 -12
- data/lib/doorkeeper/orm/active_record.rb +3 -4
- data/lib/doorkeeper/rails/helpers.rb +0 -18
- data/lib/doorkeeper/version.rb +1 -1
- data/lib/generators/doorkeeper/templates/README +0 -20
- data/lib/generators/doorkeeper/templates/initializer.rb +1 -3
- data/spec/controllers/protected_resources_controller_spec.rb +0 -13
- data/spec/dummy/app/models/user.rb +1 -25
- data/spec/dummy/config/application.rb +0 -1
- data/spec/dummy/config/initializers/doorkeeper.rb +0 -2
- data/spec/models/doorkeeper/application_spec.rb +0 -15
- data/spec/spec_helper_integration.rb +1 -7
- metadata +4 -84
- data/gemfiles/Gemfile.common.rb +0 -7
- 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 -4
- 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.rb +0 -19
- 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 -32
- data/lib/doorkeeper/orm/mongoid2.rb +0 -19
- 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/mongoid3.rb +0 -19
- 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/mongoid4.rb +0 -19
- 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/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
data/gemfiles/Gemfile.common.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
module Doorkeeper
|
2
|
-
module MongoMapper
|
3
|
-
class IndexesGenerator < ::Rails::Generators::Base
|
4
|
-
source_root File.expand_path('templates', __FILE__)
|
5
|
-
desc "'Creates an indexes file for use with MongoMapper's rake db:index'"
|
6
|
-
|
7
|
-
def install
|
8
|
-
template 'indexes.rb', 'db/indexes.rb'
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Doorkeeper
|
2
|
-
module Orm
|
3
|
-
module MongoMapper
|
4
|
-
def self.initialize_models!
|
5
|
-
require 'doorkeeper/orm/mongo_mapper/access_grant'
|
6
|
-
require 'doorkeeper/orm/mongo_mapper/access_token'
|
7
|
-
require 'doorkeeper/orm/mongo_mapper/application'
|
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
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Doorkeeper
|
2
|
-
class AccessGrant
|
3
|
-
include MongoMapper::Document
|
4
|
-
|
5
|
-
include AccessGrantMixin
|
6
|
-
|
7
|
-
safe
|
8
|
-
timestamps!
|
9
|
-
|
10
|
-
set_collection_name 'oauth_access_grants'
|
11
|
-
|
12
|
-
key :resource_owner_id, ObjectId
|
13
|
-
key :application_id, ObjectId
|
14
|
-
key :token, String
|
15
|
-
key :scopes, String
|
16
|
-
key :expires_in, Integer
|
17
|
-
key :redirect_uri, String
|
18
|
-
key :revoked_at, DateTime
|
19
|
-
|
20
|
-
def self.create_indexes
|
21
|
-
ensure_index :token, unique: true
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Doorkeeper
|
2
|
-
class AccessToken
|
3
|
-
include MongoMapper::Document
|
4
|
-
|
5
|
-
include AccessTokenMixin
|
6
|
-
|
7
|
-
safe
|
8
|
-
timestamps!
|
9
|
-
|
10
|
-
set_collection_name 'oauth_access_tokens'
|
11
|
-
|
12
|
-
key :resource_owner_id, ObjectId
|
13
|
-
key :application_id, ObjectId
|
14
|
-
key :token, String
|
15
|
-
key :refresh_token, String
|
16
|
-
key :expires_in, Integer
|
17
|
-
key :revoked_at, DateTime
|
18
|
-
key :scopes, String
|
19
|
-
|
20
|
-
def self.last
|
21
|
-
self.sort(:created_at).last
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.delete_all_for(application_id, resource_owner)
|
25
|
-
delete_all(application_id: application_id,
|
26
|
-
resource_owner_id: resource_owner.id)
|
27
|
-
end
|
28
|
-
private_class_method :delete_all_for
|
29
|
-
|
30
|
-
def self.create_indexes
|
31
|
-
ensure_index :token, unique: true
|
32
|
-
ensure_index [[:refresh_token, 1]], unique: true, sparse: true
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.order_method
|
36
|
-
:sort
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.created_at_desc
|
40
|
-
:created_at.desc
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module Doorkeeper
|
2
|
-
class Application
|
3
|
-
include MongoMapper::Document
|
4
|
-
|
5
|
-
include ApplicationMixin
|
6
|
-
|
7
|
-
safe
|
8
|
-
timestamps!
|
9
|
-
|
10
|
-
set_collection_name 'oauth_applications'
|
11
|
-
|
12
|
-
many :authorized_tokens, class_name: 'Doorkeeper::AccessToken'
|
13
|
-
|
14
|
-
key :name, String
|
15
|
-
key :uid, String
|
16
|
-
key :secret, String
|
17
|
-
key :redirect_uri, String
|
18
|
-
key :scopes, String
|
19
|
-
|
20
|
-
def self.authorized_for(resource_owner)
|
21
|
-
ids = AccessToken.where(
|
22
|
-
resource_owner_id: resource_owner.id,
|
23
|
-
revoked_at: nil
|
24
|
-
).map(&:application_id)
|
25
|
-
find(ids)
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.create_indexes
|
29
|
-
ensure_index :uid, unique: true
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Doorkeeper
|
2
|
-
module Orm
|
3
|
-
module Mongoid2
|
4
|
-
def self.initialize_models!
|
5
|
-
require 'doorkeeper/orm/mongoid2/access_grant'
|
6
|
-
require 'doorkeeper/orm/mongoid2/access_token'
|
7
|
-
require 'doorkeeper/orm/mongoid2/application'
|
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
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'doorkeeper/orm/mongoid2/concerns/scopes'
|
2
|
-
|
3
|
-
module Doorkeeper
|
4
|
-
class AccessGrant
|
5
|
-
include Mongoid::Document
|
6
|
-
include Mongoid::Timestamps
|
7
|
-
|
8
|
-
include AccessGrantMixin
|
9
|
-
include Models::Mongoid2::Scopes
|
10
|
-
|
11
|
-
self.store_in :oauth_access_grants
|
12
|
-
|
13
|
-
field :resource_owner_id, type: Integer
|
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, unique: true
|
21
|
-
end
|
22
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'doorkeeper/orm/mongoid2/concerns/scopes'
|
2
|
-
|
3
|
-
module Doorkeeper
|
4
|
-
class AccessToken
|
5
|
-
include Mongoid::Document
|
6
|
-
include Mongoid::Timestamps
|
7
|
-
|
8
|
-
include AccessTokenMixin
|
9
|
-
include Models::Mongoid2::Scopes
|
10
|
-
|
11
|
-
self.store_in :oauth_access_tokens
|
12
|
-
|
13
|
-
field :resource_owner_id, type: Integer
|
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, unique: true
|
21
|
-
index :refresh_token, 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::Mongoid2::Scopes
|
6
|
-
|
7
|
-
include ApplicationMixin
|
8
|
-
|
9
|
-
self.store_in :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, 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 Mongoid2
|
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
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Doorkeeper
|
2
|
-
module Orm
|
3
|
-
module Mongoid3
|
4
|
-
def self.initialize_models!
|
5
|
-
require 'doorkeeper/orm/mongoid3/access_grant'
|
6
|
-
require 'doorkeeper/orm/mongoid3/access_token'
|
7
|
-
require 'doorkeeper/orm/mongoid3/application'
|
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
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'doorkeeper/orm/mongoid3/concerns/scopes'
|
2
|
-
|
3
|
-
module Doorkeeper
|
4
|
-
class AccessGrant
|
5
|
-
include Mongoid::Document
|
6
|
-
include Mongoid::Timestamps
|
7
|
-
|
8
|
-
include AccessGrantMixin
|
9
|
-
include Models::Mongoid3::Scopes
|
10
|
-
|
11
|
-
self.store_in collection: :oauth_access_grants
|
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 :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/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
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|