doorkeeper 5.3.3 → 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 +82 -4
- 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/config/abstract_builder.rb +28 -0
- data/lib/doorkeeper/config/option.rb +28 -14
- data/lib/doorkeeper/config.rb +64 -35
- 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/credentials.rb +2 -4
- data/lib/doorkeeper/oauth/client.rb +1 -1
- 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/mixins/access_grant.rb +8 -3
- data/lib/doorkeeper/orm/active_record/mixins/access_token.rb +7 -3
- data/lib/doorkeeper/orm/active_record.rb +10 -2
- 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/rails/routes.rb +13 -17
- 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/doorkeeper.rb +106 -79
- 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 +13 -296
- 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/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/config.ru +0 -6
- 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/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
|
@@ -12,7 +12,7 @@ module Doorkeeper
|
|
12
12
|
source_root File.expand_path("templates", __dir__)
|
13
13
|
desc "Add confidential column to Doorkeeper applications"
|
14
14
|
|
15
|
-
def
|
15
|
+
def confidential_applications
|
16
16
|
migration_template(
|
17
17
|
"add_confidential_to_applications.rb.erb",
|
18
18
|
"db/migrate/add_confidential_to_applications.rb",
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators"
|
4
|
+
require "rails/generators/active_record"
|
5
|
+
|
6
|
+
module Doorkeeper
|
7
|
+
# Generates migration with polymorphic resource owner required
|
8
|
+
# database columns for Doorkeeper Access Token and Access Grant
|
9
|
+
# models.
|
10
|
+
#
|
11
|
+
class EnablePolymorphicResourceOwnerGenerator < ::Rails::Generators::Base
|
12
|
+
include ::Rails::Generators::Migration
|
13
|
+
source_root File.expand_path("templates", __dir__)
|
14
|
+
desc "Provide support for polymorphic Resource Owner."
|
15
|
+
|
16
|
+
def enable_polymorphic_resource_owner
|
17
|
+
migration_template(
|
18
|
+
"enable_polymorphic_resource_owner_migration.rb.erb",
|
19
|
+
"db/migrate/enable_polymorphic_resource_owner.rb",
|
20
|
+
migration_version: migration_version,
|
21
|
+
)
|
22
|
+
gsub_file(
|
23
|
+
"config/initializers/doorkeeper.rb",
|
24
|
+
"# use_polymorphic_resource_owner",
|
25
|
+
"use_polymorphic_resource_owner",
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.next_migration_number(dirname)
|
30
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def migration_version
|
36
|
+
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class EnablePolymorphicResourceOwner < ActiveRecord::Migration<%= migration_version %>
|
4
|
+
def change
|
5
|
+
add_column :oauth_access_tokens, :resource_owner_type, :string
|
6
|
+
add_column :oauth_access_grants, :resource_owner_type, :string
|
7
|
+
change_column_null :oauth_access_grants, :resource_owner_type, false
|
8
|
+
|
9
|
+
add_index :oauth_access_tokens,
|
10
|
+
[:resource_owner_id, :resource_owner_type],
|
11
|
+
name: 'polymorphic_owner_oauth_access_tokens'
|
12
|
+
|
13
|
+
add_index :oauth_access_grants,
|
14
|
+
[:resource_owner_id, :resource_owner_type],
|
15
|
+
name: 'polymorphic_owner_oauth_access_grants'
|
16
|
+
end
|
17
|
+
end
|
@@ -58,6 +58,23 @@ Doorkeeper.configure do
|
|
58
58
|
# end
|
59
59
|
# end
|
60
60
|
|
61
|
+
# Enables polymorphic Resource Owner association for Access Tokens and Access Grants.
|
62
|
+
# By default this option is disabled.
|
63
|
+
#
|
64
|
+
# Make sure you properly setup you database and have all the required columns (run
|
65
|
+
# `bundle exec rails generate doorkeeper:enable_polymorphic_resource_owner` and execute Rails
|
66
|
+
# migrations).
|
67
|
+
#
|
68
|
+
# If this option enabled, Doorkeeper will store not only Resource Owner primary key
|
69
|
+
# value, but also it's type (class name). See "Polymorphic Associations" section of
|
70
|
+
# Rails guides: https://guides.rubyonrails.org/association_basics.html#polymorphic-associations
|
71
|
+
#
|
72
|
+
# [NOTE] If you apply this option on already existing project don't forget to manually
|
73
|
+
# update `resource_owner_type` column in the database and fix migration template as it will
|
74
|
+
# set NOT NULL constraint for Access Grants table.
|
75
|
+
#
|
76
|
+
# use_polymorphic_resource_owner
|
77
|
+
|
61
78
|
# If you are planning to use Doorkeeper in Rails 5 API-only application, then you might
|
62
79
|
# want to use API mode that will skip all the views management and change the way how
|
63
80
|
# Doorkeeper responds to a requests.
|
@@ -360,6 +377,17 @@ Doorkeeper.configure do
|
|
360
377
|
# client.grant_flows.include?(grant_flow)
|
361
378
|
# end
|
362
379
|
|
380
|
+
# If you need arbitrary Resource Owner-Client authorization you can enable this option
|
381
|
+
# and implement the check your need. Config option must respond to #call and return
|
382
|
+
# true in case resource owner authorized for the specific application or false in other
|
383
|
+
# cases.
|
384
|
+
#
|
385
|
+
# Be default all Resource Owners are authorized to any Client (application).
|
386
|
+
#
|
387
|
+
# authorize_resource_owner_for_client do |client, resource_owner|
|
388
|
+
# resource_owner.admin? || client.owners_whitelist.include?(resource_owner)
|
389
|
+
# end
|
390
|
+
|
363
391
|
# Hook into the strategies' request & response life-cycle in case your
|
364
392
|
# application needs advanced customization or logging:
|
365
393
|
#
|
@@ -372,17 +400,25 @@ Doorkeeper.configure do
|
|
372
400
|
# end
|
373
401
|
|
374
402
|
# Hook into Authorization flow in order to implement Single Sign Out
|
375
|
-
# or add any other functionality.
|
403
|
+
# or add any other functionality. Inside the block you have an access
|
404
|
+
# to `controller` (authorizations controller instance) and `context`
|
405
|
+
# (Doorkeeper::OAuth::Hooks::Context instance) which provides pre auth
|
406
|
+
# or auth objects with issued token based on hook type (before or after).
|
376
407
|
#
|
377
|
-
# before_successful_authorization do |controller|
|
408
|
+
# before_successful_authorization do |controller, context|
|
378
409
|
# Rails.logger.info(controller.request.params.inspect)
|
410
|
+
#
|
411
|
+
# Rails.logger.info(context.pre_auth.inspect)
|
379
412
|
# end
|
380
413
|
#
|
381
|
-
# after_successful_authorization do |controller|
|
414
|
+
# after_successful_authorization do |controller, context|
|
382
415
|
# controller.session[:logout_urls] <<
|
383
416
|
# Doorkeeper::Application
|
384
417
|
# .find_by(controller.request.params.slice(:redirect_uri))
|
385
418
|
# .logout_uri
|
419
|
+
#
|
420
|
+
# Rails.logger.info(context.auth.inspect)
|
421
|
+
# Rails.logger.info(context.issued_token)
|
386
422
|
# end
|
387
423
|
|
388
424
|
# Under some circumstances you might want to have applications auto-approved,
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class CreateDoorkeeperTables < ActiveRecord::Migration<%= migration_version %>
|
2
4
|
def change
|
3
5
|
create_table :oauth_applications do |t|
|
@@ -55,12 +57,19 @@ class CreateDoorkeeperTables < ActiveRecord::Migration<%= migration_version %>
|
|
55
57
|
t.datetime :created_at, null: false
|
56
58
|
t.string :scopes
|
57
59
|
|
58
|
-
#
|
60
|
+
# The authorization server MAY issue a new refresh token, in which case
|
61
|
+
# *the client MUST discard the old refresh token* and replace it with the
|
62
|
+
# new refresh token. The authorization server MAY revoke the old
|
63
|
+
# refresh token after issuing a new refresh token to the client.
|
64
|
+
# @see https://tools.ietf.org/html/rfc6749#section-6
|
65
|
+
#
|
66
|
+
# Doorkeeper implementation: if there is a `previous_refresh_token` column,
|
59
67
|
# refresh tokens will be revoked after a related access token is used.
|
60
|
-
# If there is no previous_refresh_token column,
|
61
|
-
#
|
62
|
-
#
|
63
|
-
# instantly
|
68
|
+
# If there is no `previous_refresh_token` column, previous tokens are
|
69
|
+
# revoked as soon as a new access token is created.
|
70
|
+
#
|
71
|
+
# Comment out this line if you want refresh tokens to be instantly
|
72
|
+
# revoked after use.
|
64
73
|
t.string :previous_refresh_token, null: false, default: ""
|
65
74
|
end
|
66
75
|
|