doorkeeper 4.4.3 → 5.0.3
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 +5 -5
- data/.gitignore +1 -0
- data/.gitlab-ci.yml +16 -0
- data/.travis.yml +7 -0
- data/Appraisals +2 -2
- data/Dangerfile +64 -0
- data/Gemfile +1 -1
- data/NEWS.md +98 -8
- data/README.md +110 -12
- data/Rakefile +6 -0
- data/UPGRADE.md +2 -0
- data/app/assets/stylesheets/doorkeeper/admin/application.css +2 -2
- data/app/controllers/doorkeeper/application_controller.rb +6 -3
- data/app/controllers/doorkeeper/application_metal_controller.rb +6 -0
- data/app/controllers/doorkeeper/applications_controller.rb +46 -24
- data/app/controllers/doorkeeper/authorizations_controller.rb +55 -12
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +21 -2
- data/app/controllers/doorkeeper/token_info_controller.rb +2 -0
- data/app/controllers/doorkeeper/tokens_controller.rb +4 -6
- data/app/helpers/doorkeeper/dashboard_helper.rb +9 -7
- data/app/validators/redirect_uri_validator.rb +5 -2
- data/app/views/doorkeeper/applications/_delete_form.html.erb +3 -1
- data/app/views/doorkeeper/applications/_form.html.erb +25 -24
- data/app/views/doorkeeper/applications/edit.html.erb +1 -1
- data/app/views/doorkeeper/applications/index.html.erb +17 -7
- data/app/views/doorkeeper/applications/new.html.erb +1 -1
- data/app/views/doorkeeper/applications/show.html.erb +6 -6
- data/app/views/doorkeeper/authorizations/error.html.erb +1 -1
- data/app/views/doorkeeper/authorizations/new.html.erb +4 -0
- data/app/views/layouts/doorkeeper/admin.html.erb +15 -15
- data/config/locales/en.yml +10 -1
- data/doorkeeper.gemspec +25 -26
- data/gemfiles/rails_5_2.gemfile +1 -1
- data/gemfiles/rails_master.gemfile +4 -1
- data/lib/doorkeeper/config.rb +81 -40
- data/lib/doorkeeper/engine.rb +6 -0
- data/lib/doorkeeper/errors.rb +17 -3
- data/lib/doorkeeper/grape/authorization_decorator.rb +2 -0
- data/lib/doorkeeper/grape/helpers.rb +3 -1
- data/lib/doorkeeper/helpers/controller.rb +9 -2
- data/lib/doorkeeper/models/access_grant_mixin.rb +73 -0
- data/lib/doorkeeper/models/access_token_mixin.rb +44 -25
- data/lib/doorkeeper/models/application_mixin.rb +2 -0
- data/lib/doorkeeper/models/concerns/accessible.rb +2 -0
- data/lib/doorkeeper/models/concerns/expirable.rb +2 -0
- data/lib/doorkeeper/models/concerns/orderable.rb +2 -0
- data/lib/doorkeeper/models/concerns/ownership.rb +2 -0
- data/lib/doorkeeper/models/concerns/revocable.rb +2 -0
- data/lib/doorkeeper/models/concerns/scopes.rb +3 -1
- data/lib/doorkeeper/oauth/authorization/code.rb +33 -8
- data/lib/doorkeeper/oauth/authorization/context.rb +17 -0
- data/lib/doorkeeper/oauth/authorization/token.rb +38 -14
- data/lib/doorkeeper/oauth/authorization/uri_builder.rb +2 -0
- data/lib/doorkeeper/oauth/authorization_code_request.rb +29 -2
- data/lib/doorkeeper/oauth/base_request.rb +22 -9
- data/lib/doorkeeper/oauth/base_response.rb +2 -0
- data/lib/doorkeeper/oauth/client/credentials.rb +3 -1
- data/lib/doorkeeper/oauth/client.rb +1 -1
- data/lib/doorkeeper/oauth/client_credentials/creator.rb +4 -1
- data/lib/doorkeeper/oauth/client_credentials/issuer.rb +7 -2
- data/lib/doorkeeper/oauth/client_credentials/validation.rb +5 -5
- data/lib/doorkeeper/oauth/client_credentials_request.rb +1 -3
- data/lib/doorkeeper/oauth/code_request.rb +2 -0
- data/lib/doorkeeper/oauth/code_response.rb +2 -0
- data/lib/doorkeeper/oauth/error.rb +2 -0
- data/lib/doorkeeper/oauth/error_response.rb +21 -3
- data/lib/doorkeeper/oauth/forbidden_token_response.rb +9 -2
- data/lib/doorkeeper/oauth/helpers/scope_checker.rb +2 -8
- data/lib/doorkeeper/oauth/helpers/unique_token.rb +2 -0
- data/lib/doorkeeper/oauth/helpers/uri_checker.rb +5 -2
- data/lib/doorkeeper/oauth/invalid_token_response.rb +18 -0
- data/lib/doorkeeper/oauth/password_access_token_request.rb +9 -4
- data/lib/doorkeeper/oauth/pre_authorization.rb +43 -11
- data/lib/doorkeeper/oauth/refresh_token_request.rb +16 -3
- data/lib/doorkeeper/oauth/scopes.rb +3 -1
- data/lib/doorkeeper/oauth/token.rb +7 -2
- data/lib/doorkeeper/oauth/token_introspection.rb +4 -2
- data/lib/doorkeeper/oauth/token_request.rb +2 -0
- data/lib/doorkeeper/oauth/token_response.rb +6 -2
- data/lib/doorkeeper/oauth.rb +13 -0
- data/lib/doorkeeper/orm/active_record/application.rb +75 -12
- data/lib/doorkeeper/orm/active_record/stale_records_cleaner.rb +26 -0
- data/lib/doorkeeper/orm/active_record.rb +4 -0
- data/lib/doorkeeper/rails/helpers.rb +6 -4
- data/lib/doorkeeper/rails/routes/mapper.rb +2 -0
- data/lib/doorkeeper/rails/routes/mapping.rb +2 -0
- data/lib/doorkeeper/rails/routes.rb +23 -8
- data/lib/doorkeeper/rake/db.rake +40 -0
- data/lib/doorkeeper/rake/setup.rake +6 -0
- data/lib/doorkeeper/rake.rb +14 -0
- data/lib/doorkeeper/request/authorization_code.rb +1 -1
- data/lib/doorkeeper/request/client_credentials.rb +1 -1
- data/lib/doorkeeper/request/code.rb +1 -1
- data/lib/doorkeeper/request/password.rb +1 -1
- data/lib/doorkeeper/request/refresh_token.rb +1 -1
- data/lib/doorkeeper/request/strategy.rb +2 -0
- data/lib/doorkeeper/request/token.rb +1 -1
- data/lib/doorkeeper/request.rb +29 -34
- data/lib/doorkeeper/server.rb +2 -0
- data/lib/doorkeeper/stale_records_cleaner.rb +20 -0
- data/lib/doorkeeper/validations.rb +2 -0
- data/lib/doorkeeper/version.rb +6 -24
- data/lib/doorkeeper.rb +20 -17
- data/lib/generators/doorkeeper/application_owner_generator.rb +23 -18
- data/lib/generators/doorkeeper/confidential_applications_generator.rb +32 -0
- data/lib/generators/doorkeeper/install_generator.rb +17 -9
- data/lib/generators/doorkeeper/migration_generator.rb +23 -18
- data/lib/generators/doorkeeper/pkce_generator.rb +32 -0
- data/lib/generators/doorkeeper/previous_refresh_token_generator.rb +29 -24
- data/lib/generators/doorkeeper/templates/add_confidential_to_applications.rb.erb +13 -0
- data/lib/generators/doorkeeper/templates/enable_pkce_migration.rb.erb +6 -0
- data/lib/generators/doorkeeper/templates/initializer.rb +96 -13
- data/lib/generators/doorkeeper/templates/migration.rb.erb +2 -3
- data/lib/generators/doorkeeper/views_generator.rb +3 -1
- data/spec/controllers/application_metal_controller_spec.rb +50 -0
- data/spec/controllers/applications_controller_spec.rb +123 -14
- data/spec/controllers/authorizations_controller_spec.rb +334 -51
- data/spec/controllers/protected_resources_controller_spec.rb +60 -18
- data/spec/controllers/token_info_controller_spec.rb +4 -12
- data/spec/controllers/tokens_controller_spec.rb +17 -20
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/app/controllers/custom_authorizations_controller.rb +1 -1
- data/spec/dummy/app/controllers/home_controller.rb +1 -2
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/boot.rb +2 -4
- data/spec/dummy/config/environment.rb +1 -1
- data/spec/dummy/config/environments/test.rb +5 -6
- data/spec/dummy/config/initializers/doorkeeper.rb +12 -6
- data/spec/dummy/config/initializers/new_framework_defaults.rb +2 -0
- data/spec/dummy/config/initializers/secret_token.rb +1 -1
- data/spec/dummy/config/routes.rb +3 -42
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/db/migrate/20151223192035_create_doorkeeper_tables.rb +4 -4
- data/spec/dummy/db/migrate/20151223200000_add_owner_to_application.rb +1 -1
- data/spec/dummy/db/migrate/20170822064514_enable_pkce.rb +6 -0
- data/spec/dummy/db/migrate/{20180210183654_add_confidential_to_application.rb → 20180210183654_add_confidential_to_applications.rb} +1 -1
- data/spec/dummy/db/schema.rb +36 -36
- data/spec/dummy/script/rails +4 -3
- data/spec/factories.rb +6 -6
- data/spec/generators/application_owner_generator_spec.rb +1 -1
- data/spec/generators/confidential_applications_generator_spec.rb +45 -0
- data/spec/generators/install_generator_spec.rb +5 -2
- data/spec/generators/migration_generator_spec.rb +1 -1
- data/spec/generators/pkce_generator_spec.rb +43 -0
- data/spec/generators/previous_refresh_token_generator_spec.rb +1 -1
- data/spec/generators/templates/routes.rb +0 -1
- data/spec/generators/views_generator_spec.rb +2 -2
- data/spec/grape/grape_integration_spec.rb +2 -2
- data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +1 -1
- data/spec/lib/config_spec.rb +105 -39
- data/spec/lib/doorkeeper_spec.rb +6 -131
- data/spec/lib/models/expirable_spec.rb +0 -3
- data/spec/lib/models/revocable_spec.rb +0 -2
- data/spec/lib/models/scopes_spec.rb +0 -4
- data/spec/lib/oauth/authorization/uri_builder_spec.rb +0 -4
- data/spec/lib/oauth/authorization_code_request_spec.rb +17 -7
- data/spec/lib/oauth/base_request_spec.rb +49 -11
- data/spec/lib/oauth/base_response_spec.rb +1 -1
- data/spec/lib/oauth/client/credentials_spec.rb +2 -4
- data/spec/lib/oauth/client_credentials/creator_spec.rb +5 -1
- data/spec/lib/oauth/client_credentials/issuer_spec.rb +24 -7
- data/spec/lib/oauth/client_credentials/validation_spec.rb +4 -4
- data/spec/lib/oauth/client_credentials_integration_spec.rb +2 -2
- data/spec/lib/oauth/client_credentials_request_spec.rb +3 -5
- data/spec/lib/oauth/client_spec.rb +0 -3
- data/spec/lib/oauth/code_request_spec.rb +5 -3
- data/spec/lib/oauth/code_response_spec.rb +1 -1
- data/spec/lib/oauth/error_response_spec.rb +0 -3
- data/spec/lib/oauth/error_spec.rb +0 -2
- data/spec/lib/oauth/forbidden_token_response_spec.rb +1 -4
- data/spec/lib/oauth/helpers/scope_checker_spec.rb +8 -11
- data/spec/lib/oauth/helpers/unique_token_spec.rb +0 -1
- data/spec/lib/oauth/helpers/uri_checker_spec.rb +22 -13
- data/spec/lib/oauth/invalid_token_response_spec.rb +1 -4
- data/spec/lib/oauth/password_access_token_request_spec.rb +53 -6
- data/spec/lib/oauth/pre_authorization_spec.rb +33 -4
- data/spec/lib/oauth/refresh_token_request_spec.rb +22 -14
- data/spec/lib/oauth/scopes_spec.rb +0 -3
- data/spec/lib/oauth/token_request_spec.rb +8 -9
- data/spec/lib/oauth/token_response_spec.rb +0 -1
- data/spec/lib/oauth/token_spec.rb +40 -14
- data/spec/lib/request/strategy_spec.rb +0 -1
- data/spec/lib/server_spec.rb +7 -7
- data/spec/lib/stale_records_cleaner_spec.rb +89 -0
- data/spec/models/doorkeeper/access_grant_spec.rb +44 -1
- data/spec/models/doorkeeper/access_token_spec.rb +80 -32
- data/spec/models/doorkeeper/application_spec.rb +293 -221
- data/spec/requests/applications/applications_request_spec.rb +134 -1
- data/spec/requests/applications/authorized_applications_spec.rb +1 -1
- data/spec/requests/endpoints/authorization_spec.rb +3 -3
- data/spec/requests/endpoints/token_spec.rb +7 -5
- data/spec/requests/flows/authorization_code_errors_spec.rb +2 -2
- data/spec/requests/flows/authorization_code_spec.rb +258 -2
- data/spec/requests/flows/client_credentials_spec.rb +46 -6
- data/spec/requests/flows/implicit_grant_errors_spec.rb +3 -3
- data/spec/requests/flows/implicit_grant_spec.rb +38 -11
- data/spec/requests/flows/password_spec.rb +61 -3
- data/spec/requests/flows/refresh_token_spec.rb +59 -2
- data/spec/requests/flows/revoke_token_spec.rb +20 -20
- data/spec/requests/flows/skip_authorization_spec.rb +16 -11
- data/spec/requests/protected_resources/metal_spec.rb +1 -1
- data/spec/requests/protected_resources/private_api_spec.rb +3 -3
- data/spec/routing/custom_controller_routes_spec.rb +59 -7
- data/spec/routing/default_routes_spec.rb +2 -2
- data/spec/routing/scoped_routes_spec.rb +16 -2
- data/spec/spec_helper.rb +54 -3
- data/spec/spec_helper_integration.rb +2 -74
- data/spec/support/dependencies/{factory_girl.rb → factory_bot.rb} +0 -0
- data/spec/support/doorkeeper_rspec.rb +20 -0
- data/spec/support/helpers/authorization_request_helper.rb +4 -4
- data/spec/support/helpers/model_helper.rb +8 -4
- data/spec/support/helpers/request_spec_helper.rb +10 -2
- data/spec/support/helpers/url_helper.rb +18 -14
- data/spec/support/http_method_shim.rb +12 -16
- data/spec/support/shared/controllers_shared_context.rb +56 -0
- data/spec/validators/redirect_uri_validator_spec.rb +9 -3
- data/spec/version/version_spec.rb +3 -3
- data/vendor/assets/stylesheets/doorkeeper/bootstrap.min.css +4 -5
- metadata +54 -35
- data/lib/generators/doorkeeper/add_client_confidentiality_generator.rb +0 -31
- data/lib/generators/doorkeeper/templates/add_confidential_to_application_migration.rb.erb +0 -11
- data/spec/controllers/application_metal_controller.rb +0 -10
data/lib/doorkeeper/request.rb
CHANGED
@@ -1,46 +1,41 @@
|
|
1
|
-
|
2
|
-
require 'doorkeeper/request/client_credentials'
|
3
|
-
require 'doorkeeper/request/code'
|
4
|
-
require 'doorkeeper/request/password'
|
5
|
-
require 'doorkeeper/request/refresh_token'
|
6
|
-
require 'doorkeeper/request/token'
|
1
|
+
# frozen_string_literal: true
|
7
2
|
|
8
3
|
module Doorkeeper
|
9
4
|
module Request
|
10
|
-
|
5
|
+
class << self
|
6
|
+
def authorization_strategy(response_type)
|
7
|
+
get_strategy(response_type, authorization_response_types)
|
8
|
+
rescue NameError
|
9
|
+
raise Errors::InvalidAuthorizationStrategy
|
10
|
+
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
def token_strategy(grant_type)
|
13
|
+
get_strategy(grant_type, token_grant_types)
|
14
|
+
rescue NameError
|
15
|
+
raise Errors::InvalidTokenStrategy
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
raise Errors::InvalidTokenStrategy
|
22
|
-
end
|
18
|
+
def get_strategy(grant_or_request_type, available)
|
19
|
+
raise Errors::MissingRequestStrategy if grant_or_request_type.blank?
|
20
|
+
raise NameError unless available.include?(grant_or_request_type.to_s)
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
fail NameError unless available.include?(grant_or_request_type.to_s)
|
27
|
-
strategy_class(grant_or_request_type)
|
28
|
-
end
|
22
|
+
build_strategy_class(grant_or_request_type)
|
23
|
+
end
|
29
24
|
|
30
|
-
|
31
|
-
Doorkeeper.configuration.authorization_response_types
|
32
|
-
end
|
33
|
-
private_class_method :authorization_response_types
|
25
|
+
private
|
34
26
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
27
|
+
def authorization_response_types
|
28
|
+
Doorkeeper.configuration.authorization_response_types
|
29
|
+
end
|
30
|
+
|
31
|
+
def token_grant_types
|
32
|
+
Doorkeeper.configuration.token_grant_types
|
33
|
+
end
|
39
34
|
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
def build_strategy_class(grant_or_request_type)
|
36
|
+
strategy_class_name = grant_or_request_type.to_s.tr(' ', '_').camelize
|
37
|
+
"Doorkeeper::Request::#{strategy_class_name}".constantize
|
38
|
+
end
|
43
39
|
end
|
44
|
-
private_class_method :strategy_class
|
45
40
|
end
|
46
41
|
end
|
data/lib/doorkeeper/server.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Doorkeeper
|
4
|
+
class StaleRecordsCleaner
|
5
|
+
CLEANER_CLASS = 'StaleRecordsCleaner'.freeze
|
6
|
+
|
7
|
+
def self.for(base_scope)
|
8
|
+
orm_adapter = "doorkeeper/orm/#{Doorkeeper.configuration.orm}".classify
|
9
|
+
|
10
|
+
orm_cleaner = "#{orm_adapter}::#{CLEANER_CLASS}".constantize
|
11
|
+
orm_cleaner.new(base_scope)
|
12
|
+
rescue NameError
|
13
|
+
raise Doorkeeper::Errors::NoOrmCleaner, "'#{Doorkeeper.configuration.orm}' ORM has no cleaner!"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.new(base_scope)
|
17
|
+
self.for(base_scope)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/doorkeeper/version.rb
CHANGED
@@ -1,36 +1,18 @@
|
|
1
|
-
|
2
|
-
CVE_2018_1000211_WARNING = <<-HEREDOC.freeze
|
3
|
-
|
4
|
-
|
5
|
-
WARNING: This is a security release that addresses token revocation not working for public apps (CVE-2018-1000211)
|
6
|
-
|
7
|
-
There is no breaking change in this release, however to take advantage of the security fix you must:
|
8
|
-
|
9
|
-
1. Run `rails generate doorkeeper:add_client_confidentiality` for the migration
|
10
|
-
2. Review your OAuth apps and determine which ones exclusively use public grant flows (eg implicit)
|
11
|
-
3. Update their `confidential` column to `false` for those public apps
|
12
|
-
|
13
|
-
This is a backported security release.
|
14
|
-
|
15
|
-
For more information:
|
16
|
-
|
17
|
-
* https://github.com/doorkeeper-gem/doorkeeper/pull/1119
|
18
|
-
* https://github.com/doorkeeper-gem/doorkeeper/issues/891
|
19
|
-
|
20
|
-
|
21
|
-
HEREDOC
|
1
|
+
# frozen_string_literal: true
|
22
2
|
|
3
|
+
module Doorkeeper
|
23
4
|
def self.gem_version
|
24
5
|
Gem::Version.new VERSION::STRING
|
25
6
|
end
|
26
7
|
|
27
8
|
module VERSION
|
28
9
|
# Semantic versioning
|
29
|
-
MAJOR =
|
30
|
-
MINOR =
|
10
|
+
MAJOR = 5
|
11
|
+
MINOR = 0
|
31
12
|
TINY = 3
|
13
|
+
PRE = nil
|
32
14
|
|
33
15
|
# Full version number
|
34
|
-
STRING = [MAJOR, MINOR, TINY].compact.join('.')
|
16
|
+
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
|
35
17
|
end
|
36
18
|
end
|
data/lib/doorkeeper.rb
CHANGED
@@ -2,18 +2,28 @@ require 'doorkeeper/version'
|
|
2
2
|
require 'doorkeeper/engine'
|
3
3
|
require 'doorkeeper/config'
|
4
4
|
|
5
|
+
require 'doorkeeper/request/strategy'
|
6
|
+
require 'doorkeeper/request/authorization_code'
|
7
|
+
require 'doorkeeper/request/client_credentials'
|
8
|
+
require 'doorkeeper/request/code'
|
9
|
+
require 'doorkeeper/request/password'
|
10
|
+
require 'doorkeeper/request/refresh_token'
|
11
|
+
require 'doorkeeper/request/token'
|
12
|
+
|
5
13
|
require 'doorkeeper/errors'
|
6
14
|
require 'doorkeeper/server'
|
7
15
|
require 'doorkeeper/request'
|
8
16
|
require 'doorkeeper/validations'
|
9
17
|
|
10
18
|
require 'doorkeeper/oauth/authorization/code'
|
19
|
+
require 'doorkeeper/oauth/authorization/context'
|
11
20
|
require 'doorkeeper/oauth/authorization/token'
|
12
21
|
require 'doorkeeper/oauth/authorization/uri_builder'
|
13
22
|
require 'doorkeeper/oauth/helpers/scope_checker'
|
14
23
|
require 'doorkeeper/oauth/helpers/uri_checker'
|
15
24
|
require 'doorkeeper/oauth/helpers/unique_token'
|
16
25
|
|
26
|
+
require 'doorkeeper/oauth'
|
17
27
|
require 'doorkeeper/oauth/scopes'
|
18
28
|
require 'doorkeeper/oauth/error'
|
19
29
|
require 'doorkeeper/oauth/base_response'
|
@@ -25,6 +35,13 @@ require 'doorkeeper/oauth/base_request'
|
|
25
35
|
require 'doorkeeper/oauth/authorization_code_request'
|
26
36
|
require 'doorkeeper/oauth/refresh_token_request'
|
27
37
|
require 'doorkeeper/oauth/password_access_token_request'
|
38
|
+
|
39
|
+
require 'doorkeeper/oauth/client_credentials/validation'
|
40
|
+
require 'doorkeeper/oauth/client_credentials/creator'
|
41
|
+
require 'doorkeeper/oauth/client_credentials/issuer'
|
42
|
+
require 'doorkeeper/oauth/client_credentials/validation'
|
43
|
+
require 'doorkeeper/oauth/client/credentials'
|
44
|
+
|
28
45
|
require 'doorkeeper/oauth/client_credentials_request'
|
29
46
|
require 'doorkeeper/oauth/code_request'
|
30
47
|
require 'doorkeeper/oauth/token_request'
|
@@ -49,26 +66,12 @@ require 'doorkeeper/helpers/controller'
|
|
49
66
|
require 'doorkeeper/rails/routes'
|
50
67
|
require 'doorkeeper/rails/helpers'
|
51
68
|
|
52
|
-
require 'doorkeeper/
|
69
|
+
require 'doorkeeper/rake'
|
70
|
+
require 'doorkeeper/stale_records_cleaner'
|
53
71
|
|
54
|
-
require '
|
72
|
+
require 'doorkeeper/orm/active_record'
|
55
73
|
|
56
74
|
module Doorkeeper
|
57
|
-
def self.configured?
|
58
|
-
ActiveSupport::Deprecation.warn "Method `Doorkeeper#configured?` has been deprecated without replacement."
|
59
|
-
@config.present?
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.database_installed?
|
63
|
-
ActiveSupport::Deprecation.warn "Method `Doorkeeper#database_installed?` has been deprecated without replacement."
|
64
|
-
[AccessToken, AccessGrant, Application].all?(&:table_exists?)
|
65
|
-
end
|
66
|
-
|
67
|
-
def self.installed?
|
68
|
-
ActiveSupport::Deprecation.warn "Method `Doorkeeper#installed?` has been deprecated without replacement."
|
69
|
-
configured? && database_installed?
|
70
|
-
end
|
71
|
-
|
72
75
|
def self.authenticate(request, methods = Doorkeeper.configuration.access_token_methods)
|
73
76
|
OAuth::Token.authenticate(request, *methods)
|
74
77
|
end
|
@@ -1,27 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators'
|
1
4
|
require 'rails/generators/active_record'
|
2
5
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
module Doorkeeper
|
7
|
+
class ApplicationOwnerGenerator < ::Rails::Generators::Base
|
8
|
+
include ::Rails::Generators::Migration
|
9
|
+
source_root File.expand_path('templates', __dir__)
|
10
|
+
desc 'Provide support for client application ownership.'
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
def application_owner
|
13
|
+
migration_template(
|
14
|
+
'add_owner_to_application_migration.rb.erb',
|
15
|
+
'db/migrate/add_owner_to_application.rb',
|
16
|
+
migration_version: migration_version
|
17
|
+
)
|
18
|
+
end
|
15
19
|
|
16
|
-
|
17
|
-
|
18
|
-
|
20
|
+
def self.next_migration_number(dirname)
|
21
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
22
|
+
end
|
19
23
|
|
20
|
-
|
24
|
+
private
|
21
25
|
|
22
|
-
|
23
|
-
|
24
|
-
|
26
|
+
def migration_version
|
27
|
+
if ActiveRecord::VERSION::MAJOR >= 5
|
28
|
+
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
29
|
+
end
|
25
30
|
end
|
26
31
|
end
|
27
32
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators'
|
4
|
+
require 'rails/generators/active_record'
|
5
|
+
|
6
|
+
module Doorkeeper
|
7
|
+
class ConfidentialApplicationsGenerator < ::Rails::Generators::Base
|
8
|
+
include ::Rails::Generators::Migration
|
9
|
+
source_root File.expand_path('templates', __dir__)
|
10
|
+
desc 'Add confidential column to Doorkeeper applications'
|
11
|
+
|
12
|
+
def pkce
|
13
|
+
migration_template(
|
14
|
+
'add_confidential_to_applications.rb.erb',
|
15
|
+
'db/migrate/add_confidential_to_applications.rb',
|
16
|
+
migration_version: migration_version
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.next_migration_number(dirname)
|
21
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def migration_version
|
27
|
+
if ActiveRecord::VERSION::MAJOR >= 5
|
28
|
+
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,12 +1,20 @@
|
|
1
|
-
|
2
|
-
include Rails::Generators::Migration
|
3
|
-
source_root File.expand_path('../templates', __FILE__)
|
4
|
-
desc 'Installs Doorkeeper.'
|
1
|
+
# frozen_string_literal: true
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
require 'rails/generators'
|
4
|
+
require 'rails/generators/active_record'
|
5
|
+
|
6
|
+
module Doorkeeper
|
7
|
+
class InstallGenerator < ::Rails::Generators::Base
|
8
|
+
include ::Rails::Generators::Migration
|
9
|
+
source_root File.expand_path('templates', __dir__)
|
10
|
+
desc 'Installs Doorkeeper.'
|
11
|
+
|
12
|
+
def install
|
13
|
+
template 'initializer.rb', 'config/initializers/doorkeeper.rb'
|
14
|
+
copy_file File.expand_path('../../../config/locales/en.yml', __dir__),
|
15
|
+
'config/locales/doorkeeper.en.yml'
|
16
|
+
route 'use_doorkeeper'
|
17
|
+
readme 'README'
|
18
|
+
end
|
11
19
|
end
|
12
20
|
end
|
@@ -1,27 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators'
|
1
4
|
require 'rails/generators/active_record'
|
2
5
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
module Doorkeeper
|
7
|
+
class MigrationGenerator < ::Rails::Generators::Base
|
8
|
+
include ::Rails::Generators::Migration
|
9
|
+
source_root File.expand_path('templates', __dir__)
|
10
|
+
desc 'Installs Doorkeeper migration file.'
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
def install
|
13
|
+
migration_template(
|
14
|
+
'migration.rb.erb',
|
15
|
+
'db/migrate/create_doorkeeper_tables.rb',
|
16
|
+
migration_version: migration_version
|
17
|
+
)
|
18
|
+
end
|
15
19
|
|
16
|
-
|
17
|
-
|
18
|
-
|
20
|
+
def self.next_migration_number(dirname)
|
21
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
22
|
+
end
|
19
23
|
|
20
|
-
|
24
|
+
private
|
21
25
|
|
22
|
-
|
23
|
-
|
24
|
-
|
26
|
+
def migration_version
|
27
|
+
if ActiveRecord::VERSION::MAJOR >= 5
|
28
|
+
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
29
|
+
end
|
25
30
|
end
|
26
31
|
end
|
27
32
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators'
|
4
|
+
require 'rails/generators/active_record'
|
5
|
+
|
6
|
+
module Doorkeeper
|
7
|
+
class PkceGenerator < ::Rails::Generators::Base
|
8
|
+
include ::Rails::Generators::Migration
|
9
|
+
source_root File.expand_path('templates', __dir__)
|
10
|
+
desc 'Provide support for PKCE.'
|
11
|
+
|
12
|
+
def pkce
|
13
|
+
migration_template(
|
14
|
+
'enable_pkce_migration.rb.erb',
|
15
|
+
'db/migrate/enable_pkce.rb',
|
16
|
+
migration_version: migration_version
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.next_migration_number(dirname)
|
21
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def migration_version
|
27
|
+
if ActiveRecord::VERSION::MAJOR >= 5
|
28
|
+
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,35 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators'
|
1
4
|
require 'rails/generators/active_record'
|
2
5
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
module Doorkeeper
|
7
|
+
class PreviousRefreshTokenGenerator < ::Rails::Generators::Base
|
8
|
+
include ::Rails::Generators::Migration
|
9
|
+
source_root File.expand_path('templates', __dir__)
|
10
|
+
desc 'Support revoke refresh token on access token use'
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
|
12
|
+
def self.next_migration_number(path)
|
13
|
+
ActiveRecord::Generators::Base.next_migration_number(path)
|
14
|
+
end
|
11
15
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
def previous_refresh_token
|
17
|
+
if no_previous_refresh_token_column?
|
18
|
+
migration_template(
|
19
|
+
'add_previous_refresh_token_to_access_tokens.rb.erb',
|
20
|
+
'db/migrate/add_previous_refresh_token_to_access_tokens.rb'
|
21
|
+
)
|
22
|
+
end
|
18
23
|
end
|
19
|
-
end
|
20
24
|
|
21
|
-
|
25
|
+
private
|
22
26
|
|
23
|
-
|
24
|
-
|
25
|
-
|
27
|
+
def migration_version
|
28
|
+
if ActiveRecord::VERSION::MAJOR >= 5
|
29
|
+
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
30
|
+
end
|
26
31
|
end
|
27
|
-
end
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
def no_previous_refresh_token_column?
|
34
|
+
!ActiveRecord::Base.connection.column_exists?(
|
35
|
+
:oauth_access_tokens,
|
36
|
+
:previous_refresh_token
|
37
|
+
)
|
38
|
+
end
|
34
39
|
end
|
35
40
|
end
|