doorkeeper 5.3.0 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +97 -1
- data/README.md +6 -4
- data/app/controllers/doorkeeper/applications_controller.rb +7 -7
- data/app/controllers/doorkeeper/authorizations_controller.rb +31 -12
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +3 -3
- 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 +65 -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 +110 -46
- 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/mixins/application.rb +69 -10
- 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 +1 -1
- 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 +47 -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/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 -794
- 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 -404
- 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/Rakefile
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "bundler/setup"
|
|
4
|
-
require "rspec/core/rake_task"
|
|
5
|
-
|
|
6
|
-
desc "Default: run specs."
|
|
7
|
-
task default: :spec
|
|
8
|
-
|
|
9
|
-
desc "Run all specs"
|
|
10
|
-
RSpec::Core::RakeTask.new(:spec) do |config|
|
|
11
|
-
config.verbose = false
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
namespace :doorkeeper do
|
|
15
|
-
desc "Install doorkeeper in dummy app"
|
|
16
|
-
task :install do
|
|
17
|
-
cd "spec/dummy"
|
|
18
|
-
system "bundle exec rails g doorkeeper:install --force"
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
desc "Runs local test server"
|
|
22
|
-
task :server do
|
|
23
|
-
cd "spec/dummy"
|
|
24
|
-
system "bundle exec rails server"
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
Bundler::GemHelper.install_tasks
|
data/SECURITY.md
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# Reporting security issues in Doorkeeper
|
|
2
|
-
|
|
3
|
-
Hello! Thank you for wanting to disclose a possible security
|
|
4
|
-
vulnerability within the Doorkeeper gem! Please follow our disclosure
|
|
5
|
-
policy as outlined below:
|
|
6
|
-
|
|
7
|
-
1. Do NOT open up a GitHub issue with your report. Security reports
|
|
8
|
-
should be kept private until a possible fix is determined.
|
|
9
|
-
2. Send an email to Nikita Bulai at bulaj.nikita AT gmail.com or one of
|
|
10
|
-
the others Doorkeeper maintainers listed in gemspec. You should receive
|
|
11
|
-
a prompt response.
|
|
12
|
-
3. Be patient. Since Doorkeeper is in a stable maintenance phase, we want to
|
|
13
|
-
do as little as possible to rock the boat of the project.
|
|
14
|
-
|
|
15
|
-
Thank you very much for adhering for these policies!
|
data/UPGRADE.md
DELETED
data/bin/console
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require "bundler/setup"
|
|
5
|
-
require "rails/all"
|
|
6
|
-
require "doorkeeper"
|
|
7
|
-
|
|
8
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
|
9
|
-
# with your gem easier. You can also use a different console, if you like.
|
|
10
|
-
|
|
11
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
12
|
-
# require "pry"
|
|
13
|
-
# Pry.start
|
|
14
|
-
|
|
15
|
-
require "irb"
|
|
16
|
-
IRB.start(__FILE__)
|
data/doorkeeper.gemspec
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
$LOAD_PATH.push File.expand_path("lib", __dir__)
|
|
4
|
-
|
|
5
|
-
require "doorkeeper/version"
|
|
6
|
-
|
|
7
|
-
Gem::Specification.new do |gem|
|
|
8
|
-
gem.name = "doorkeeper"
|
|
9
|
-
gem.version = Doorkeeper.gem_version
|
|
10
|
-
gem.authors = ["Felipe Elias Philipp", "Tute Costa", "Jon Moss", "Nikita Bulai"]
|
|
11
|
-
gem.email = %w[bulaj.nikita@gmail.com]
|
|
12
|
-
gem.homepage = "https://github.com/doorkeeper-gem/doorkeeper"
|
|
13
|
-
gem.summary = "OAuth 2 provider for Rails and Grape"
|
|
14
|
-
gem.description = "Doorkeeper is an OAuth 2 provider for Rails and Grape."
|
|
15
|
-
gem.license = "MIT"
|
|
16
|
-
|
|
17
|
-
gem.files = `git ls-files`.split("\n").reject { |file| file.start_with?(".") }
|
|
18
|
-
gem.test_files = `git ls-files -- spec/*`.split("\n")
|
|
19
|
-
gem.require_paths = ["lib"]
|
|
20
|
-
|
|
21
|
-
gem.metadata = {
|
|
22
|
-
"homepage_uri" => "https://github.com/doorkeeper-gem/doorkeeper",
|
|
23
|
-
"changelog_uri" => "https://github.com/doorkeeper-gem/doorkeeper/blob/master/CHANGELOG.md",
|
|
24
|
-
"source_code_uri" => "https://github.com/doorkeeper-gem/doorkeeper",
|
|
25
|
-
"bug_tracker_uri" => "https://github.com/doorkeeper-gem/doorkeeper/issues",
|
|
26
|
-
"documentation_uri" => "https://doorkeeper.gitbook.io/guides/",
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
gem.add_dependency "railties", ">= 5"
|
|
30
|
-
gem.required_ruby_version = ">= 2.4"
|
|
31
|
-
|
|
32
|
-
gem.add_development_dependency "appraisal"
|
|
33
|
-
gem.add_development_dependency "capybara"
|
|
34
|
-
gem.add_development_dependency "coveralls"
|
|
35
|
-
gem.add_development_dependency "danger", "~> 6.0"
|
|
36
|
-
gem.add_development_dependency "database_cleaner", "~> 1.6"
|
|
37
|
-
gem.add_development_dependency "factory_bot", "~> 5.0"
|
|
38
|
-
gem.add_development_dependency "generator_spec", "~> 0.9.3"
|
|
39
|
-
gem.add_development_dependency "grape"
|
|
40
|
-
gem.add_development_dependency "rake", ">= 11.3.0"
|
|
41
|
-
gem.add_development_dependency "rspec-rails"
|
|
42
|
-
end
|
data/gemfiles/rails_5_0.gemfile
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# This file was generated by Appraisal
|
|
2
|
-
|
|
3
|
-
source "https://rubygems.org"
|
|
4
|
-
|
|
5
|
-
gem "rails", "~> 5.0.0"
|
|
6
|
-
gem "rspec-core", git: "https://github.com/rspec/rspec-core.git"
|
|
7
|
-
gem "rspec-expectations", git: "https://github.com/rspec/rspec-expectations.git"
|
|
8
|
-
gem "rspec-mocks", git: "https://github.com/rspec/rspec-mocks.git"
|
|
9
|
-
gem "rspec-rails", "4.0.0.beta3"
|
|
10
|
-
gem "rspec-support", git: "https://github.com/rspec/rspec-support.git"
|
|
11
|
-
gem "rubocop", "~> 0.75"
|
|
12
|
-
gem "rubocop-performance"
|
|
13
|
-
gem "bcrypt", "~> 3.1", require: false
|
|
14
|
-
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
|
15
|
-
gem "sqlite3", "~> 1.3", "< 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
|
|
16
|
-
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw]
|
|
17
|
-
|
|
18
|
-
gemspec path: "../"
|
data/gemfiles/rails_5_1.gemfile
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# This file was generated by Appraisal
|
|
2
|
-
|
|
3
|
-
source "https://rubygems.org"
|
|
4
|
-
|
|
5
|
-
gem "rails", "~> 5.1.0"
|
|
6
|
-
gem "rspec-core", git: "https://github.com/rspec/rspec-core.git"
|
|
7
|
-
gem "rspec-expectations", git: "https://github.com/rspec/rspec-expectations.git"
|
|
8
|
-
gem "rspec-mocks", git: "https://github.com/rspec/rspec-mocks.git"
|
|
9
|
-
gem "rspec-rails", "4.0.0.beta3"
|
|
10
|
-
gem "rspec-support", git: "https://github.com/rspec/rspec-support.git"
|
|
11
|
-
gem "rubocop", "~> 0.75"
|
|
12
|
-
gem "rubocop-performance"
|
|
13
|
-
gem "bcrypt", "~> 3.1", require: false
|
|
14
|
-
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
|
15
|
-
gem "sqlite3", "~> 1.3", "< 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
|
|
16
|
-
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw]
|
|
17
|
-
|
|
18
|
-
gemspec path: "../"
|
data/gemfiles/rails_5_2.gemfile
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# This file was generated by Appraisal
|
|
2
|
-
|
|
3
|
-
source "https://rubygems.org"
|
|
4
|
-
|
|
5
|
-
gem "rails", "~> 5.2.0"
|
|
6
|
-
gem "rspec-core", git: "https://github.com/rspec/rspec-core.git"
|
|
7
|
-
gem "rspec-expectations", git: "https://github.com/rspec/rspec-expectations.git"
|
|
8
|
-
gem "rspec-mocks", git: "https://github.com/rspec/rspec-mocks.git"
|
|
9
|
-
gem "rspec-rails", "4.0.0.beta3"
|
|
10
|
-
gem "rspec-support", git: "https://github.com/rspec/rspec-support.git"
|
|
11
|
-
gem "rubocop", "~> 0.75"
|
|
12
|
-
gem "rubocop-performance"
|
|
13
|
-
gem "bcrypt", "~> 3.1", require: false
|
|
14
|
-
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
|
15
|
-
gem "sqlite3", "~> 1.3", "< 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
|
|
16
|
-
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw]
|
|
17
|
-
|
|
18
|
-
gemspec path: "../"
|
data/gemfiles/rails_6_0.gemfile
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# This file was generated by Appraisal
|
|
2
|
-
|
|
3
|
-
source "https://rubygems.org"
|
|
4
|
-
|
|
5
|
-
gem "rails", "~> 6.0.0"
|
|
6
|
-
gem "rspec-core", git: "https://github.com/rspec/rspec-core.git"
|
|
7
|
-
gem "rspec-expectations", git: "https://github.com/rspec/rspec-expectations.git"
|
|
8
|
-
gem "rspec-mocks", git: "https://github.com/rspec/rspec-mocks.git"
|
|
9
|
-
gem "rspec-rails", "4.0.0.beta3"
|
|
10
|
-
gem "rspec-support", git: "https://github.com/rspec/rspec-support.git"
|
|
11
|
-
gem "rubocop", "~> 0.75"
|
|
12
|
-
gem "rubocop-performance"
|
|
13
|
-
gem "bcrypt", "~> 3.1", require: false
|
|
14
|
-
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
|
15
|
-
gem "sqlite3", "~> 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
|
|
16
|
-
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw]
|
|
17
|
-
|
|
18
|
-
gemspec path: "../"
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# This file was generated by Appraisal
|
|
2
|
-
|
|
3
|
-
source "https://rubygems.org"
|
|
4
|
-
|
|
5
|
-
gem "rails", git: "https://github.com/rails/rails"
|
|
6
|
-
gem "rspec-core", git: "https://github.com/rspec/rspec-core.git"
|
|
7
|
-
gem "rspec-expectations", git: "https://github.com/rspec/rspec-expectations.git"
|
|
8
|
-
gem "rspec-mocks", git: "https://github.com/rspec/rspec-mocks.git"
|
|
9
|
-
gem "rspec-rails", "4.0.0.beta3"
|
|
10
|
-
gem "rspec-support", git: "https://github.com/rspec/rspec-support.git"
|
|
11
|
-
gem "rubocop", "~> 0.75"
|
|
12
|
-
gem "rubocop-performance"
|
|
13
|
-
gem "bcrypt", "~> 3.1", require: false
|
|
14
|
-
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
|
15
|
-
gem "sqlite3", "~> 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
|
|
16
|
-
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw]
|
|
17
|
-
|
|
18
|
-
gemspec path: "../"
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper_integration"
|
|
4
|
-
|
|
5
|
-
describe Doorkeeper::ApplicationMetalController do
|
|
6
|
-
controller(Doorkeeper::ApplicationMetalController) do
|
|
7
|
-
def index
|
|
8
|
-
render json: {}, status: 200
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def create
|
|
12
|
-
render json: {}, status: 200
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "lazy run hooks" do
|
|
17
|
-
i = 0
|
|
18
|
-
ActiveSupport.on_load(:doorkeeper_metal_controller) { i += 1 }
|
|
19
|
-
|
|
20
|
-
expect(i).to eq 1
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
describe "enforce_content_type" do
|
|
24
|
-
before { allow(Doorkeeper.config).to receive(:enforce_content_type).and_return(flag) }
|
|
25
|
-
|
|
26
|
-
context "enabled" do
|
|
27
|
-
let(:flag) { true }
|
|
28
|
-
|
|
29
|
-
it "returns a 200 for the requests without body" do
|
|
30
|
-
get :index, params: {}
|
|
31
|
-
expect(response).to have_http_status 200
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "returns a 200 for the requests with body and correct media type" do
|
|
35
|
-
post :create, params: {}, as: :url_encoded_form
|
|
36
|
-
expect(response).to have_http_status 200
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "returns a 415 for the requests with body and incorrect media type" do
|
|
40
|
-
post :create, params: {}, as: :json
|
|
41
|
-
expect(response).to have_http_status 415
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
context "disabled" do
|
|
46
|
-
let(:flag) { false }
|
|
47
|
-
|
|
48
|
-
it "returns a 200 for the correct media type" do
|
|
49
|
-
get :index, as: :url_encoded_form
|
|
50
|
-
expect(response).to have_http_status 200
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it "returns a 200 for an incorrect media type" do
|
|
54
|
-
get :index, as: :json
|
|
55
|
-
expect(response).to have_http_status 200
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it "returns a 200 for the requests with body and incorrect media type" do
|
|
59
|
-
post :create, params: {}, as: :json
|
|
60
|
-
expect(response).to have_http_status 200
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
module Doorkeeper
|
|
6
|
-
describe ApplicationsController do
|
|
7
|
-
context "JSON API" do
|
|
8
|
-
render_views
|
|
9
|
-
|
|
10
|
-
before do
|
|
11
|
-
allow(Doorkeeper.configuration).to receive(:api_only).and_return(true)
|
|
12
|
-
allow(Doorkeeper.configuration).to receive(:authenticate_admin).and_return(->(*) { true })
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it "creates an application" do
|
|
16
|
-
expect do
|
|
17
|
-
post :create, params: {
|
|
18
|
-
doorkeeper_application: {
|
|
19
|
-
name: "Example",
|
|
20
|
-
redirect_uri: "https://example.com",
|
|
21
|
-
}, format: :json,
|
|
22
|
-
}
|
|
23
|
-
end.to(change { Doorkeeper::Application.count })
|
|
24
|
-
|
|
25
|
-
expect(response).to be_successful
|
|
26
|
-
|
|
27
|
-
expect(json_response).to include("id", "name", "uid", "secret", "redirect_uri", "scopes")
|
|
28
|
-
|
|
29
|
-
application = Application.last
|
|
30
|
-
secret_from_response = json_response["secret"]
|
|
31
|
-
expect(application.secret_matches?(secret_from_response)).to be_truthy
|
|
32
|
-
|
|
33
|
-
expect(json_response["name"]).to eq("Example")
|
|
34
|
-
expect(json_response["redirect_uri"]).to eq("https://example.com")
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it "returns validation errors on wrong create params" do
|
|
38
|
-
expect do
|
|
39
|
-
post :create, params: {
|
|
40
|
-
doorkeeper_application: {
|
|
41
|
-
name: "Example",
|
|
42
|
-
}, format: :json,
|
|
43
|
-
}
|
|
44
|
-
end.not_to(change { Doorkeeper::Application.count })
|
|
45
|
-
|
|
46
|
-
expect(response).to have_http_status(422)
|
|
47
|
-
|
|
48
|
-
expect(json_response).to include("errors")
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "returns validations on wrong create params (unspecified scheme)" do
|
|
52
|
-
expect do
|
|
53
|
-
post :create, params: {
|
|
54
|
-
doorkeeper_application: {
|
|
55
|
-
name: "Example",
|
|
56
|
-
redirect_uri: "app.com:80",
|
|
57
|
-
}, format: :json,
|
|
58
|
-
}
|
|
59
|
-
end.not_to(change { Doorkeeper::Application.count })
|
|
60
|
-
|
|
61
|
-
expect(response).to have_http_status(422)
|
|
62
|
-
|
|
63
|
-
expect(json_response).to include("errors")
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
it "returns application info" do
|
|
67
|
-
application = FactoryBot.create(:application, name: "Change me")
|
|
68
|
-
|
|
69
|
-
get :show, params: { id: application.id, format: :json }
|
|
70
|
-
|
|
71
|
-
expect(response).to be_successful
|
|
72
|
-
|
|
73
|
-
expect(json_response).to include("id", "name", "uid", "secret", "redirect_uri", "scopes")
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
it "updates application" do
|
|
77
|
-
application = FactoryBot.create(:application, name: "Change me")
|
|
78
|
-
|
|
79
|
-
put :update, params: {
|
|
80
|
-
id: application.id,
|
|
81
|
-
doorkeeper_application: {
|
|
82
|
-
name: "Example App",
|
|
83
|
-
redirect_uri: "https://example.com",
|
|
84
|
-
}, format: :json,
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
expect(application.reload.name).to eq "Example App"
|
|
88
|
-
|
|
89
|
-
expect(json_response).to include("id", "name", "uid", "secret", "redirect_uri", "scopes")
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
it "returns validation errors on wrong update params" do
|
|
93
|
-
application = FactoryBot.create(:application, name: "Change me")
|
|
94
|
-
|
|
95
|
-
put :update, params: {
|
|
96
|
-
id: application.id,
|
|
97
|
-
doorkeeper_application: {
|
|
98
|
-
name: "Example App",
|
|
99
|
-
redirect_uri: "localhost:3000",
|
|
100
|
-
}, format: :json,
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
expect(response).to have_http_status(422)
|
|
104
|
-
|
|
105
|
-
expect(json_response).to include("errors")
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
it "destroys an application" do
|
|
109
|
-
application = FactoryBot.create(:application)
|
|
110
|
-
|
|
111
|
-
delete :destroy, params: { id: application.id, format: :json }
|
|
112
|
-
|
|
113
|
-
expect(response).to have_http_status(204)
|
|
114
|
-
expect(Application.count).to be_zero
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
context "when admin is not authenticated" do
|
|
119
|
-
before do
|
|
120
|
-
allow(Doorkeeper.config).to receive(:authenticate_admin).and_return(proc do
|
|
121
|
-
redirect_to main_app.root_url
|
|
122
|
-
end)
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
it "redirects as set in Doorkeeper.authenticate_admin" do
|
|
126
|
-
get :index
|
|
127
|
-
expect(response).to redirect_to(controller.main_app.root_url)
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
it "does not create application" do
|
|
131
|
-
expect do
|
|
132
|
-
post :create, params: {
|
|
133
|
-
doorkeeper_application: {
|
|
134
|
-
name: "Example",
|
|
135
|
-
redirect_uri: "https://example.com",
|
|
136
|
-
},
|
|
137
|
-
}
|
|
138
|
-
end.not_to(change { Doorkeeper::Application.count })
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
context "when admin is authenticated" do
|
|
143
|
-
context "when application secrets are hashed" do
|
|
144
|
-
before do
|
|
145
|
-
allow(Doorkeeper.configuration)
|
|
146
|
-
.to receive(:application_secret_strategy).and_return(Doorkeeper::SecretStoring::Sha256Hash)
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
it "shows the application secret after creating a new application" do
|
|
150
|
-
expect do
|
|
151
|
-
post :create, params: {
|
|
152
|
-
doorkeeper_application: {
|
|
153
|
-
name: "Example",
|
|
154
|
-
redirect_uri: "https://example.com",
|
|
155
|
-
},
|
|
156
|
-
}
|
|
157
|
-
end.to change { Doorkeeper::Application.count }.by(1)
|
|
158
|
-
|
|
159
|
-
application = Application.last
|
|
160
|
-
|
|
161
|
-
secret_from_flash = flash[:application_secret]
|
|
162
|
-
expect(secret_from_flash).not_to be_empty
|
|
163
|
-
expect(application.secret_matches?(secret_from_flash)).to be_truthy
|
|
164
|
-
expect(response).to redirect_to(controller.main_app.oauth_application_url(application.id))
|
|
165
|
-
|
|
166
|
-
get :show, params: { id: application.id, format: :html }
|
|
167
|
-
|
|
168
|
-
# We don't know the application secret here (because its hashed) so we can not assert its text on the page
|
|
169
|
-
# Instead, we read it from the page and then check if it matches the application secret
|
|
170
|
-
code_element = %r{<code.*id="secret".*>(.*)<\/code>}.match(response.body)
|
|
171
|
-
secret_from_page = code_element[1]
|
|
172
|
-
|
|
173
|
-
expect(response.body).to have_selector("code#application_id", text: application.uid)
|
|
174
|
-
expect(response.body).to have_selector("code#secret")
|
|
175
|
-
expect(secret_from_page).not_to be_empty
|
|
176
|
-
expect(application.secret_matches?(secret_from_page)).to be_truthy
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
it "does not show an application secret when application did already exist" do
|
|
180
|
-
application = FactoryBot.create(:application)
|
|
181
|
-
get :show, params: { id: application.id, format: :html }
|
|
182
|
-
|
|
183
|
-
expect(response.body).to have_selector("code#application_id", text: application.uid)
|
|
184
|
-
expect(response.body).to have_selector("code#secret", text: "")
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
it "returns the application details in a json response" do
|
|
188
|
-
expect do
|
|
189
|
-
post :create, params: {
|
|
190
|
-
doorkeeper_application: {
|
|
191
|
-
name: "Example",
|
|
192
|
-
redirect_uri: "https://example.com",
|
|
193
|
-
}, format: :json,
|
|
194
|
-
}
|
|
195
|
-
end.to(change { Doorkeeper::Application.count })
|
|
196
|
-
|
|
197
|
-
expect(response).to be_successful
|
|
198
|
-
|
|
199
|
-
expect(json_response).to include("id", "name", "uid", "secret", "redirect_uri", "scopes")
|
|
200
|
-
|
|
201
|
-
application = Application.last
|
|
202
|
-
secret_from_response = json_response["secret"]
|
|
203
|
-
expect(application.secret_matches?(secret_from_response)).to be_truthy
|
|
204
|
-
|
|
205
|
-
expect(json_response["name"]).to eq("Example")
|
|
206
|
-
expect(json_response["redirect_uri"]).to eq("https://example.com")
|
|
207
|
-
end
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
render_views
|
|
211
|
-
|
|
212
|
-
before do
|
|
213
|
-
allow(Doorkeeper.configuration).to receive(:authenticate_admin).and_return(->(*) { true })
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
it "sorts applications by created_at" do
|
|
217
|
-
first_application = FactoryBot.create(:application)
|
|
218
|
-
second_application = FactoryBot.create(:application)
|
|
219
|
-
expect(Doorkeeper::Application).to receive(:ordered_by).and_call_original
|
|
220
|
-
|
|
221
|
-
get :index
|
|
222
|
-
|
|
223
|
-
expect(response.body).to have_selector("tbody tr:first-child#application_#{first_application.id}")
|
|
224
|
-
expect(response.body).to have_selector("tbody tr:last-child#application_#{second_application.id}")
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
it "creates application" do
|
|
228
|
-
expect do
|
|
229
|
-
post :create, params: {
|
|
230
|
-
doorkeeper_application: {
|
|
231
|
-
name: "Example",
|
|
232
|
-
redirect_uri: "https://example.com",
|
|
233
|
-
},
|
|
234
|
-
}
|
|
235
|
-
end.to change { Doorkeeper::Application.count }.by(1)
|
|
236
|
-
|
|
237
|
-
expect(response).to be_redirect
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
it "shows application details" do
|
|
241
|
-
application = FactoryBot.create(:application)
|
|
242
|
-
get :show, params: { id: application.id, format: :html }
|
|
243
|
-
|
|
244
|
-
expect(response.body).to have_selector("code#application_id", text: application.uid)
|
|
245
|
-
expect(response.body).to have_selector("code#secret", text: application.plaintext_secret)
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
it "does not allow mass assignment of uid or secret" do
|
|
249
|
-
application = FactoryBot.create(:application)
|
|
250
|
-
put :update, params: {
|
|
251
|
-
id: application.id,
|
|
252
|
-
doorkeeper_application: {
|
|
253
|
-
uid: "1A2B3C4D",
|
|
254
|
-
secret: "1A2B3C4D",
|
|
255
|
-
},
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
expect(application.reload.uid).not_to eq "1A2B3C4D"
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
it "updates application" do
|
|
262
|
-
application = FactoryBot.create(:application)
|
|
263
|
-
put :update, params: {
|
|
264
|
-
id: application.id, doorkeeper_application: {
|
|
265
|
-
name: "Example",
|
|
266
|
-
redirect_uri: "https://example.com",
|
|
267
|
-
},
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
expect(application.reload.name).to eq "Example"
|
|
271
|
-
end
|
|
272
|
-
end
|
|
273
|
-
end
|
|
274
|
-
end
|