doorkeeper 5.0.0 → 5.1.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 +5 -5
- data/.hound.yml +2 -1
- data/.rubocop.yml +37 -4
- data/.travis.yml +16 -21
- data/Appraisals +29 -7
- data/Dangerfile +67 -0
- data/Gemfile +19 -5
- data/NEWS.md +107 -10
- data/README.md +75 -470
- data/Rakefile +10 -8
- data/app/controllers/doorkeeper/application_controller.rb +3 -2
- data/app/controllers/doorkeeper/application_metal_controller.rb +4 -13
- data/app/controllers/doorkeeper/applications_controller.rb +21 -7
- data/app/controllers/doorkeeper/authorizations_controller.rb +3 -3
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +2 -0
- data/app/controllers/doorkeeper/token_info_controller.rb +4 -2
- data/app/controllers/doorkeeper/tokens_controller.rb +13 -11
- data/app/helpers/doorkeeper/dashboard_helper.rb +3 -1
- data/app/validators/redirect_uri_validator.rb +7 -2
- data/app/views/doorkeeper/applications/_form.html.erb +6 -0
- data/app/views/doorkeeper/applications/show.html.erb +1 -1
- data/app/views/layouts/doorkeeper/admin.html.erb +5 -3
- data/bin/console +16 -0
- data/config/locales/en.yml +1 -0
- data/doorkeeper.gemspec +28 -24
- data/gemfiles/rails_5_0.gemfile +9 -4
- data/gemfiles/rails_5_1.gemfile +9 -4
- data/gemfiles/rails_5_2.gemfile +10 -5
- data/gemfiles/rails_6_0.gemfile +17 -0
- data/gemfiles/rails_master.gemfile +9 -9
- data/lib/doorkeeper/config/option.rb +64 -0
- data/lib/doorkeeper/config.rb +197 -76
- data/lib/doorkeeper/engine.rb +3 -1
- data/lib/doorkeeper/errors.rb +17 -0
- data/lib/doorkeeper/grape/authorization_decorator.rb +6 -4
- data/lib/doorkeeper/grape/helpers.rb +5 -3
- data/lib/doorkeeper/helpers/controller.rb +5 -2
- data/lib/doorkeeper/models/access_grant_mixin.rb +25 -6
- data/lib/doorkeeper/models/access_token_mixin.rb +68 -22
- data/lib/doorkeeper/models/application_mixin.rb +45 -1
- data/lib/doorkeeper/models/concerns/accessible.rb +2 -0
- data/lib/doorkeeper/models/concerns/expirable.rb +6 -2
- data/lib/doorkeeper/models/concerns/orderable.rb +2 -0
- data/lib/doorkeeper/models/concerns/ownership.rb +3 -6
- data/lib/doorkeeper/models/concerns/reusable.rb +19 -0
- data/lib/doorkeeper/models/concerns/revocable.rb +4 -1
- data/lib/doorkeeper/models/concerns/scopes.rb +7 -1
- data/lib/doorkeeper/models/concerns/secret_storable.rb +108 -0
- data/lib/doorkeeper/oauth/authorization/code.rb +4 -2
- data/lib/doorkeeper/oauth/authorization/context.rb +2 -0
- data/lib/doorkeeper/oauth/authorization/token.rb +14 -7
- data/lib/doorkeeper/oauth/authorization/uri_builder.rb +3 -1
- data/lib/doorkeeper/oauth/authorization_code_request.rb +8 -4
- data/lib/doorkeeper/oauth/base_request.rb +2 -0
- data/lib/doorkeeper/oauth/base_response.rb +2 -0
- data/lib/doorkeeper/oauth/client/credentials.rb +2 -0
- data/lib/doorkeeper/oauth/client.rb +3 -1
- data/lib/doorkeeper/oauth/client_credentials/creator.rb +2 -0
- data/lib/doorkeeper/oauth/client_credentials/issuer.rb +2 -0
- data/lib/doorkeeper/oauth/client_credentials/validation.rb +7 -4
- data/lib/doorkeeper/oauth/client_credentials_request.rb +3 -1
- data/lib/doorkeeper/oauth/code_request.rb +2 -0
- data/lib/doorkeeper/oauth/code_response.rb +4 -2
- data/lib/doorkeeper/oauth/error.rb +2 -0
- data/lib/doorkeeper/oauth/error_response.rb +20 -6
- data/lib/doorkeeper/oauth/forbidden_token_response.rb +10 -3
- data/lib/doorkeeper/oauth/helpers/scope_checker.rb +25 -8
- data/lib/doorkeeper/oauth/helpers/unique_token.rb +15 -1
- data/lib/doorkeeper/oauth/helpers/uri_checker.rb +42 -3
- data/lib/doorkeeper/oauth/invalid_token_response.rb +22 -0
- data/lib/doorkeeper/oauth/password_access_token_request.rb +9 -2
- data/lib/doorkeeper/oauth/pre_authorization.rb +13 -5
- data/lib/doorkeeper/oauth/refresh_token_request.rb +15 -4
- data/lib/doorkeeper/oauth/scopes.rb +7 -3
- data/lib/doorkeeper/oauth/token.rb +4 -2
- data/lib/doorkeeper/oauth/token_introspection.rb +76 -8
- data/lib/doorkeeper/oauth/token_request.rb +2 -0
- data/lib/doorkeeper/oauth/token_response.rb +11 -9
- data/lib/doorkeeper/oauth.rb +5 -5
- data/lib/doorkeeper/orm/active_record/access_grant.rb +27 -13
- data/lib/doorkeeper/orm/active_record/access_token.rb +6 -13
- data/lib/doorkeeper/orm/active_record/application.rb +26 -7
- data/lib/doorkeeper/orm/active_record/stale_records_cleaner.rb +10 -3
- data/lib/doorkeeper/orm/active_record.rb +8 -6
- data/lib/doorkeeper/rails/helpers.rb +5 -1
- data/lib/doorkeeper/rails/routes/mapper.rb +2 -0
- data/lib/doorkeeper/rails/routes/mapping.rb +9 -7
- data/lib/doorkeeper/rails/routes.rb +19 -12
- data/lib/doorkeeper/rake/db.rake +17 -17
- data/lib/doorkeeper/rake.rb +1 -1
- data/lib/doorkeeper/request/authorization_code.rb +2 -0
- data/lib/doorkeeper/request/client_credentials.rb +2 -0
- data/lib/doorkeeper/request/code.rb +2 -0
- data/lib/doorkeeper/request/password.rb +2 -0
- data/lib/doorkeeper/request/refresh_token.rb +2 -0
- data/lib/doorkeeper/request/strategy.rb +2 -0
- data/lib/doorkeeper/request/token.rb +2 -0
- data/lib/doorkeeper/request.rb +3 -1
- data/lib/doorkeeper/secret_storing/base.rb +64 -0
- data/lib/doorkeeper/secret_storing/bcrypt.rb +60 -0
- data/lib/doorkeeper/secret_storing/plain.rb +33 -0
- data/lib/doorkeeper/secret_storing/sha256_hash.rb +26 -0
- data/lib/doorkeeper/server.rb +2 -0
- data/lib/doorkeeper/stale_records_cleaner.rb +20 -0
- data/lib/doorkeeper/validations.rb +2 -0
- data/lib/doorkeeper/version.rb +4 -2
- data/lib/doorkeeper.rb +69 -59
- data/lib/generators/doorkeeper/application_owner_generator.rb +10 -9
- data/lib/generators/doorkeeper/confidential_applications_generator.rb +10 -9
- data/lib/generators/doorkeeper/install_generator.rb +11 -9
- data/lib/generators/doorkeeper/migration_generator.rb +9 -9
- data/lib/generators/doorkeeper/pkce_generator.rb +10 -9
- data/lib/generators/doorkeeper/previous_refresh_token_generator.rb +10 -9
- data/lib/generators/doorkeeper/templates/initializer.rb +138 -13
- data/lib/generators/doorkeeper/templates/migration.rb.erb +17 -10
- data/lib/generators/doorkeeper/views_generator.rb +6 -4
- data/spec/controllers/application_metal_controller_spec.rb +24 -10
- data/spec/controllers/applications_controller_spec.rb +76 -78
- data/spec/controllers/authorizations_controller_spec.rb +189 -142
- data/spec/controllers/protected_resources_controller_spec.rb +111 -67
- data/spec/controllers/token_info_controller_spec.rb +14 -12
- data/spec/controllers/tokens_controller_spec.rb +170 -112
- data/spec/dummy/Rakefile +3 -1
- data/spec/dummy/app/controllers/application_controller.rb +3 -1
- data/spec/dummy/app/controllers/custom_authorizations_controller.rb +3 -1
- data/spec/dummy/app/controllers/full_protected_resources_controller.rb +4 -2
- data/spec/dummy/app/controllers/home_controller.rb +6 -5
- data/spec/dummy/app/controllers/metal_controller.rb +2 -0
- data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +4 -2
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/user.rb +2 -0
- data/spec/dummy/config/application.rb +26 -2
- data/spec/dummy/config/boot.rb +2 -4
- data/spec/dummy/config/environment.rb +1 -1
- data/spec/dummy/config/environments/development.rb +2 -0
- data/spec/dummy/config/environments/production.rb +2 -0
- data/spec/dummy/config/environments/test.rb +4 -2
- data/spec/dummy/config/initializers/backtrace_silencers.rb +2 -0
- data/spec/dummy/config/initializers/doorkeeper.rb +7 -3
- data/spec/dummy/config/initializers/secret_token.rb +3 -1
- data/spec/dummy/config/initializers/session_store.rb +3 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +2 -0
- data/spec/dummy/config.ru +3 -1
- data/spec/dummy/db/migrate/20151223192035_create_doorkeeper_tables.rb +20 -13
- data/spec/dummy/db/migrate/20151223200000_add_owner_to_application.rb +1 -1
- data/spec/dummy/db/migrate/20170822064514_enable_pkce.rb +2 -0
- data/spec/dummy/db/schema.rb +1 -1
- data/spec/dummy/script/rails +7 -4
- data/spec/factories.rb +11 -9
- data/spec/generators/application_owner_generator_spec.rb +13 -26
- data/spec/generators/confidential_applications_generator_spec.rb +12 -28
- data/spec/generators/install_generator_spec.rb +19 -14
- data/spec/generators/migration_generator_spec.rb +13 -26
- data/spec/generators/pkce_generator_spec.rb +11 -26
- data/spec/generators/previous_refresh_token_generator_spec.rb +16 -29
- data/spec/generators/templates/routes.rb +2 -1
- data/spec/generators/views_generator_spec.rb +14 -12
- data/spec/grape/grape_integration_spec.rb +35 -33
- data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +9 -7
- data/spec/lib/config_spec.rb +290 -104
- data/spec/lib/doorkeeper_spec.rb +8 -6
- data/spec/lib/models/expirable_spec.rb +22 -8
- data/spec/lib/models/reusable_spec.rb +40 -0
- data/spec/lib/models/revocable_spec.rb +8 -6
- data/spec/lib/models/scopes_spec.rb +27 -13
- data/spec/lib/models/secret_storable_spec.rb +135 -0
- data/spec/lib/oauth/authorization/uri_builder_spec.rb +17 -15
- data/spec/lib/oauth/authorization_code_request_spec.rb +43 -17
- data/spec/lib/oauth/base_request_spec.rb +24 -12
- data/spec/lib/oauth/base_response_spec.rb +3 -1
- data/spec/lib/oauth/client/credentials_spec.rb +26 -24
- data/spec/lib/oauth/client_credentials/creator_spec.rb +56 -10
- data/spec/lib/oauth/client_credentials/issuer_spec.rb +27 -20
- data/spec/lib/oauth/client_credentials/validation_spec.rb +21 -15
- data/spec/lib/oauth/client_credentials_integration_spec.rb +8 -6
- data/spec/lib/oauth/client_credentials_request_spec.rb +27 -21
- data/spec/lib/oauth/client_spec.rb +15 -13
- data/spec/lib/oauth/code_request_spec.rb +10 -8
- data/spec/lib/oauth/code_response_spec.rb +9 -7
- data/spec/lib/oauth/error_response_spec.rb +19 -11
- data/spec/lib/oauth/error_spec.rb +4 -2
- data/spec/lib/oauth/forbidden_token_response_spec.rb +7 -5
- data/spec/lib/oauth/helpers/scope_checker_spec.rb +68 -31
- data/spec/lib/oauth/helpers/unique_token_spec.rb +8 -6
- data/spec/lib/oauth/helpers/uri_checker_spec.rb +124 -93
- data/spec/lib/oauth/invalid_token_response_spec.rb +3 -1
- data/spec/lib/oauth/password_access_token_request_spec.rb +95 -34
- data/spec/lib/oauth/pre_authorization_spec.rb +80 -54
- data/spec/lib/oauth/refresh_token_request_spec.rb +46 -39
- data/spec/lib/oauth/scopes_spec.rb +63 -61
- data/spec/lib/oauth/token_request_spec.rb +80 -25
- data/spec/lib/oauth/token_response_spec.rb +40 -38
- data/spec/lib/oauth/token_spec.rb +64 -45
- data/spec/lib/request/strategy_spec.rb +3 -1
- data/spec/lib/secret_storing/base_spec.rb +60 -0
- data/spec/lib/secret_storing/bcrypt_spec.rb +49 -0
- data/spec/lib/secret_storing/plain_spec.rb +44 -0
- data/spec/lib/secret_storing/sha256_hash_spec.rb +48 -0
- data/spec/lib/server_spec.rb +20 -18
- data/spec/lib/{orm/active_record/stale_records_cleaner_spec.rb → stale_records_cleaner_spec.rb} +28 -18
- data/spec/models/doorkeeper/access_grant_spec.rb +80 -15
- data/spec/models/doorkeeper/access_token_spec.rb +212 -83
- data/spec/models/doorkeeper/application_spec.rb +146 -49
- data/spec/requests/applications/applications_request_spec.rb +100 -68
- data/spec/requests/applications/authorized_applications_spec.rb +20 -18
- data/spec/requests/endpoints/authorization_spec.rb +27 -25
- data/spec/requests/endpoints/token_spec.rb +38 -36
- data/spec/requests/flows/authorization_code_errors_spec.rb +27 -25
- data/spec/requests/flows/authorization_code_spec.rb +260 -158
- data/spec/requests/flows/client_credentials_spec.rb +54 -52
- data/spec/requests/flows/implicit_grant_errors_spec.rb +11 -9
- data/spec/requests/flows/implicit_grant_spec.rb +27 -25
- data/spec/requests/flows/password_spec.rb +64 -56
- data/spec/requests/flows/refresh_token_spec.rb +91 -32
- data/spec/requests/flows/revoke_token_spec.rb +49 -63
- data/spec/requests/flows/skip_authorization_spec.rb +23 -21
- data/spec/requests/protected_resources/metal_spec.rb +7 -5
- data/spec/requests/protected_resources/private_api_spec.rb +37 -35
- data/spec/routing/custom_controller_routes_spec.rb +71 -65
- data/spec/routing/default_routes_spec.rb +22 -20
- data/spec/routing/scoped_routes_spec.rb +20 -18
- data/spec/spec_helper.rb +15 -13
- data/spec/spec_helper_integration.rb +3 -1
- data/spec/support/dependencies/factory_bot.rb +3 -1
- data/spec/support/doorkeeper_rspec.rb +5 -2
- data/spec/support/helpers/access_token_request_helper.rb +3 -1
- data/spec/support/helpers/authorization_request_helper.rb +4 -2
- data/spec/support/helpers/config_helper.rb +2 -0
- data/spec/support/helpers/model_helper.rb +11 -5
- data/spec/support/helpers/request_spec_helper.rb +5 -3
- data/spec/support/helpers/url_helper.rb +20 -18
- data/spec/support/http_method_shim.rb +4 -9
- data/spec/support/orm/active_record.rb +3 -1
- data/spec/support/shared/controllers_shared_context.rb +68 -10
- data/spec/support/shared/hashing_shared_context.rb +36 -0
- data/spec/support/shared/models_shared_examples.rb +12 -10
- data/spec/validators/redirect_uri_validator_spec.rb +76 -47
- data/spec/version/version_spec.rb +7 -5
- metadata +70 -21
- data/gemfiles/rails_4_2.gemfile +0 -13
- data/spec/dummy/config/initializers/new_framework_defaults.rb +0 -10
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
Doorkeeper.configure do
|
|
2
4
|
# Change the ORM that doorkeeper will use.
|
|
3
5
|
orm DOORKEEPER_ORM
|
|
@@ -5,7 +7,7 @@ Doorkeeper.configure do
|
|
|
5
7
|
# This block will be called to check whether the resource owner is authenticated or not.
|
|
6
8
|
resource_owner_authenticator do
|
|
7
9
|
# Put your resource owner authentication logic here.
|
|
8
|
-
User.where(id: session[:user_id]).first || redirect_to(root_url, alert:
|
|
10
|
+
User.where(id: session[:user_id]).first || redirect_to(root_url, alert: "Needs sign in.")
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
# If you didn't skip applications controller from Doorkeeper routes in your application routes.rb
|
|
@@ -64,8 +66,10 @@ Doorkeeper.configure do
|
|
|
64
66
|
# access_token_methods :from_bearer_authorization, :from_access_token_param, :from_bearer_param
|
|
65
67
|
|
|
66
68
|
# Change the native redirect uri for client apps
|
|
67
|
-
# When clients register with the following redirect uri, they won't be redirected to any server and
|
|
68
|
-
#
|
|
69
|
+
# When clients register with the following redirect uri, they won't be redirected to any server and
|
|
70
|
+
# the authorization code will be displayed within the provider
|
|
71
|
+
# The value can be any string. Use nil to disable this feature.
|
|
72
|
+
# When disabled, clients must provide a valid URL
|
|
69
73
|
# (Similar behaviour: https://developers.google.com/accounts/docs/OAuth2InstalledApp#choosingredirecturi)
|
|
70
74
|
#
|
|
71
75
|
# native_redirect_uri 'urn:ietf:wg:oauth:2.0:oob'
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Be sure to restart your server when you modify this file.
|
|
2
4
|
|
|
3
5
|
# Your secret key for verifying the integrity of signed cookies.
|
|
@@ -5,4 +7,4 @@
|
|
|
5
7
|
# Make sure the secret is at least 30 characters and all random,
|
|
6
8
|
# no regular words or you'll be exposed to dictionary attacks.
|
|
7
9
|
Dummy::Application.config.secret_key_base =
|
|
8
|
-
|
|
10
|
+
"c00157b5a1bb6181792f0f4a8a080485de7bab9987e6cf159"
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Be sure to restart your server when you modify this file.
|
|
2
4
|
|
|
3
|
-
Dummy::Application.config.session_store :cookie_store, key:
|
|
5
|
+
Dummy::Application.config.session_store :cookie_store, key: "_dummy_session"
|
|
4
6
|
|
|
5
7
|
# Use the database for sessions instead of the cookie-based default,
|
|
6
8
|
# which shouldn't be used to store highly confidential information
|
data/spec/dummy/config.ru
CHANGED
|
@@ -3,18 +3,22 @@
|
|
|
3
3
|
class CreateDoorkeeperTables < ActiveRecord::Migration[4.2]
|
|
4
4
|
def change
|
|
5
5
|
create_table :oauth_applications do |t|
|
|
6
|
-
t.string :name,
|
|
7
|
-
t.string :uid,
|
|
8
|
-
t.string :secret,
|
|
6
|
+
t.string :name, null: false
|
|
7
|
+
t.string :uid, null: false
|
|
8
|
+
t.string :secret, null: false
|
|
9
|
+
|
|
10
|
+
# Remove `null: false` if you are planning to use grant flows
|
|
11
|
+
# that doesn't require redirect URI to be used during authorization
|
|
12
|
+
# like Client Credentials flow or Resource Owner Password.
|
|
9
13
|
t.text :redirect_uri, null: false
|
|
10
|
-
t.string :scopes, null: false, default:
|
|
14
|
+
t.string :scopes, null: false, default: ""
|
|
11
15
|
t.timestamps null: false
|
|
12
16
|
end
|
|
13
17
|
|
|
14
18
|
add_index :oauth_applications, :uid, unique: true
|
|
15
19
|
|
|
16
20
|
create_table :oauth_access_grants do |t|
|
|
17
|
-
t.
|
|
21
|
+
t.references :resource_owner, null: false
|
|
18
22
|
t.references :application, null: false
|
|
19
23
|
t.string :token, null: false
|
|
20
24
|
t.integer :expires_in, null: false
|
|
@@ -28,35 +32,38 @@ class CreateDoorkeeperTables < ActiveRecord::Migration[4.2]
|
|
|
28
32
|
add_foreign_key(
|
|
29
33
|
:oauth_access_grants,
|
|
30
34
|
:oauth_applications,
|
|
31
|
-
column: :application_id
|
|
35
|
+
column: :application_id
|
|
32
36
|
)
|
|
33
37
|
|
|
34
38
|
create_table :oauth_access_tokens do |t|
|
|
35
|
-
t.
|
|
36
|
-
t.references :application
|
|
39
|
+
t.references :resource_owner, index: true
|
|
40
|
+
t.references :application, null: false
|
|
37
41
|
|
|
38
42
|
# If you use a custom token generator you may need to change this column
|
|
39
43
|
# from string to text, so that it accepts tokens larger than 255
|
|
40
44
|
# characters. More info on custom token generators in:
|
|
41
45
|
# https://github.com/doorkeeper-gem/doorkeeper/tree/v3.0.0.rc1#custom-access-token-generator
|
|
42
46
|
#
|
|
43
|
-
# t.text
|
|
44
|
-
t.string
|
|
47
|
+
# t.text :token, null: false
|
|
48
|
+
t.string :token, null: false
|
|
45
49
|
|
|
46
50
|
t.string :refresh_token
|
|
47
51
|
t.integer :expires_in
|
|
48
52
|
t.datetime :revoked_at
|
|
49
|
-
t.datetime :created_at,
|
|
53
|
+
t.datetime :created_at, null: false
|
|
50
54
|
t.string :scopes
|
|
51
55
|
end
|
|
52
56
|
|
|
53
57
|
add_index :oauth_access_tokens, :token, unique: true
|
|
54
|
-
add_index :oauth_access_tokens, :resource_owner_id
|
|
55
58
|
add_index :oauth_access_tokens, :refresh_token, unique: true
|
|
56
59
|
add_foreign_key(
|
|
57
60
|
:oauth_access_tokens,
|
|
58
61
|
:oauth_applications,
|
|
59
|
-
column: :application_id
|
|
62
|
+
column: :application_id
|
|
60
63
|
)
|
|
64
|
+
|
|
65
|
+
# Uncomment below to ensure a valid reference to the resource owner's table
|
|
66
|
+
add_foreign_key :oauth_access_grants, :users, column: :resource_owner_id
|
|
67
|
+
add_foreign_key :oauth_access_tokens, :users, column: :resource_owner_id
|
|
61
68
|
end
|
|
62
69
|
end
|
|
@@ -4,6 +4,6 @@ class AddOwnerToApplication < ActiveRecord::Migration[4.2]
|
|
|
4
4
|
def change
|
|
5
5
|
add_column :oauth_applications, :owner_id, :integer, null: true
|
|
6
6
|
add_column :oauth_applications, :owner_type, :string, null: true
|
|
7
|
-
add_index :oauth_applications, [
|
|
7
|
+
add_index :oauth_applications, %i[owner_id owner_type]
|
|
8
8
|
end
|
|
9
9
|
end
|
data/spec/dummy/db/schema.rb
CHANGED
|
@@ -47,7 +47,7 @@ ActiveRecord::Schema.define(version: 20180210183654) do
|
|
|
47
47
|
t.string "name", null: false
|
|
48
48
|
t.string "uid", null: false
|
|
49
49
|
t.string "secret", null: false
|
|
50
|
-
t.text "redirect_uri"
|
|
50
|
+
t.text "redirect_uri"
|
|
51
51
|
t.string "scopes", default: "", null: false
|
|
52
52
|
t.datetime "created_at", null: false
|
|
53
53
|
t.datetime "updated_at", null: false
|
data/spec/dummy/script/rails
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
-
#
|
|
2
|
+
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems
|
|
5
|
+
# installed from the root of your application.
|
|
6
|
+
|
|
7
|
+
APP_PATH = File.expand_path("../config/application", __dir__)
|
|
8
|
+
require File.expand_path("../config/boot", __dir__)
|
|
9
|
+
require "rails/commands"
|
data/spec/factories.rb
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
FactoryBot.define do
|
|
2
|
-
factory :access_grant, class: Doorkeeper::AccessGrant do
|
|
4
|
+
factory :access_grant, class: "Doorkeeper::AccessGrant" do
|
|
3
5
|
sequence(:resource_owner_id) { |n| n }
|
|
4
6
|
application
|
|
5
|
-
redirect_uri
|
|
6
|
-
expires_in 100
|
|
7
|
-
scopes
|
|
7
|
+
redirect_uri { "https://app.com/callback" }
|
|
8
|
+
expires_in { 100 }
|
|
9
|
+
scopes { "public write" }
|
|
8
10
|
end
|
|
9
11
|
|
|
10
|
-
factory :access_token, class: Doorkeeper::AccessToken do
|
|
12
|
+
factory :access_token, class: "Doorkeeper::AccessToken" do
|
|
11
13
|
sequence(:resource_owner_id) { |n| n }
|
|
12
14
|
application
|
|
13
|
-
expires_in 2.hours
|
|
15
|
+
expires_in { 2.hours }
|
|
14
16
|
|
|
15
17
|
factory :clientless_access_token do
|
|
16
|
-
application nil
|
|
18
|
+
application { nil }
|
|
17
19
|
end
|
|
18
20
|
end
|
|
19
21
|
|
|
20
|
-
factory :application, class: Doorkeeper::Application do
|
|
22
|
+
factory :application, class: "Doorkeeper::Application" do
|
|
21
23
|
sequence(:name) { |n| "Application #{n}" }
|
|
22
|
-
redirect_uri
|
|
24
|
+
redirect_uri { "https://app.com/callback" }
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
# do not name this factory :user, otherwise it will conflict with factories
|
|
@@ -1,40 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
require 'generators/doorkeeper/application_owner_generator'
|
|
1
|
+
# frozen_string_literal: true
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require "generators/doorkeeper/application_owner_generator"
|
|
5
|
+
|
|
6
|
+
describe "Doorkeeper::ApplicationOwnerGenerator" do
|
|
5
7
|
include GeneratorSpec::TestCase
|
|
6
8
|
|
|
7
9
|
tests Doorkeeper::ApplicationOwnerGenerator
|
|
8
|
-
destination ::File.expand_path(
|
|
10
|
+
destination ::File.expand_path("../tmp/dummy", __FILE__)
|
|
9
11
|
|
|
10
|
-
describe
|
|
12
|
+
describe "after running the generator" do
|
|
11
13
|
before :each do
|
|
12
14
|
prepare_destination
|
|
13
15
|
end
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
stub_const("ActiveRecord::VERSION::MINOR", 2)
|
|
19
|
-
|
|
20
|
-
run_generator
|
|
21
|
-
|
|
22
|
-
assert_migration 'db/migrate/add_owner_to_application.rb' do |migration|
|
|
23
|
-
assert migration.include?("ActiveRecord::Migration\n")
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
context 'post Rails 5.0.0' do
|
|
29
|
-
it 'creates a migration with a version specifier' do
|
|
30
|
-
stub_const("ActiveRecord::VERSION::MAJOR", 5)
|
|
31
|
-
stub_const("ActiveRecord::VERSION::MINOR", 0)
|
|
17
|
+
it "creates a migration with a version specifier" do
|
|
18
|
+
stub_const("ActiveRecord::VERSION::MAJOR", 5)
|
|
19
|
+
stub_const("ActiveRecord::VERSION::MINOR", 0)
|
|
32
20
|
|
|
33
|
-
|
|
21
|
+
run_generator
|
|
34
22
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
end
|
|
23
|
+
assert_migration "db/migrate/add_owner_to_application.rb" do |migration|
|
|
24
|
+
assert migration.include?("ActiveRecord::Migration[5.0]\n")
|
|
38
25
|
end
|
|
39
26
|
end
|
|
40
27
|
end
|
|
@@ -1,44 +1,28 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require "generators/doorkeeper/confidential_applications_generator"
|
|
5
5
|
|
|
6
|
-
describe
|
|
6
|
+
describe "Doorkeeper::ConfidentialApplicationsGenerator" do
|
|
7
7
|
include GeneratorSpec::TestCase
|
|
8
8
|
|
|
9
9
|
tests Doorkeeper::ConfidentialApplicationsGenerator
|
|
10
|
-
destination ::File.expand_path(
|
|
10
|
+
destination ::File.expand_path("../tmp/dummy", __FILE__)
|
|
11
11
|
|
|
12
|
-
describe
|
|
12
|
+
describe "after running the generator" do
|
|
13
13
|
before :each do
|
|
14
14
|
prepare_destination
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
stub_const("ActiveRecord::VERSION::MINOR", 2)
|
|
17
|
+
it "creates a migration with a version specifier" do
|
|
18
|
+
stub_const("ActiveRecord::VERSION::MAJOR", 5)
|
|
19
|
+
stub_const("ActiveRecord::VERSION::MINOR", 0)
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
run_generator
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
|
23
|
+
assert_migration "db/migrate/add_confidential_to_applications.rb" do |migration|
|
|
24
|
+
assert migration.include?("ActiveRecord::Migration[5.0]\n")
|
|
25
|
+
assert migration.include?(":confidential")
|
|
42
26
|
end
|
|
43
27
|
end
|
|
44
28
|
end
|
|
@@ -1,31 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
require 'generators/doorkeeper/install_generator'
|
|
1
|
+
# frozen_string_literal: true
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require "generators/doorkeeper/install_generator"
|
|
5
|
+
|
|
6
|
+
describe "Doorkeeper::InstallGenerator" do
|
|
5
7
|
include GeneratorSpec::TestCase
|
|
6
8
|
|
|
7
9
|
tests Doorkeeper::InstallGenerator
|
|
8
|
-
destination ::File.expand_path(
|
|
10
|
+
destination ::File.expand_path("../tmp/dummy", __FILE__)
|
|
9
11
|
|
|
10
|
-
describe
|
|
12
|
+
describe "after running the generator" do
|
|
11
13
|
before :each do
|
|
12
14
|
prepare_destination
|
|
13
|
-
FileUtils.mkdir(::File.expand_path(
|
|
14
|
-
FileUtils.mkdir(::File.expand_path(
|
|
15
|
-
FileUtils.copy_file(
|
|
15
|
+
FileUtils.mkdir(::File.expand_path("config", Pathname(destination_root)))
|
|
16
|
+
FileUtils.mkdir(::File.expand_path("db", Pathname(destination_root)))
|
|
17
|
+
FileUtils.copy_file(
|
|
18
|
+
::File.expand_path("../templates/routes.rb", __FILE__),
|
|
19
|
+
::File.expand_path("config/routes.rb", Pathname.new(destination_root))
|
|
20
|
+
)
|
|
16
21
|
run_generator
|
|
17
22
|
end
|
|
18
23
|
|
|
19
|
-
it
|
|
20
|
-
assert_file
|
|
24
|
+
it "creates an initializer file" do
|
|
25
|
+
assert_file "config/initializers/doorkeeper.rb"
|
|
21
26
|
end
|
|
22
27
|
|
|
23
|
-
it
|
|
24
|
-
assert_file
|
|
28
|
+
it "copies the locale file" do
|
|
29
|
+
assert_file "config/locales/doorkeeper.en.yml"
|
|
25
30
|
end
|
|
26
31
|
|
|
27
|
-
it
|
|
28
|
-
assert_file
|
|
32
|
+
it "adds sample route" do
|
|
33
|
+
assert_file "config/routes.rb", /use_doorkeeper/
|
|
29
34
|
end
|
|
30
35
|
end
|
|
31
36
|
end
|
|
@@ -1,40 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
require 'generators/doorkeeper/migration_generator'
|
|
1
|
+
# frozen_string_literal: true
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require "generators/doorkeeper/migration_generator"
|
|
5
|
+
|
|
6
|
+
describe "Doorkeeper::MigrationGenerator" do
|
|
5
7
|
include GeneratorSpec::TestCase
|
|
6
8
|
|
|
7
9
|
tests Doorkeeper::MigrationGenerator
|
|
8
|
-
destination ::File.expand_path(
|
|
10
|
+
destination ::File.expand_path("../tmp/dummy", __FILE__)
|
|
9
11
|
|
|
10
|
-
describe
|
|
12
|
+
describe "after running the generator" do
|
|
11
13
|
before :each do
|
|
12
14
|
prepare_destination
|
|
13
15
|
end
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
stub_const('ActiveRecord::VERSION::MINOR', 2)
|
|
19
|
-
|
|
20
|
-
run_generator
|
|
21
|
-
|
|
22
|
-
assert_migration 'db/migrate/create_doorkeeper_tables.rb' do |migration|
|
|
23
|
-
assert migration.include?("ActiveRecord::Migration\n")
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
context 'post Rails 5.0.0' do
|
|
29
|
-
it 'creates a migration with a version specifier' do
|
|
30
|
-
stub_const('ActiveRecord::VERSION::MAJOR', 5)
|
|
31
|
-
stub_const('ActiveRecord::VERSION::MINOR', 0)
|
|
17
|
+
it "creates a migration with a version specifier" do
|
|
18
|
+
stub_const("ActiveRecord::VERSION::MAJOR", 5)
|
|
19
|
+
stub_const("ActiveRecord::VERSION::MINOR", 0)
|
|
32
20
|
|
|
33
|
-
|
|
21
|
+
run_generator
|
|
34
22
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
end
|
|
23
|
+
assert_migration "db/migrate/create_doorkeeper_tables.rb" do |migration|
|
|
24
|
+
assert migration.include?("ActiveRecord::Migration[5.0]\n")
|
|
38
25
|
end
|
|
39
26
|
end
|
|
40
27
|
end
|
|
@@ -1,42 +1,27 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require "generators/doorkeeper/pkce_generator"
|
|
5
5
|
|
|
6
|
-
describe
|
|
6
|
+
describe "Doorkeeper::PkceGenerator" do
|
|
7
7
|
include GeneratorSpec::TestCase
|
|
8
8
|
|
|
9
9
|
tests Doorkeeper::PkceGenerator
|
|
10
|
-
destination ::File.expand_path(
|
|
10
|
+
destination ::File.expand_path("../tmp/dummy", __FILE__)
|
|
11
11
|
|
|
12
|
-
describe
|
|
12
|
+
describe "after running the generator" do
|
|
13
13
|
before :each do
|
|
14
14
|
prepare_destination
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
stub_const("ActiveRecord::VERSION::MINOR", 2)
|
|
17
|
+
it "creates a migration with a version specifier" do
|
|
18
|
+
stub_const("ActiveRecord::VERSION::MAJOR", 5)
|
|
19
|
+
stub_const("ActiveRecord::VERSION::MINOR", 0)
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
run_generator
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
23
|
+
assert_migration "db/migrate/enable_pkce.rb" do |migration|
|
|
24
|
+
assert migration.include?("ActiveRecord::Migration[5.0]\n")
|
|
40
25
|
end
|
|
41
26
|
end
|
|
42
27
|
end
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
require 'generators/doorkeeper/previous_refresh_token_generator'
|
|
1
|
+
# frozen_string_literal: true
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require "generators/doorkeeper/previous_refresh_token_generator"
|
|
5
|
+
|
|
6
|
+
describe "Doorkeeper::PreviousRefreshTokenGenerator" do
|
|
5
7
|
include GeneratorSpec::TestCase
|
|
6
8
|
|
|
7
9
|
tests Doorkeeper::PreviousRefreshTokenGenerator
|
|
8
|
-
destination ::File.expand_path(
|
|
10
|
+
destination ::File.expand_path("../tmp/dummy", __FILE__)
|
|
9
11
|
|
|
10
|
-
describe
|
|
12
|
+
describe "after running the generator" do
|
|
11
13
|
before :each do
|
|
12
14
|
prepare_destination
|
|
13
15
|
|
|
@@ -16,41 +18,26 @@ describe 'Doorkeeper::PreviousRefreshTokenGenerator' do
|
|
|
16
18
|
)
|
|
17
19
|
end
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
stub_const('ActiveRecord::VERSION::MINOR', 2)
|
|
23
|
-
|
|
24
|
-
run_generator
|
|
25
|
-
|
|
26
|
-
assert_migration 'db/migrate/add_previous_refresh_token_to_access_tokens.rb' do |migration|
|
|
27
|
-
assert migration.include?("ActiveRecord::Migration\n")
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
context 'post Rails 5.0.0' do
|
|
33
|
-
it 'creates a migration with a version specifier' do
|
|
34
|
-
stub_const('ActiveRecord::VERSION::MAJOR', 5)
|
|
35
|
-
stub_const('ActiveRecord::VERSION::MINOR', 0)
|
|
21
|
+
it "creates a migration with a version specifier" do
|
|
22
|
+
stub_const("ActiveRecord::VERSION::MAJOR", 5)
|
|
23
|
+
stub_const("ActiveRecord::VERSION::MINOR", 0)
|
|
36
24
|
|
|
37
|
-
|
|
25
|
+
run_generator
|
|
38
26
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
end
|
|
27
|
+
assert_migration "db/migrate/add_previous_refresh_token_to_access_tokens.rb" do |migration|
|
|
28
|
+
assert migration.include?("ActiveRecord::Migration[5.0]\n")
|
|
42
29
|
end
|
|
43
30
|
end
|
|
44
31
|
|
|
45
|
-
context
|
|
46
|
-
it
|
|
32
|
+
context "already exist" do
|
|
33
|
+
it "does not create a migration" do
|
|
47
34
|
allow_any_instance_of(Doorkeeper::PreviousRefreshTokenGenerator).to(
|
|
48
35
|
receive(:no_previous_refresh_token_column?).and_call_original
|
|
49
36
|
)
|
|
50
37
|
|
|
51
38
|
run_generator
|
|
52
39
|
|
|
53
|
-
assert_no_migration
|
|
40
|
+
assert_no_migration "db/migrate/add_previous_refresh_token_to_access_tokens.rb"
|
|
54
41
|
end
|
|
55
42
|
end
|
|
56
43
|
end
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require "generators/doorkeeper/views_generator"
|
|
3
5
|
|
|
4
6
|
describe Doorkeeper::Generators::ViewsGenerator do
|
|
5
7
|
include GeneratorSpec::TestCase
|
|
6
8
|
|
|
7
9
|
tests Doorkeeper::Generators::ViewsGenerator
|
|
8
|
-
destination File.expand_path(
|
|
10
|
+
destination File.expand_path("tmp/dummy", __dir__)
|
|
9
11
|
|
|
10
12
|
before :each do
|
|
11
13
|
prepare_destination
|
|
12
14
|
end
|
|
13
15
|
|
|
14
|
-
it
|
|
16
|
+
it "create all views" do
|
|
15
17
|
run_generator
|
|
16
|
-
assert_file
|
|
17
|
-
assert_file
|
|
18
|
-
assert_file
|
|
19
|
-
assert_file
|
|
20
|
-
assert_file
|
|
18
|
+
assert_file "app/views/doorkeeper/applications/_form.html.erb"
|
|
19
|
+
assert_file "app/views/doorkeeper/applications/edit.html.erb"
|
|
20
|
+
assert_file "app/views/doorkeeper/applications/index.html.erb"
|
|
21
|
+
assert_file "app/views/doorkeeper/applications/new.html.erb"
|
|
22
|
+
assert_file "app/views/doorkeeper/applications/show.html.erb"
|
|
21
23
|
|
|
22
|
-
assert_file
|
|
23
|
-
assert_file
|
|
24
|
+
assert_file "app/views/doorkeeper/authorizations/error.html.erb"
|
|
25
|
+
assert_file "app/views/doorkeeper/authorizations/new.html.erb"
|
|
24
26
|
|
|
25
|
-
assert_file
|
|
27
|
+
assert_file "app/views/doorkeeper/authorized_applications/index.html.erb"
|
|
26
28
|
end
|
|
27
29
|
end
|