doorkeeper 5.3.2 → 5.4.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/CHANGELOG.md +84 -2
- data/README.md +6 -4
- data/app/controllers/doorkeeper/applications_controller.rb +4 -4
- data/app/controllers/doorkeeper/authorizations_controller.rb +31 -12
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +2 -2
- data/app/controllers/doorkeeper/tokens_controller.rb +57 -20
- data/app/views/doorkeeper/applications/_form.html.erb +1 -1
- data/app/views/doorkeeper/applications/show.html.erb +19 -2
- data/config/locales/en.yml +3 -1
- data/lib/doorkeeper.rb +106 -79
- data/lib/doorkeeper/config.rb +64 -35
- data/lib/doorkeeper/config/abstract_builder.rb +28 -0
- data/lib/doorkeeper/config/option.rb +28 -14
- data/lib/doorkeeper/engine.rb +1 -1
- data/lib/doorkeeper/grape/helpers.rb +1 -1
- data/lib/doorkeeper/helpers/controller.rb +4 -4
- data/lib/doorkeeper/models/access_grant_mixin.rb +20 -16
- data/lib/doorkeeper/models/access_token_mixin.rb +108 -45
- data/lib/doorkeeper/models/application_mixin.rb +5 -4
- data/lib/doorkeeper/models/concerns/resource_ownerable.rb +47 -0
- data/lib/doorkeeper/models/concerns/revocable.rb +1 -1
- data/lib/doorkeeper/models/concerns/scopes.rb +5 -1
- data/lib/doorkeeper/models/concerns/secret_storable.rb +1 -3
- data/lib/doorkeeper/oauth/authorization/code.rb +15 -6
- data/lib/doorkeeper/oauth/authorization/context.rb +2 -2
- data/lib/doorkeeper/oauth/authorization/token.rb +8 -12
- data/lib/doorkeeper/oauth/authorization/uri_builder.rb +4 -4
- data/lib/doorkeeper/oauth/authorization_code_request.rb +18 -8
- data/lib/doorkeeper/oauth/base_request.rb +11 -19
- data/lib/doorkeeper/oauth/client.rb +1 -1
- data/lib/doorkeeper/oauth/client/credentials.rb +2 -4
- data/lib/doorkeeper/oauth/client_credentials/creator.rb +26 -8
- data/lib/doorkeeper/oauth/client_credentials/issuer.rb +3 -2
- data/lib/doorkeeper/oauth/client_credentials/validator.rb +4 -2
- data/lib/doorkeeper/oauth/client_credentials_request.rb +8 -7
- data/lib/doorkeeper/oauth/code_request.rb +3 -3
- data/lib/doorkeeper/oauth/code_response.rb +6 -2
- data/lib/doorkeeper/oauth/error_response.rb +2 -4
- data/lib/doorkeeper/oauth/helpers/scope_checker.rb +1 -5
- data/lib/doorkeeper/oauth/hooks/context.rb +21 -0
- data/lib/doorkeeper/oauth/invalid_token_response.rb +2 -2
- data/lib/doorkeeper/oauth/password_access_token_request.rb +4 -6
- data/lib/doorkeeper/oauth/pre_authorization.rb +36 -30
- data/lib/doorkeeper/oauth/refresh_token_request.rb +18 -22
- data/lib/doorkeeper/oauth/token.rb +5 -6
- data/lib/doorkeeper/oauth/token_introspection.rb +4 -8
- data/lib/doorkeeper/oauth/token_request.rb +3 -3
- data/lib/doorkeeper/oauth/token_response.rb +1 -1
- data/lib/doorkeeper/orm/active_record.rb +10 -2
- data/lib/doorkeeper/orm/active_record/mixins/access_grant.rb +8 -3
- data/lib/doorkeeper/orm/active_record/mixins/access_token.rb +7 -3
- data/lib/doorkeeper/orm/active_record/mixins/application.rb +20 -16
- data/lib/doorkeeper/rails/routes.rb +13 -17
- data/lib/doorkeeper/rails/routes/abstract_router.rb +35 -0
- data/lib/doorkeeper/rails/routes/mapper.rb +2 -2
- data/lib/doorkeeper/rails/routes/registry.rb +45 -0
- data/lib/doorkeeper/request/refresh_token.rb +2 -1
- data/lib/doorkeeper/request/strategy.rb +2 -2
- data/lib/doorkeeper/server.rb +4 -4
- data/lib/doorkeeper/stale_records_cleaner.rb +4 -4
- data/lib/doorkeeper/version.rb +2 -2
- data/lib/generators/doorkeeper/confidential_applications_generator.rb +1 -1
- data/lib/generators/doorkeeper/enable_polymorphic_resource_owner_generator.rb +39 -0
- data/lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb.erb +2 -0
- data/lib/generators/doorkeeper/templates/add_previous_refresh_token_to_access_tokens.rb.erb +2 -0
- data/lib/generators/doorkeeper/templates/enable_pkce_migration.rb.erb +2 -0
- data/lib/generators/doorkeeper/templates/enable_polymorphic_resource_owner_migration.rb.erb +17 -0
- data/lib/generators/doorkeeper/templates/initializer.rb +39 -3
- data/lib/generators/doorkeeper/templates/migration.rb.erb +14 -5
- metadata +12 -295
- data/Appraisals +0 -40
- data/CODE_OF_CONDUCT.md +0 -46
- data/CONTRIBUTING.md +0 -49
- data/Dangerfile +0 -67
- data/Dockerfile +0 -29
- data/Gemfile +0 -25
- data/NEWS.md +0 -1
- data/RELEASING.md +0 -11
- data/Rakefile +0 -28
- data/SECURITY.md +0 -15
- data/UPGRADE.md +0 -2
- data/bin/console +0 -16
- data/doorkeeper.gemspec +0 -42
- data/gemfiles/rails_5_0.gemfile +0 -18
- data/gemfiles/rails_5_1.gemfile +0 -18
- data/gemfiles/rails_5_2.gemfile +0 -18
- data/gemfiles/rails_6_0.gemfile +0 -18
- data/gemfiles/rails_master.gemfile +0 -18
- data/spec/controllers/application_metal_controller_spec.rb +0 -64
- data/spec/controllers/applications_controller_spec.rb +0 -274
- data/spec/controllers/authorizations_controller_spec.rb +0 -608
- data/spec/controllers/protected_resources_controller_spec.rb +0 -361
- data/spec/controllers/token_info_controller_spec.rb +0 -50
- data/spec/controllers/tokens_controller_spec.rb +0 -498
- data/spec/dummy/Rakefile +0 -9
- data/spec/dummy/app/assets/config/manifest.js +0 -2
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/controllers/custom_authorizations_controller.rb +0 -9
- data/spec/dummy/app/controllers/full_protected_resources_controller.rb +0 -14
- data/spec/dummy/app/controllers/home_controller.rb +0 -18
- data/spec/dummy/app/controllers/metal_controller.rb +0 -13
- data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +0 -13
- data/spec/dummy/app/helpers/application_helper.rb +0 -7
- data/spec/dummy/app/models/user.rb +0 -7
- data/spec/dummy/app/views/home/index.html.erb +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/config.ru +0 -6
- data/spec/dummy/config/application.rb +0 -49
- data/spec/dummy/config/boot.rb +0 -7
- data/spec/dummy/config/database.yml +0 -15
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -31
- data/spec/dummy/config/environments/production.rb +0 -64
- data/spec/dummy/config/environments/test.rb +0 -45
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -9
- data/spec/dummy/config/initializers/doorkeeper.rb +0 -166
- data/spec/dummy/config/initializers/secret_token.rb +0 -10
- data/spec/dummy/config/initializers/session_store.rb +0 -10
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -16
- data/spec/dummy/config/locales/doorkeeper.en.yml +0 -5
- data/spec/dummy/config/routes.rb +0 -13
- data/spec/dummy/db/migrate/20111122132257_create_users.rb +0 -11
- data/spec/dummy/db/migrate/20120312140401_add_password_to_users.rb +0 -7
- data/spec/dummy/db/migrate/20151223192035_create_doorkeeper_tables.rb +0 -69
- data/spec/dummy/db/migrate/20151223200000_add_owner_to_application.rb +0 -9
- data/spec/dummy/db/migrate/20160320211015_add_previous_refresh_token_to_access_tokens.rb +0 -13
- data/spec/dummy/db/migrate/20170822064514_enable_pkce.rb +0 -8
- data/spec/dummy/db/migrate/20180210183654_add_confidential_to_applications.rb +0 -13
- data/spec/dummy/db/schema.rb +0 -68
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -26
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +0 -9
- data/spec/factories.rb +0 -30
- data/spec/generators/application_owner_generator_spec.rb +0 -28
- data/spec/generators/confidential_applications_generator_spec.rb +0 -29
- data/spec/generators/install_generator_spec.rb +0 -36
- data/spec/generators/migration_generator_spec.rb +0 -28
- data/spec/generators/pkce_generator_spec.rb +0 -28
- data/spec/generators/previous_refresh_token_generator_spec.rb +0 -44
- data/spec/generators/templates/routes.rb +0 -4
- data/spec/generators/views_generator_spec.rb +0 -29
- data/spec/grape/grape_integration_spec.rb +0 -137
- data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +0 -26
- data/spec/lib/config_spec.rb +0 -809
- data/spec/lib/doorkeeper_spec.rb +0 -27
- data/spec/lib/models/expirable_spec.rb +0 -61
- data/spec/lib/models/reusable_spec.rb +0 -40
- data/spec/lib/models/revocable_spec.rb +0 -59
- data/spec/lib/models/scopes_spec.rb +0 -53
- data/spec/lib/models/secret_storable_spec.rb +0 -135
- data/spec/lib/oauth/authorization/uri_builder_spec.rb +0 -39
- data/spec/lib/oauth/authorization_code_request_spec.rb +0 -170
- data/spec/lib/oauth/base_request_spec.rb +0 -224
- data/spec/lib/oauth/base_response_spec.rb +0 -45
- data/spec/lib/oauth/client/credentials_spec.rb +0 -90
- data/spec/lib/oauth/client_credentials/creator_spec.rb +0 -134
- data/spec/lib/oauth/client_credentials/issuer_spec.rb +0 -112
- data/spec/lib/oauth/client_credentials/validation_spec.rb +0 -59
- data/spec/lib/oauth/client_credentials_integration_spec.rb +0 -27
- data/spec/lib/oauth/client_credentials_request_spec.rb +0 -107
- data/spec/lib/oauth/client_spec.rb +0 -38
- data/spec/lib/oauth/code_request_spec.rb +0 -46
- data/spec/lib/oauth/code_response_spec.rb +0 -32
- data/spec/lib/oauth/error_response_spec.rb +0 -64
- data/spec/lib/oauth/error_spec.rb +0 -21
- data/spec/lib/oauth/forbidden_token_response_spec.rb +0 -20
- data/spec/lib/oauth/helpers/scope_checker_spec.rb +0 -110
- data/spec/lib/oauth/helpers/unique_token_spec.rb +0 -21
- data/spec/lib/oauth/helpers/uri_checker_spec.rb +0 -262
- data/spec/lib/oauth/invalid_request_response_spec.rb +0 -73
- data/spec/lib/oauth/invalid_token_response_spec.rb +0 -53
- data/spec/lib/oauth/password_access_token_request_spec.rb +0 -190
- data/spec/lib/oauth/pre_authorization_spec.rb +0 -223
- data/spec/lib/oauth/refresh_token_request_spec.rb +0 -177
- data/spec/lib/oauth/scopes_spec.rb +0 -146
- data/spec/lib/oauth/token_request_spec.rb +0 -157
- data/spec/lib/oauth/token_response_spec.rb +0 -84
- data/spec/lib/oauth/token_spec.rb +0 -156
- data/spec/lib/request/strategy_spec.rb +0 -54
- data/spec/lib/secret_storing/base_spec.rb +0 -60
- data/spec/lib/secret_storing/bcrypt_spec.rb +0 -49
- data/spec/lib/secret_storing/plain_spec.rb +0 -44
- data/spec/lib/secret_storing/sha256_hash_spec.rb +0 -48
- data/spec/lib/server_spec.rb +0 -49
- data/spec/lib/stale_records_cleaner_spec.rb +0 -89
- data/spec/models/doorkeeper/access_grant_spec.rb +0 -161
- data/spec/models/doorkeeper/access_token_spec.rb +0 -622
- data/spec/models/doorkeeper/application_spec.rb +0 -482
- data/spec/requests/applications/applications_request_spec.rb +0 -259
- data/spec/requests/applications/authorized_applications_spec.rb +0 -32
- data/spec/requests/endpoints/authorization_spec.rb +0 -91
- data/spec/requests/endpoints/token_spec.rb +0 -75
- data/spec/requests/flows/authorization_code_errors_spec.rb +0 -79
- data/spec/requests/flows/authorization_code_spec.rb +0 -525
- data/spec/requests/flows/client_credentials_spec.rb +0 -166
- data/spec/requests/flows/implicit_grant_errors_spec.rb +0 -46
- data/spec/requests/flows/implicit_grant_spec.rb +0 -91
- data/spec/requests/flows/password_spec.rb +0 -316
- data/spec/requests/flows/refresh_token_spec.rb +0 -233
- data/spec/requests/flows/revoke_token_spec.rb +0 -157
- data/spec/requests/flows/skip_authorization_spec.rb +0 -66
- data/spec/requests/protected_resources/metal_spec.rb +0 -16
- data/spec/requests/protected_resources/private_api_spec.rb +0 -83
- data/spec/routing/custom_controller_routes_spec.rb +0 -133
- data/spec/routing/default_routes_spec.rb +0 -41
- data/spec/routing/scoped_routes_spec.rb +0 -47
- data/spec/spec_helper.rb +0 -54
- data/spec/spec_helper_integration.rb +0 -4
- data/spec/support/dependencies/factory_bot.rb +0 -4
- data/spec/support/doorkeeper_rspec.rb +0 -22
- data/spec/support/helpers/access_token_request_helper.rb +0 -13
- data/spec/support/helpers/authorization_request_helper.rb +0 -43
- data/spec/support/helpers/config_helper.rb +0 -11
- data/spec/support/helpers/model_helper.rb +0 -78
- data/spec/support/helpers/request_spec_helper.rb +0 -110
- data/spec/support/helpers/url_helper.rb +0 -62
- data/spec/support/orm/active_record.rb +0 -5
- data/spec/support/shared/controllers_shared_context.rb +0 -133
- data/spec/support/shared/hashing_shared_context.rb +0 -36
- data/spec/support/shared/models_shared_examples.rb +0 -54
- data/spec/validators/redirect_uri_validator_spec.rb +0 -183
- data/spec/version/version_spec.rb +0 -17
data/config/locales/en.yml
CHANGED
@@ -51,12 +51,14 @@ en:
|
|
51
51
|
title: 'New Application'
|
52
52
|
show:
|
53
53
|
title: 'Application: %{name}'
|
54
|
-
application_id: '
|
54
|
+
application_id: 'UID'
|
55
55
|
secret: 'Secret'
|
56
|
+
secret_hashed: 'Secret hashed'
|
56
57
|
scopes: 'Scopes'
|
57
58
|
confidential: 'Confidential'
|
58
59
|
callback_urls: 'Callback urls'
|
59
60
|
actions: 'Actions'
|
61
|
+
not_defined: 'Not defined'
|
60
62
|
|
61
63
|
authorizations:
|
62
64
|
buttons:
|
data/lib/doorkeeper.rb
CHANGED
@@ -1,89 +1,116 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "doorkeeper/version"
|
4
|
-
require "doorkeeper/engine"
|
5
3
|
require "doorkeeper/config"
|
6
|
-
|
7
|
-
require "doorkeeper/request/strategy"
|
8
|
-
require "doorkeeper/request/authorization_code"
|
9
|
-
require "doorkeeper/request/client_credentials"
|
10
|
-
require "doorkeeper/request/code"
|
11
|
-
require "doorkeeper/request/password"
|
12
|
-
require "doorkeeper/request/refresh_token"
|
13
|
-
require "doorkeeper/request/token"
|
14
|
-
|
15
|
-
require "doorkeeper/errors"
|
16
|
-
require "doorkeeper/server"
|
17
|
-
require "doorkeeper/request"
|
18
|
-
require "doorkeeper/validations"
|
19
|
-
|
20
|
-
require "doorkeeper/oauth/authorization/code"
|
21
|
-
require "doorkeeper/oauth/authorization/context"
|
22
|
-
require "doorkeeper/oauth/authorization/token"
|
23
|
-
require "doorkeeper/oauth/authorization/uri_builder"
|
24
|
-
require "doorkeeper/oauth/helpers/scope_checker"
|
25
|
-
require "doorkeeper/oauth/helpers/uri_checker"
|
26
|
-
require "doorkeeper/oauth/helpers/unique_token"
|
27
|
-
|
28
|
-
require "doorkeeper/oauth"
|
29
|
-
require "doorkeeper/oauth/scopes"
|
30
|
-
require "doorkeeper/oauth/error"
|
31
|
-
require "doorkeeper/oauth/base_response"
|
32
|
-
require "doorkeeper/oauth/code_response"
|
33
|
-
require "doorkeeper/oauth/token_response"
|
34
|
-
require "doorkeeper/oauth/error_response"
|
35
|
-
require "doorkeeper/oauth/pre_authorization"
|
36
|
-
require "doorkeeper/oauth/base_request"
|
37
|
-
require "doorkeeper/oauth/authorization_code_request"
|
38
|
-
require "doorkeeper/oauth/refresh_token_request"
|
39
|
-
require "doorkeeper/oauth/password_access_token_request"
|
40
|
-
|
41
|
-
require "doorkeeper/oauth/client_credentials/validator"
|
42
|
-
require "doorkeeper/oauth/client_credentials/creator"
|
43
|
-
require "doorkeeper/oauth/client_credentials/issuer"
|
44
|
-
require "doorkeeper/oauth/client/credentials"
|
45
|
-
|
46
|
-
require "doorkeeper/oauth/client_credentials_request"
|
47
|
-
require "doorkeeper/oauth/code_request"
|
48
|
-
require "doorkeeper/oauth/token_request"
|
49
|
-
require "doorkeeper/oauth/client"
|
50
|
-
require "doorkeeper/oauth/token"
|
51
|
-
require "doorkeeper/oauth/token_introspection"
|
52
|
-
require "doorkeeper/oauth/invalid_token_response"
|
53
|
-
require "doorkeeper/oauth/forbidden_token_response"
|
54
|
-
require "doorkeeper/oauth/invalid_request_response"
|
55
|
-
require "doorkeeper/oauth/nonstandard"
|
56
|
-
|
57
|
-
require "doorkeeper/secret_storing/base"
|
58
|
-
require "doorkeeper/secret_storing/plain"
|
59
|
-
require "doorkeeper/secret_storing/sha256_hash"
|
60
|
-
require "doorkeeper/secret_storing/bcrypt"
|
61
|
-
|
62
|
-
require "doorkeeper/models/concerns/orderable"
|
63
|
-
require "doorkeeper/models/concerns/scopes"
|
64
|
-
require "doorkeeper/models/concerns/expirable"
|
65
|
-
require "doorkeeper/models/concerns/reusable"
|
66
|
-
require "doorkeeper/models/concerns/revocable"
|
67
|
-
require "doorkeeper/models/concerns/accessible"
|
68
|
-
require "doorkeeper/models/concerns/secret_storable"
|
69
|
-
|
70
|
-
require "doorkeeper/models/access_grant_mixin"
|
71
|
-
require "doorkeeper/models/access_token_mixin"
|
72
|
-
require "doorkeeper/models/application_mixin"
|
73
|
-
|
74
|
-
require "doorkeeper/helpers/controller"
|
75
|
-
|
76
|
-
require "doorkeeper/rails/routes"
|
77
|
-
require "doorkeeper/rails/helpers"
|
78
|
-
|
79
|
-
require "doorkeeper/rake"
|
80
|
-
require "doorkeeper/stale_records_cleaner"
|
81
|
-
|
82
|
-
require "doorkeeper/orm/active_record"
|
4
|
+
require "doorkeeper/engine"
|
83
5
|
|
84
6
|
# Main Doorkeeper namespace.
|
85
7
|
#
|
86
8
|
module Doorkeeper
|
9
|
+
autoload :Errors, "doorkeeper/errors"
|
10
|
+
autoload :OAuth, "doorkeeper/oauth"
|
11
|
+
autoload :Rake, "doorkeeper/rake"
|
12
|
+
autoload :Request, "doorkeeper/request"
|
13
|
+
autoload :Server, "doorkeeper/server"
|
14
|
+
autoload :StaleRecordsCleaner, "doorkeeper/stale_records_cleaner"
|
15
|
+
autoload :Validations, "doorkeeper/validations"
|
16
|
+
autoload :VERSION, "doorkeeper/version"
|
17
|
+
|
18
|
+
autoload :AccessGrantMixin, "doorkeeper/models/access_grant_mixin"
|
19
|
+
autoload :AccessTokenMixin, "doorkeeper/models/access_token_mixin"
|
20
|
+
autoload :ApplicationMixin, "doorkeeper/models/application_mixin"
|
21
|
+
|
22
|
+
module Helpers
|
23
|
+
autoload :Controller, "doorkeeper/helpers/controller"
|
24
|
+
end
|
25
|
+
|
26
|
+
module Request
|
27
|
+
autoload :Strategy, "doorkeeper/request/strategy"
|
28
|
+
autoload :AuthorizationCode, "doorkeeper/request/authorization_code"
|
29
|
+
autoload :ClientCredentials, "doorkeeper/request/client_credentials"
|
30
|
+
autoload :Code, "doorkeeper/request/code"
|
31
|
+
autoload :Password, "doorkeeper/request/password"
|
32
|
+
autoload :RefreshToken, "doorkeeper/request/refresh_token"
|
33
|
+
autoload :Token, "doorkeeper/request/token"
|
34
|
+
end
|
35
|
+
|
36
|
+
module OAuth
|
37
|
+
autoload :BaseRequest, "doorkeeper/oauth/base_request"
|
38
|
+
autoload :AuthorizationCodeRequest, "doorkeeper/oauth/authorization_code_request"
|
39
|
+
autoload :BaseResponse, "doorkeeper/oauth/base_response"
|
40
|
+
autoload :CodeResponse, "doorkeeper/oauth/code_response"
|
41
|
+
autoload :Client, "doorkeeper/oauth/client"
|
42
|
+
autoload :ClientCredentialsRequest, "doorkeeper/oauth/client_credentials_request"
|
43
|
+
autoload :CodeRequest, "doorkeeper/oauth/code_request"
|
44
|
+
autoload :ErrorResponse, "doorkeeper/oauth/error_response"
|
45
|
+
autoload :Error, "doorkeeper/oauth/error"
|
46
|
+
autoload :InvalidTokenResponse, "doorkeeper/oauth/invalid_token_response"
|
47
|
+
autoload :InvalidRequestResponse, "doorkeeper/oauth/invalid_request_response"
|
48
|
+
autoload :ForbiddenTokenResponse, "doorkeeper/oauth/forbidden_token_response"
|
49
|
+
autoload :NonStandard, "doorkeeper/oauth/nonstandard"
|
50
|
+
autoload :PasswordAccessTokenRequest, "doorkeeper/oauth/password_access_token_request"
|
51
|
+
autoload :PreAuthorization, "doorkeeper/oauth/pre_authorization"
|
52
|
+
autoload :RefreshTokenRequest, "doorkeeper/oauth/refresh_token_request"
|
53
|
+
autoload :Scopes, "doorkeeper/oauth/scopes"
|
54
|
+
autoload :Token, "doorkeeper/oauth/token"
|
55
|
+
autoload :TokenIntrospection, "doorkeeper/oauth/token_introspection"
|
56
|
+
autoload :TokenRequest, "doorkeeper/oauth/token_request"
|
57
|
+
autoload :TokenResponse, "doorkeeper/oauth/token_response"
|
58
|
+
|
59
|
+
module Authorization
|
60
|
+
autoload :Code, "doorkeeper/oauth/authorization/code"
|
61
|
+
autoload :Context, "doorkeeper/oauth/authorization/context"
|
62
|
+
autoload :Token, "doorkeeper/oauth/authorization/token"
|
63
|
+
autoload :URIBuilder, "doorkeeper/oauth/authorization/uri_builder"
|
64
|
+
end
|
65
|
+
|
66
|
+
class Client
|
67
|
+
autoload :Credentials, "doorkeeper/oauth/client/credentials"
|
68
|
+
end
|
69
|
+
|
70
|
+
module ClientCredentials
|
71
|
+
autoload :Validator, "doorkeeper/oauth/client_credentials/validator"
|
72
|
+
autoload :Creator, "doorkeeper/oauth/client_credentials/creator"
|
73
|
+
autoload :Issuer, "doorkeeper/oauth/client_credentials/issuer"
|
74
|
+
end
|
75
|
+
|
76
|
+
module Helpers
|
77
|
+
autoload :ScopeChecker, "doorkeeper/oauth/helpers/scope_checker"
|
78
|
+
autoload :URIChecker, "doorkeeper/oauth/helpers/uri_checker"
|
79
|
+
autoload :UniqueToken, "doorkeeper/oauth/helpers/unique_token"
|
80
|
+
end
|
81
|
+
|
82
|
+
module Hooks
|
83
|
+
autoload :Context, "doorkeeper/oauth/hooks/context"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
module Models
|
88
|
+
autoload :Accessible, "doorkeeper/models/concerns/accessible"
|
89
|
+
autoload :Expirable, "doorkeeper/models/concerns/expirable"
|
90
|
+
autoload :Orderable, "doorkeeper/models/concerns/orderable"
|
91
|
+
autoload :Scopes, "doorkeeper/models/concerns/scopes"
|
92
|
+
autoload :Reusable, "doorkeeper/models/concerns/reusable"
|
93
|
+
autoload :ResourceOwnerable, "doorkeeper/models/concerns/resource_ownerable"
|
94
|
+
autoload :Revocable, "doorkeeper/models/concerns/revocable"
|
95
|
+
autoload :SecretStorable, "doorkeeper/models/concerns/secret_storable"
|
96
|
+
end
|
97
|
+
|
98
|
+
module Orm
|
99
|
+
autoload :ActiveRecord, "doorkeeper/orm/active_record"
|
100
|
+
end
|
101
|
+
|
102
|
+
module Rails
|
103
|
+
autoload :Helpers, "doorkeeper/rails/helpers"
|
104
|
+
autoload :Routes, "doorkeeper/rails/routes"
|
105
|
+
end
|
106
|
+
|
107
|
+
module SecretStoring
|
108
|
+
autoload :Base, "doorkeeper/secret_storing/base"
|
109
|
+
autoload :Plain, "doorkeeper/secret_storing/plain"
|
110
|
+
autoload :Sha256Hash, "doorkeeper/secret_storing/sha256_hash"
|
111
|
+
autoload :BCrypt, "doorkeeper/secret_storing/bcrypt"
|
112
|
+
end
|
113
|
+
|
87
114
|
def self.authenticate(request, methods = Doorkeeper.config.access_token_methods)
|
88
115
|
OAuth::Token.authenticate(request, *methods)
|
89
116
|
end
|
data/lib/doorkeeper/config.rb
CHANGED
@@ -1,16 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "doorkeeper/config/option"
|
4
|
+
require "doorkeeper/config/abstract_builder"
|
4
5
|
|
5
6
|
module Doorkeeper
|
7
|
+
# Defines a MissingConfiguration error for a missing Doorkeeper configuration
|
8
|
+
#
|
6
9
|
class MissingConfiguration < StandardError
|
7
|
-
# Defines a MissingConfiguration error for a missing Doorkeeper
|
8
|
-
# configuration
|
9
10
|
def initialize
|
10
11
|
super("Configuration for doorkeeper missing. Do you have doorkeeper initializer?")
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
15
|
+
# Doorkeeper option DSL could be reused in extensions to build their own
|
16
|
+
# configurations. To use the Option DSL gems need to define `builder_class` method
|
17
|
+
# that returns configuration Builder class. This exception raises when they don't
|
18
|
+
# define it.
|
19
|
+
#
|
20
|
+
class MissingConfigurationBuilderClass < StandardError; end
|
21
|
+
|
14
22
|
class << self
|
15
23
|
def configure(&block)
|
16
24
|
@config = Config::Builder.new(&block).build
|
@@ -30,7 +38,7 @@ module Doorkeeper
|
|
30
38
|
@orm_adapter = "doorkeeper/orm/#{configuration.orm}".classify.constantize
|
31
39
|
rescue NameError => e
|
32
40
|
raise e, "ORM adapter not found (#{configuration.orm})", <<-ERROR_MSG.strip_heredoc
|
33
|
-
[
|
41
|
+
[DOORKEEPER] ORM adapter not found (#{configuration.orm}), or there was an error
|
34
42
|
trying to load it.
|
35
43
|
|
36
44
|
You probably need to add the related gem for this adapter to work with
|
@@ -48,17 +56,8 @@ module Doorkeeper
|
|
48
56
|
end
|
49
57
|
|
50
58
|
class Config
|
51
|
-
|
52
|
-
|
53
|
-
@config = Config.new
|
54
|
-
instance_eval(&block)
|
55
|
-
end
|
56
|
-
|
57
|
-
def build
|
58
|
-
@config.validate
|
59
|
-
@config
|
60
|
-
end
|
61
|
-
|
59
|
+
# Default Doorkeeper configuration builder
|
60
|
+
class Builder < AbstractBuilder
|
62
61
|
# Provide support for an owner to be assigned to each registered
|
63
62
|
# application (disabled by default)
|
64
63
|
# Optional parameter confirmation: true (default false) if you want
|
@@ -135,15 +134,6 @@ module Doorkeeper
|
|
135
134
|
@config.instance_variable_set(:@reuse_access_token, true)
|
136
135
|
end
|
137
136
|
|
138
|
-
# Sets the token_reuse_limit
|
139
|
-
# It will be used only when reuse_access_token option in enabled
|
140
|
-
# By default it will be 100
|
141
|
-
# It will be used for token reusablity to some threshold percentage
|
142
|
-
# Rationale: https://github.com/doorkeeper-gem/doorkeeper/issues/1189
|
143
|
-
def token_reuse_limit(percentage)
|
144
|
-
@config.instance_variable_set(:@token_reuse_limit, percentage)
|
145
|
-
end
|
146
|
-
|
147
137
|
# TODO: maybe make it more generic for other flows too?
|
148
138
|
# Only allow one valid access token obtained via client credentials
|
149
139
|
# per client. If a new access token is obtained before the old one
|
@@ -158,6 +148,12 @@ module Doorkeeper
|
|
158
148
|
@config.instance_variable_set(:@api_only, true)
|
159
149
|
end
|
160
150
|
|
151
|
+
# Enables polymorphic Resource Owner association for Access Grant and
|
152
|
+
# Access Token models. Requires additional database columns to be setup.
|
153
|
+
def use_polymorphic_resource_owner
|
154
|
+
@config.instance_variable_set(:@polymorphic_resource_owner, true)
|
155
|
+
end
|
156
|
+
|
161
157
|
# Forbids creating/updating applications with arbitrary scopes that are
|
162
158
|
# not in configuration, i.e. `default_scopes` or `optional_scopes`.
|
163
159
|
# (disabled by default)
|
@@ -219,6 +215,9 @@ module Doorkeeper
|
|
219
215
|
end
|
220
216
|
end
|
221
217
|
|
218
|
+
# Replace with `default: Builder` when we drop support of Rails < 5.2
|
219
|
+
mattr_reader(:builder_class) { Builder }
|
220
|
+
|
222
221
|
extend Option
|
223
222
|
|
224
223
|
option :resource_owner_authenticator,
|
@@ -251,8 +250,8 @@ module Doorkeeper
|
|
251
250
|
end)
|
252
251
|
|
253
252
|
# Hooks for authorization
|
254
|
-
option :before_successful_authorization, default: ->(_context) {}
|
255
|
-
option :after_successful_authorization, default: ->(_context) {}
|
253
|
+
option :before_successful_authorization, default: ->(_controller, _context = nil) {}
|
254
|
+
option :after_successful_authorization, default: ->(_controller, _context = nil) {}
|
256
255
|
# Hooks for strategies responses
|
257
256
|
option :before_successful_strategy_response, default: ->(_request) {}
|
258
257
|
option :after_successful_strategy_response, default: ->(_request, _response) {}
|
@@ -265,11 +264,25 @@ module Doorkeeper
|
|
265
264
|
option :authorization_code_expires_in, default: 600
|
266
265
|
option :orm, default: :active_record
|
267
266
|
option :native_redirect_uri, default: "urn:ietf:wg:oauth:2.0:oob", deprecated: true
|
268
|
-
option :active_record_options, default: {}
|
269
267
|
option :grant_flows, default: %w[authorization_code client_credentials]
|
270
268
|
option :handle_auth_errors, default: :render
|
271
269
|
option :token_lookup_batch_size, default: 10_000
|
272
270
|
|
271
|
+
# Sets the token_reuse_limit
|
272
|
+
# It will be used only when reuse_access_token option in enabled
|
273
|
+
# By default it will be 100
|
274
|
+
# It will be used for token reusablity to some threshold percentage
|
275
|
+
# Rationale: https://github.com/doorkeeper-gem/doorkeeper/issues/1189
|
276
|
+
option :token_reuse_limit, default: 100
|
277
|
+
|
278
|
+
option :active_record_options,
|
279
|
+
default: {},
|
280
|
+
deprecated: { message: "Customize Doorkeeper models instead" }
|
281
|
+
|
282
|
+
# Hook to allow arbitrary user-client authorization
|
283
|
+
option :authorize_resource_owner_for_client,
|
284
|
+
default: ->(_client, _resource_owner) { true }
|
285
|
+
|
273
286
|
# Allows to customize OAuth grant flows that +each+ application support.
|
274
287
|
# You can configure a custom block (or use a class respond to `#call`) that must
|
275
288
|
# return `true` in case Application instance supports requested OAuth grant flow
|
@@ -411,20 +424,32 @@ module Doorkeeper
|
|
411
424
|
:application_secret_fallback_strategy
|
412
425
|
|
413
426
|
# Return the valid subset of this configuration
|
414
|
-
def validate
|
427
|
+
def validate!
|
415
428
|
validate_reuse_access_token_value
|
416
429
|
validate_token_reuse_limit
|
417
430
|
validate_secret_strategies
|
418
431
|
end
|
419
432
|
|
433
|
+
# Doorkeeper Access Token model class.
|
434
|
+
#
|
435
|
+
# @return [ActiveRecord::Base, Mongoid::Document, Sequel::Model]
|
436
|
+
#
|
420
437
|
def access_token_model
|
421
438
|
@access_token_model ||= access_token_class.constantize
|
422
439
|
end
|
423
440
|
|
441
|
+
# Doorkeeper Access Grant model class.
|
442
|
+
#
|
443
|
+
# @return [ActiveRecord::Base, Mongoid::Document, Sequel::Model]
|
444
|
+
#
|
424
445
|
def access_grant_model
|
425
446
|
@access_grant_model ||= access_grant_class.constantize
|
426
447
|
end
|
427
448
|
|
449
|
+
# Doorkeeper Application model class.
|
450
|
+
#
|
451
|
+
# @return [ActiveRecord::Base, Mongoid::Document, Sequel::Model]
|
452
|
+
#
|
428
453
|
def application_model
|
429
454
|
@application_model ||= application_class.constantize
|
430
455
|
end
|
@@ -445,14 +470,6 @@ module Doorkeeper
|
|
445
470
|
end
|
446
471
|
end
|
447
472
|
|
448
|
-
def token_reuse_limit
|
449
|
-
@token_reuse_limit ||= 100
|
450
|
-
end
|
451
|
-
|
452
|
-
def revoke_previous_client_credentials_token
|
453
|
-
@revoke_previous_client_credentials_token || false
|
454
|
-
end
|
455
|
-
|
456
473
|
def resolve_controller(name)
|
457
474
|
config_option = public_send(:"#{name}_controller")
|
458
475
|
controller_name = if config_option.respond_to?(:call)
|
@@ -464,6 +481,10 @@ module Doorkeeper
|
|
464
481
|
controller_name.constantize
|
465
482
|
end
|
466
483
|
|
484
|
+
def revoke_previous_client_credentials_token?
|
485
|
+
option_set? :revoke_previous_client_credentials_token
|
486
|
+
end
|
487
|
+
|
467
488
|
def enforce_configured_scopes?
|
468
489
|
option_set? :enforce_configured_scopes
|
469
490
|
end
|
@@ -472,6 +493,10 @@ module Doorkeeper
|
|
472
493
|
option_set? :enable_application_owner
|
473
494
|
end
|
474
495
|
|
496
|
+
def polymorphic_resource_owner?
|
497
|
+
option_set? :polymorphic_resource_owner
|
498
|
+
end
|
499
|
+
|
475
500
|
def confirm_application_owner?
|
476
501
|
option_set? :confirm_application_owner
|
477
502
|
end
|
@@ -480,6 +505,10 @@ module Doorkeeper
|
|
480
505
|
handle_auth_errors == :raise
|
481
506
|
end
|
482
507
|
|
508
|
+
def application_secret_hashed?
|
509
|
+
instance_variable_defined?(:"@application_secret_strategy")
|
510
|
+
end
|
511
|
+
|
483
512
|
def token_secret_strategy
|
484
513
|
@token_secret_strategy ||= ::Doorkeeper::SecretStoring::Plain
|
485
514
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Doorkeeper
|
4
|
+
class Config
|
5
|
+
# Abstract base class for Doorkeeper and it's extensions configuration
|
6
|
+
# builder. Instantiates and validates gem configuration.
|
7
|
+
#
|
8
|
+
class AbstractBuilder
|
9
|
+
attr_reader :config
|
10
|
+
|
11
|
+
# @param [Class] config class
|
12
|
+
#
|
13
|
+
def initialize(config = Config.new, &block)
|
14
|
+
@config = config
|
15
|
+
instance_eval(&block)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Builds and validates configuration.
|
19
|
+
#
|
20
|
+
# @return [Doorkeeper::Config] config instance
|
21
|
+
#
|
22
|
+
def build
|
23
|
+
@config.validate! if @config.respond_to?(:validate!)
|
24
|
+
@config
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|