doorkeeper 4.3.2 → 5.0.0.rc1
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/.gitignore +1 -0
- data/.rubocop.yml +4 -0
- data/.travis.yml +2 -0
- data/Appraisals +2 -2
- data/Gemfile +1 -1
- data/NEWS.md +36 -0
- data/README.md +85 -3
- data/Rakefile +6 -0
- data/app/assets/stylesheets/doorkeeper/admin/application.css +2 -2
- data/app/controllers/doorkeeper/application_controller.rb +4 -3
- data/app/controllers/doorkeeper/application_metal_controller.rb +4 -0
- data/app/controllers/doorkeeper/applications_controller.rb +43 -22
- data/app/controllers/doorkeeper/authorizations_controller.rb +55 -12
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +15 -1
- data/app/controllers/doorkeeper/tokens_controller.rb +2 -6
- data/app/helpers/doorkeeper/dashboard_helper.rb +7 -7
- data/app/validators/redirect_uri_validator.rb +3 -2
- data/app/views/doorkeeper/applications/_delete_form.html.erb +3 -1
- data/app/views/doorkeeper/applications/_form.html.erb +31 -19
- data/app/views/doorkeeper/applications/edit.html.erb +1 -1
- data/app/views/doorkeeper/applications/index.html.erb +18 -6
- data/app/views/doorkeeper/applications/new.html.erb +1 -1
- data/app/views/doorkeeper/applications/show.html.erb +8 -5
- data/app/views/doorkeeper/authorizations/error.html.erb +1 -1
- data/app/views/doorkeeper/authorizations/new.html.erb +4 -0
- data/app/views/layouts/doorkeeper/admin.html.erb +15 -15
- data/config/locales/en.yml +15 -1
- data/gemfiles/rails_5_2.gemfile +1 -1
- data/lib/doorkeeper/config.rb +60 -23
- data/lib/doorkeeper/engine.rb +4 -0
- data/lib/doorkeeper/errors.rb +2 -5
- data/lib/doorkeeper/grape/helpers.rb +1 -1
- data/lib/doorkeeper/helpers/controller.rb +7 -2
- data/lib/doorkeeper/models/access_grant_mixin.rb +56 -0
- data/lib/doorkeeper/models/access_token_mixin.rb +37 -20
- data/lib/doorkeeper/models/application_mixin.rb +8 -1
- data/lib/doorkeeper/models/concerns/scopes.rb +1 -1
- data/lib/doorkeeper/oauth/authorization/code.rb +31 -8
- data/lib/doorkeeper/oauth/authorization/context.rb +15 -0
- data/lib/doorkeeper/oauth/authorization/token.rb +23 -6
- data/lib/doorkeeper/oauth/authorization_code_request.rb +27 -2
- data/lib/doorkeeper/oauth/base_request.rb +18 -8
- data/lib/doorkeeper/oauth/client/credentials.rb +4 -2
- data/lib/doorkeeper/oauth/client_credentials/issuer.rb +6 -1
- data/lib/doorkeeper/oauth/client_credentials/validation.rb +4 -2
- data/lib/doorkeeper/oauth/error_response.rb +11 -3
- data/lib/doorkeeper/oauth/helpers/scope_checker.rb +0 -8
- data/lib/doorkeeper/oauth/helpers/uri_checker.rb +1 -0
- data/lib/doorkeeper/oauth/password_access_token_request.rb +7 -4
- data/lib/doorkeeper/oauth/pre_authorization.rb +45 -13
- data/lib/doorkeeper/oauth/refresh_token_request.rb +6 -1
- data/lib/doorkeeper/oauth/scopes.rb +1 -1
- data/lib/doorkeeper/oauth/token.rb +5 -2
- data/lib/doorkeeper/oauth/token_introspection.rb +2 -2
- data/lib/doorkeeper/oauth/token_response.rb +4 -2
- data/lib/doorkeeper/oauth.rb +13 -0
- data/lib/doorkeeper/orm/active_record/application.rb +14 -0
- data/lib/doorkeeper/orm/active_record/stale_records_cleaner.rb +26 -0
- data/lib/doorkeeper/orm/active_record.rb +2 -0
- data/lib/doorkeeper/rails/helpers.rb +2 -4
- data/lib/doorkeeper/rails/routes.rb +13 -1
- data/lib/doorkeeper/rake/db.rake +40 -0
- data/lib/doorkeeper/rake/setup.rake +6 -0
- data/lib/doorkeeper/rake.rb +14 -0
- data/lib/doorkeeper/request/password.rb +1 -11
- data/lib/doorkeeper/request.rb +28 -28
- data/lib/doorkeeper/version.rb +5 -4
- data/lib/doorkeeper.rb +4 -17
- data/lib/generators/doorkeeper/application_owner_generator.rb +23 -18
- data/lib/generators/doorkeeper/confidential_applications_generator.rb +32 -0
- data/lib/generators/doorkeeper/install_generator.rb +17 -9
- data/lib/generators/doorkeeper/migration_generator.rb +23 -18
- data/lib/generators/doorkeeper/pkce_generator.rb +32 -0
- data/lib/generators/doorkeeper/previous_refresh_token_generator.rb +29 -24
- data/lib/generators/doorkeeper/templates/add_confidential_to_applications.rb.erb +13 -0
- data/lib/generators/doorkeeper/templates/enable_pkce_migration.rb.erb +6 -0
- data/lib/generators/doorkeeper/templates/initializer.rb +60 -9
- data/lib/generators/doorkeeper/templates/migration.rb.erb +1 -0
- data/lib/generators/doorkeeper/views_generator.rb +3 -1
- data/spec/controllers/application_metal_controller_spec.rb +50 -0
- data/spec/controllers/applications_controller_spec.rb +126 -13
- data/spec/controllers/authorizations_controller_spec.rb +250 -15
- data/spec/controllers/protected_resources_controller_spec.rb +16 -16
- data/spec/controllers/token_info_controller_spec.rb +4 -12
- data/spec/controllers/tokens_controller_spec.rb +12 -14
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/config/environments/test.rb +4 -5
- data/spec/dummy/config/initializers/doorkeeper.rb +6 -0
- data/spec/dummy/config/initializers/new_framework_defaults.rb +4 -0
- data/spec/dummy/config/routes.rb +3 -42
- data/spec/dummy/db/migrate/20111122132257_create_users.rb +3 -1
- data/spec/dummy/db/migrate/20120312140401_add_password_to_users.rb +3 -1
- data/spec/dummy/db/migrate/20151223192035_create_doorkeeper_tables.rb +3 -1
- data/spec/dummy/db/migrate/20151223200000_add_owner_to_application.rb +3 -1
- data/spec/dummy/db/migrate/20160320211015_add_previous_refresh_token_to_access_tokens.rb +3 -1
- data/spec/dummy/db/migrate/20170822064514_enable_pkce.rb +6 -0
- data/spec/dummy/db/migrate/20180210183654_add_confidential_to_applications.rb +13 -0
- data/spec/dummy/db/schema.rb +38 -37
- data/spec/generators/application_owner_generator_spec.rb +1 -1
- data/spec/generators/confidential_applications_generator_spec.rb +45 -0
- data/spec/generators/install_generator_spec.rb +1 -1
- data/spec/generators/migration_generator_spec.rb +1 -1
- data/spec/generators/pkce_generator_spec.rb +43 -0
- data/spec/generators/previous_refresh_token_generator_spec.rb +1 -1
- data/spec/generators/views_generator_spec.rb +1 -1
- data/spec/grape/grape_integration_spec.rb +1 -1
- data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +1 -1
- data/spec/lib/config_spec.rb +59 -14
- data/spec/lib/doorkeeper_spec.rb +1 -126
- data/spec/lib/models/expirable_spec.rb +0 -3
- data/spec/lib/models/revocable_spec.rb +0 -2
- data/spec/lib/models/scopes_spec.rb +0 -4
- data/spec/lib/oauth/authorization/uri_builder_spec.rb +0 -4
- data/spec/lib/oauth/authorization_code_request_spec.rb +24 -2
- data/spec/lib/oauth/base_request_spec.rb +16 -2
- data/spec/lib/oauth/base_response_spec.rb +1 -1
- data/spec/lib/oauth/client/credentials_spec.rb +5 -5
- data/spec/lib/oauth/client_credentials/creator_spec.rb +5 -1
- data/spec/lib/oauth/client_credentials/issuer_spec.rb +26 -7
- data/spec/lib/oauth/client_credentials/validation_spec.rb +2 -3
- data/spec/lib/oauth/client_credentials_integration_spec.rb +1 -1
- data/spec/lib/oauth/client_credentials_request_spec.rb +3 -5
- data/spec/lib/oauth/client_spec.rb +0 -3
- data/spec/lib/oauth/code_request_spec.rb +4 -2
- data/spec/lib/oauth/error_response_spec.rb +0 -3
- data/spec/lib/oauth/error_spec.rb +0 -2
- data/spec/lib/oauth/forbidden_token_response_spec.rb +1 -4
- data/spec/lib/oauth/helpers/scope_checker_spec.rb +0 -3
- data/spec/lib/oauth/helpers/unique_token_spec.rb +0 -1
- data/spec/lib/oauth/helpers/uri_checker_spec.rb +5 -2
- data/spec/lib/oauth/invalid_token_response_spec.rb +1 -4
- data/spec/lib/oauth/password_access_token_request_spec.rb +37 -2
- data/spec/lib/oauth/pre_authorization_spec.rb +40 -6
- data/spec/lib/oauth/refresh_token_request_spec.rb +11 -7
- data/spec/lib/oauth/scopes_spec.rb +0 -3
- data/spec/lib/oauth/token_request_spec.rb +4 -5
- data/spec/lib/oauth/token_response_spec.rb +0 -1
- data/spec/lib/oauth/token_spec.rb +37 -14
- data/spec/lib/orm/active_record/stale_records_cleaner_spec.rb +79 -0
- data/spec/lib/request/strategy_spec.rb +0 -1
- data/spec/lib/server_spec.rb +1 -1
- data/spec/models/doorkeeper/access_grant_spec.rb +1 -1
- data/spec/models/doorkeeper/access_token_spec.rb +50 -16
- data/spec/models/doorkeeper/application_spec.rb +51 -6
- data/spec/requests/applications/applications_request_spec.rb +89 -1
- data/spec/requests/applications/authorized_applications_spec.rb +1 -1
- data/spec/requests/endpoints/authorization_spec.rb +1 -1
- data/spec/requests/endpoints/token_spec.rb +7 -5
- data/spec/requests/flows/authorization_code_errors_spec.rb +1 -1
- data/spec/requests/flows/authorization_code_spec.rb +197 -1
- data/spec/requests/flows/client_credentials_spec.rb +46 -6
- data/spec/requests/flows/implicit_grant_errors_spec.rb +1 -1
- data/spec/requests/flows/implicit_grant_spec.rb +38 -11
- data/spec/requests/flows/password_spec.rb +120 -23
- data/spec/requests/flows/refresh_token_spec.rb +2 -2
- data/spec/requests/flows/revoke_token_spec.rb +11 -11
- data/spec/requests/flows/skip_authorization_spec.rb +16 -11
- data/spec/requests/protected_resources/metal_spec.rb +1 -1
- data/spec/requests/protected_resources/private_api_spec.rb +1 -1
- data/spec/routing/custom_controller_routes_spec.rb +59 -7
- data/spec/routing/default_routes_spec.rb +2 -2
- data/spec/routing/scoped_routes_spec.rb +16 -2
- data/spec/spec_helper.rb +54 -3
- data/spec/spec_helper_integration.rb +2 -74
- data/spec/support/doorkeeper_rspec.rb +19 -0
- data/spec/support/helpers/authorization_request_helper.rb +4 -4
- data/spec/support/helpers/request_spec_helper.rb +2 -2
- data/spec/support/helpers/url_helper.rb +7 -3
- data/spec/support/http_method_shim.rb +12 -16
- data/spec/validators/redirect_uri_validator_spec.rb +7 -1
- data/spec/version/version_spec.rb +3 -3
- data/vendor/assets/stylesheets/doorkeeper/bootstrap.min.css +4 -5
- metadata +32 -8
- data/spec/controllers/application_metal_controller.rb +0 -10
- /data/spec/support/dependencies/{factory_girl.rb → factory_bot.rb} +0 -0
|
@@ -3,4 +3,8 @@
|
|
|
3
3
|
# made on earlier versions of Rails are not affected when upgrading.
|
|
4
4
|
if Rails::VERSION::MAJOR >= 5
|
|
5
5
|
Rails.application.config.active_record.belongs_to_required_by_default = true
|
|
6
|
+
|
|
7
|
+
if Rails::VERSION::MINOR >= 2
|
|
8
|
+
Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
|
|
9
|
+
end
|
|
6
10
|
end
|
data/spec/dummy/config/routes.rb
CHANGED
|
@@ -1,52 +1,13 @@
|
|
|
1
1
|
Rails.application.routes.draw do
|
|
2
2
|
use_doorkeeper
|
|
3
|
-
use_doorkeeper scope: 'scope'
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
controllers authorizations: 'custom_authorizations',
|
|
8
|
-
tokens: 'custom_authorizations',
|
|
9
|
-
applications: 'custom_authorizations',
|
|
10
|
-
token_info: 'custom_authorizations'
|
|
11
|
-
|
|
12
|
-
as authorizations: 'custom_auth',
|
|
13
|
-
tokens: 'custom_token',
|
|
14
|
-
token_info: 'custom_token_info'
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
scope 'space' do
|
|
19
|
-
use_doorkeeper do
|
|
20
|
-
controllers authorizations: 'custom_authorizations',
|
|
21
|
-
tokens: 'custom_authorizations',
|
|
22
|
-
applications: 'custom_authorizations',
|
|
23
|
-
token_info: 'custom_authorizations'
|
|
24
|
-
|
|
25
|
-
as authorizations: 'custom_auth',
|
|
26
|
-
tokens: 'custom_token',
|
|
27
|
-
token_info: 'custom_token_info'
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
scope 'outer_space' do
|
|
32
|
-
use_doorkeeper do
|
|
33
|
-
controllers authorizations: 'custom_authorizations',
|
|
34
|
-
tokens: 'custom_authorizations',
|
|
35
|
-
token_info: 'custom_authorizations'
|
|
36
|
-
|
|
37
|
-
as authorizations: 'custom_auth',
|
|
38
|
-
tokens: 'custom_token',
|
|
39
|
-
token_info: 'custom_token_info'
|
|
40
|
-
|
|
41
|
-
skip_controllers :tokens, :applications, :token_info
|
|
42
|
-
end
|
|
43
|
-
end
|
|
4
|
+
resources :semi_protected_resources
|
|
5
|
+
resources :full_protected_resources
|
|
44
6
|
|
|
45
7
|
get 'metal.json' => 'metal#index'
|
|
46
8
|
|
|
47
9
|
get '/callback', to: 'home#callback'
|
|
48
10
|
get '/sign_in', to: 'home#sign_in'
|
|
49
|
-
|
|
50
|
-
resources :full_protected_resources
|
|
11
|
+
|
|
51
12
|
root to: 'home#index'
|
|
52
13
|
end
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class AddOwnerToApplication < ActiveRecord::Migration[4.2]
|
|
2
4
|
def change
|
|
3
5
|
add_column :oauth_applications, :owner_id, :integer, null: true
|
|
4
6
|
add_column :oauth_applications, :owner_type, :string, null: true
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class AddConfidentialToApplications < ActiveRecord::Migration[5.1]
|
|
4
|
+
def change
|
|
5
|
+
add_column(
|
|
6
|
+
:oauth_applications,
|
|
7
|
+
:confidential,
|
|
8
|
+
:boolean,
|
|
9
|
+
null: false,
|
|
10
|
+
default: true # maintaining backwards compatibility: require secrets
|
|
11
|
+
)
|
|
12
|
+
end
|
|
13
|
+
end
|
data/spec/dummy/db/schema.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
1
|
# This file is auto-generated from the current state of the database. Instead
|
|
3
2
|
# of editing this file, please use the migrations feature of Active Record to
|
|
4
3
|
# incrementally modify your database, and then regenerate this schema definition.
|
|
@@ -11,57 +10,59 @@
|
|
|
11
10
|
#
|
|
12
11
|
# It's strongly recommended that you check this file into your version control system.
|
|
13
12
|
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
|
13
|
+
ActiveRecord::Schema.define(version: 20180210183654) do
|
|
15
14
|
|
|
16
15
|
create_table "oauth_access_grants", force: :cascade do |t|
|
|
17
|
-
t.integer
|
|
18
|
-
t.integer
|
|
19
|
-
t.string
|
|
20
|
-
t.integer
|
|
21
|
-
t.text
|
|
22
|
-
t.datetime "created_at",
|
|
16
|
+
t.integer "resource_owner_id", null: false
|
|
17
|
+
t.integer "application_id", null: false
|
|
18
|
+
t.string "token", null: false
|
|
19
|
+
t.integer "expires_in", null: false
|
|
20
|
+
t.text "redirect_uri", null: false
|
|
21
|
+
t.datetime "created_at", null: false
|
|
23
22
|
t.datetime "revoked_at"
|
|
24
|
-
t.string
|
|
23
|
+
t.string "scopes"
|
|
24
|
+
unless ENV['WITHOUT_PKCE']
|
|
25
|
+
t.string "code_challenge"
|
|
26
|
+
t.string "code_challenge_method"
|
|
27
|
+
end
|
|
28
|
+
t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true
|
|
25
29
|
end
|
|
26
30
|
|
|
27
|
-
add_index "oauth_access_grants", ["token"], name: "index_oauth_access_grants_on_token", unique: true
|
|
28
|
-
|
|
29
31
|
create_table "oauth_access_tokens", force: :cascade do |t|
|
|
30
|
-
t.integer
|
|
31
|
-
t.integer
|
|
32
|
-
t.string
|
|
33
|
-
t.string
|
|
34
|
-
t.integer
|
|
32
|
+
t.integer "resource_owner_id"
|
|
33
|
+
t.integer "application_id"
|
|
34
|
+
t.string "token", null: false
|
|
35
|
+
t.string "refresh_token"
|
|
36
|
+
t.integer "expires_in"
|
|
35
37
|
t.datetime "revoked_at"
|
|
36
|
-
t.datetime "created_at",
|
|
37
|
-
t.string
|
|
38
|
-
t.string
|
|
38
|
+
t.datetime "created_at", null: false
|
|
39
|
+
t.string "scopes"
|
|
40
|
+
t.string "previous_refresh_token", default: "", null: false
|
|
41
|
+
t.index ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true
|
|
42
|
+
t.index ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id"
|
|
43
|
+
t.index ["token"], name: "index_oauth_access_tokens_on_token", unique: true
|
|
39
44
|
end
|
|
40
45
|
|
|
41
|
-
add_index "oauth_access_tokens", ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true
|
|
42
|
-
add_index "oauth_access_tokens", ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id"
|
|
43
|
-
add_index "oauth_access_tokens", ["token"], name: "index_oauth_access_tokens_on_token", unique: true
|
|
44
|
-
|
|
45
46
|
create_table "oauth_applications", force: :cascade do |t|
|
|
46
|
-
t.string
|
|
47
|
-
t.string
|
|
48
|
-
t.string
|
|
49
|
-
t.text
|
|
50
|
-
t.string
|
|
51
|
-
t.datetime "created_at"
|
|
52
|
-
t.datetime "updated_at"
|
|
53
|
-
t.integer
|
|
54
|
-
t.string
|
|
47
|
+
t.string "name", null: false
|
|
48
|
+
t.string "uid", null: false
|
|
49
|
+
t.string "secret", null: false
|
|
50
|
+
t.text "redirect_uri", null: false
|
|
51
|
+
t.string "scopes", default: "", null: false
|
|
52
|
+
t.datetime "created_at", null: false
|
|
53
|
+
t.datetime "updated_at", null: false
|
|
54
|
+
t.integer "owner_id"
|
|
55
|
+
t.string "owner_type"
|
|
56
|
+
t.boolean "confidential", default: true, null: false
|
|
57
|
+
t.index ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type"
|
|
58
|
+
t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true
|
|
55
59
|
end
|
|
56
60
|
|
|
57
|
-
add_index "oauth_applications", ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type"
|
|
58
|
-
add_index "oauth_applications", ["uid"], name: "index_oauth_applications_on_uid", unique: true
|
|
59
|
-
|
|
60
61
|
create_table "users", force: :cascade do |t|
|
|
61
|
-
t.string
|
|
62
|
+
t.string "name"
|
|
62
63
|
t.datetime "created_at"
|
|
63
64
|
t.datetime "updated_at"
|
|
64
|
-
t.string
|
|
65
|
+
t.string "password"
|
|
65
66
|
end
|
|
66
67
|
|
|
67
68
|
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'generators/doorkeeper/confidential_applications_generator'
|
|
5
|
+
|
|
6
|
+
describe 'Doorkeeper::ConfidentialApplicationsGenerator' do
|
|
7
|
+
include GeneratorSpec::TestCase
|
|
8
|
+
|
|
9
|
+
tests Doorkeeper::ConfidentialApplicationsGenerator
|
|
10
|
+
destination ::File.expand_path('../tmp/dummy', __FILE__)
|
|
11
|
+
|
|
12
|
+
describe 'after running the generator' do
|
|
13
|
+
before :each do
|
|
14
|
+
prepare_destination
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context 'pre Rails 5.0.0' do
|
|
18
|
+
it 'creates a migration with no version specifier' do
|
|
19
|
+
stub_const("ActiveRecord::VERSION::MAJOR", 4)
|
|
20
|
+
stub_const("ActiveRecord::VERSION::MINOR", 2)
|
|
21
|
+
|
|
22
|
+
run_generator
|
|
23
|
+
|
|
24
|
+
assert_migration 'db/migrate/add_confidential_to_applications.rb' do |migration|
|
|
25
|
+
assert migration.include?("ActiveRecord::Migration\n")
|
|
26
|
+
assert migration.include?(':confidential')
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context 'post Rails 5.0.0' do
|
|
32
|
+
it 'creates a migration with a version specifier' do
|
|
33
|
+
stub_const("ActiveRecord::VERSION::MAJOR", 5)
|
|
34
|
+
stub_const("ActiveRecord::VERSION::MINOR", 0)
|
|
35
|
+
|
|
36
|
+
run_generator
|
|
37
|
+
|
|
38
|
+
assert_migration 'db/migrate/add_confidential_to_applications.rb' do |migration|
|
|
39
|
+
assert migration.include?("ActiveRecord::Migration[5.0]\n")
|
|
40
|
+
assert migration.include?(':confidential')
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'generators/doorkeeper/pkce_generator'
|
|
5
|
+
|
|
6
|
+
describe 'Doorkeeper::PkceGenerator' do
|
|
7
|
+
include GeneratorSpec::TestCase
|
|
8
|
+
|
|
9
|
+
tests Doorkeeper::PkceGenerator
|
|
10
|
+
destination ::File.expand_path('../tmp/dummy', __FILE__)
|
|
11
|
+
|
|
12
|
+
describe 'after running the generator' do
|
|
13
|
+
before :each do
|
|
14
|
+
prepare_destination
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context 'pre Rails 5.0.0' do
|
|
18
|
+
it 'creates a migration with no version specifier' do
|
|
19
|
+
stub_const("ActiveRecord::VERSION::MAJOR", 4)
|
|
20
|
+
stub_const("ActiveRecord::VERSION::MINOR", 2)
|
|
21
|
+
|
|
22
|
+
run_generator
|
|
23
|
+
|
|
24
|
+
assert_migration 'db/migrate/enable_pkce.rb' do |migration|
|
|
25
|
+
assert migration.include?("ActiveRecord::Migration\n")
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context 'post Rails 5.0.0' do
|
|
31
|
+
it 'creates a migration with a version specifier' do
|
|
32
|
+
stub_const("ActiveRecord::VERSION::MAJOR", 5)
|
|
33
|
+
stub_const("ActiveRecord::VERSION::MINOR", 0)
|
|
34
|
+
|
|
35
|
+
run_generator
|
|
36
|
+
|
|
37
|
+
assert_migration 'db/migrate/enable_pkce.rb' do |migration|
|
|
38
|
+
assert migration.include?("ActiveRecord::Migration[5.0]\n")
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
data/spec/lib/config_spec.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Doorkeeper, 'configuration' do
|
|
4
4
|
subject { Doorkeeper.configuration }
|
|
@@ -122,7 +122,7 @@ describe Doorkeeper, 'configuration' do
|
|
|
122
122
|
it 'has all scopes' do
|
|
123
123
|
Doorkeeper.configure do
|
|
124
124
|
orm DOORKEEPER_ORM
|
|
125
|
-
default_scopes
|
|
125
|
+
default_scopes :normal
|
|
126
126
|
optional_scopes :admin
|
|
127
127
|
end
|
|
128
128
|
|
|
@@ -132,7 +132,7 @@ describe Doorkeeper, 'configuration' do
|
|
|
132
132
|
|
|
133
133
|
describe 'use_refresh_token' do
|
|
134
134
|
it 'is false by default' do
|
|
135
|
-
expect(subject.refresh_token_enabled?).to
|
|
135
|
+
expect(subject.refresh_token_enabled?).to eq(false)
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
it 'can change the value' do
|
|
@@ -141,7 +141,7 @@ describe Doorkeeper, 'configuration' do
|
|
|
141
141
|
use_refresh_token
|
|
142
142
|
end
|
|
143
143
|
|
|
144
|
-
expect(subject.refresh_token_enabled?).to
|
|
144
|
+
expect(subject.refresh_token_enabled?).to eq(true)
|
|
145
145
|
end
|
|
146
146
|
|
|
147
147
|
it "does not includes 'refresh_token' in authorization_response_types" do
|
|
@@ -162,6 +162,21 @@ describe Doorkeeper, 'configuration' do
|
|
|
162
162
|
end
|
|
163
163
|
end
|
|
164
164
|
|
|
165
|
+
describe 'enforce_configured_scopes' do
|
|
166
|
+
it 'is false by default' do
|
|
167
|
+
expect(subject.enforce_configured_scopes?).to eq(false)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
it 'can change the value' do
|
|
171
|
+
Doorkeeper.configure do
|
|
172
|
+
orm DOORKEEPER_ORM
|
|
173
|
+
enforce_configured_scopes
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
expect(subject.enforce_configured_scopes?).to eq(true)
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
165
180
|
describe 'client_credentials' do
|
|
166
181
|
it 'has defaults order' do
|
|
167
182
|
expect(subject.client_credentials_methods).to eq([:from_basic, :from_params])
|
|
@@ -179,7 +194,7 @@ describe Doorkeeper, 'configuration' do
|
|
|
179
194
|
|
|
180
195
|
describe 'force_ssl_in_redirect_uri' do
|
|
181
196
|
it 'is true by default in non-development environments' do
|
|
182
|
-
expect(subject.force_ssl_in_redirect_uri).to
|
|
197
|
+
expect(subject.force_ssl_in_redirect_uri).to eq(true)
|
|
183
198
|
end
|
|
184
199
|
|
|
185
200
|
it 'can change the value' do
|
|
@@ -188,7 +203,7 @@ describe Doorkeeper, 'configuration' do
|
|
|
188
203
|
force_ssl_in_redirect_uri(false)
|
|
189
204
|
end
|
|
190
205
|
|
|
191
|
-
expect(subject.force_ssl_in_redirect_uri).to
|
|
206
|
+
expect(subject.force_ssl_in_redirect_uri).to eq(false)
|
|
192
207
|
end
|
|
193
208
|
|
|
194
209
|
it 'can be a callable object' do
|
|
@@ -199,7 +214,7 @@ describe Doorkeeper, 'configuration' do
|
|
|
199
214
|
end
|
|
200
215
|
|
|
201
216
|
expect(subject.force_ssl_in_redirect_uri).to eq(block)
|
|
202
|
-
expect(subject.force_ssl_in_redirect_uri.call).to
|
|
217
|
+
expect(subject.force_ssl_in_redirect_uri.call).to eq(false)
|
|
203
218
|
end
|
|
204
219
|
end
|
|
205
220
|
|
|
@@ -220,7 +235,7 @@ describe Doorkeeper, 'configuration' do
|
|
|
220
235
|
|
|
221
236
|
describe 'forbid_redirect_uri' do
|
|
222
237
|
it 'is false by default' do
|
|
223
|
-
expect(subject.forbid_redirect_uri.call(URI.parse('https://localhost'))).to
|
|
238
|
+
expect(subject.forbid_redirect_uri.call(URI.parse('https://localhost'))).to eq(false)
|
|
224
239
|
end
|
|
225
240
|
|
|
226
241
|
it 'can be a callable object' do
|
|
@@ -231,13 +246,13 @@ describe Doorkeeper, 'configuration' do
|
|
|
231
246
|
end
|
|
232
247
|
|
|
233
248
|
expect(subject.forbid_redirect_uri).to eq(block)
|
|
234
|
-
expect(subject.forbid_redirect_uri.call).to
|
|
249
|
+
expect(subject.forbid_redirect_uri.call).to eq(true)
|
|
235
250
|
end
|
|
236
251
|
end
|
|
237
252
|
|
|
238
253
|
describe 'enable_application_owner' do
|
|
239
254
|
it 'is disabled by default' do
|
|
240
|
-
expect(Doorkeeper.configuration.enable_application_owner?).not_to
|
|
255
|
+
expect(Doorkeeper.configuration.enable_application_owner?).not_to eq(true)
|
|
241
256
|
end
|
|
242
257
|
|
|
243
258
|
context 'when enabled without confirmation' do
|
|
@@ -253,7 +268,7 @@ describe Doorkeeper, 'configuration' do
|
|
|
253
268
|
end
|
|
254
269
|
|
|
255
270
|
it 'Doorkeeper.configuration.confirm_application_owner? returns false' do
|
|
256
|
-
expect(Doorkeeper.configuration.confirm_application_owner?).not_to
|
|
271
|
+
expect(Doorkeeper.configuration.confirm_application_owner?).not_to eq(true)
|
|
257
272
|
end
|
|
258
273
|
end
|
|
259
274
|
|
|
@@ -270,7 +285,7 @@ describe Doorkeeper, 'configuration' do
|
|
|
270
285
|
end
|
|
271
286
|
|
|
272
287
|
it 'Doorkeeper.configuration.confirm_application_owner? returns true' do
|
|
273
|
-
expect(Doorkeeper.configuration.confirm_application_owner?).to
|
|
288
|
+
expect(Doorkeeper.configuration.confirm_application_owner?).to eq(true)
|
|
274
289
|
end
|
|
275
290
|
end
|
|
276
291
|
end
|
|
@@ -299,10 +314,10 @@ describe Doorkeeper, 'configuration' do
|
|
|
299
314
|
it "can change the value" do
|
|
300
315
|
Doorkeeper.configure do
|
|
301
316
|
orm DOORKEEPER_ORM
|
|
302
|
-
grant_flows [
|
|
317
|
+
grant_flows %w[authorization_code implicit]
|
|
303
318
|
end
|
|
304
319
|
|
|
305
|
-
expect(subject.grant_flows).to eq [
|
|
320
|
+
expect(subject.grant_flows).to eq %w[authorization_code implicit]
|
|
306
321
|
end
|
|
307
322
|
|
|
308
323
|
context "when including 'authorization_code'" do
|
|
@@ -434,4 +449,34 @@ describe Doorkeeper, 'configuration' do
|
|
|
434
449
|
end
|
|
435
450
|
end
|
|
436
451
|
end
|
|
452
|
+
|
|
453
|
+
describe "api_only" do
|
|
454
|
+
it "is false by default" do
|
|
455
|
+
expect(subject.api_only).to eq(false)
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
it "can change the value" do
|
|
459
|
+
Doorkeeper.configure do
|
|
460
|
+
orm DOORKEEPER_ORM
|
|
461
|
+
api_only
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
expect(subject.api_only).to eq(true)
|
|
465
|
+
end
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
describe 'strict_content_type' do
|
|
469
|
+
it 'is false by default' do
|
|
470
|
+
expect(subject.enforce_content_type).to eq(false)
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
it "can change the value" do
|
|
474
|
+
Doorkeeper.configure do
|
|
475
|
+
orm DOORKEEPER_ORM
|
|
476
|
+
enforce_content_type
|
|
477
|
+
end
|
|
478
|
+
|
|
479
|
+
expect(subject.enforce_content_type).to eq(true)
|
|
480
|
+
end
|
|
481
|
+
end
|
|
437
482
|
end
|