doorkeeper 5.0.3 → 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 +4 -4
- data/.hound.yml +2 -1
- data/.rubocop.yml +37 -4
- data/.travis.yml +11 -21
- data/Appraisals +29 -7
- data/Dangerfile +5 -2
- data/Gemfile +19 -5
- data/NEWS.md +81 -21
- data/README.md +75 -485
- data/Rakefile +10 -8
- data/app/controllers/doorkeeper/application_controller.rb +1 -2
- data/app/controllers/doorkeeper/application_metal_controller.rb +2 -13
- data/app/controllers/doorkeeper/applications_controller.rb +20 -8
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +1 -1
- data/app/controllers/doorkeeper/token_info_controller.rb +2 -2
- data/app/controllers/doorkeeper/tokens_controller.rb +11 -11
- data/app/helpers/doorkeeper/dashboard_helper.rb +1 -1
- data/app/validators/redirect_uri_validator.rb +5 -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 +24 -21
- 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 +191 -75
- data/lib/doorkeeper/engine.rb +1 -1
- data/lib/doorkeeper/grape/authorization_decorator.rb +4 -4
- data/lib/doorkeeper/grape/helpers.rb +3 -3
- data/lib/doorkeeper/helpers/controller.rb +3 -2
- data/lib/doorkeeper/models/access_grant_mixin.rb +20 -3
- data/lib/doorkeeper/models/access_token_mixin.rb +63 -19
- data/lib/doorkeeper/models/application_mixin.rb +43 -1
- data/lib/doorkeeper/models/concerns/expirable.rb +4 -2
- data/lib/doorkeeper/models/concerns/ownership.rb +1 -6
- data/lib/doorkeeper/models/concerns/reusable.rb +19 -0
- data/lib/doorkeeper/models/concerns/revocable.rb +2 -1
- data/lib/doorkeeper/models/concerns/scopes.rb +5 -1
- data/lib/doorkeeper/models/concerns/secret_storable.rb +108 -0
- data/lib/doorkeeper/oauth/authorization/code.rb +2 -2
- data/lib/doorkeeper/oauth/authorization/token.rb +12 -7
- data/lib/doorkeeper/oauth/authorization/uri_builder.rb +1 -1
- data/lib/doorkeeper/oauth/authorization_code_request.rb +6 -4
- data/lib/doorkeeper/oauth/client.rb +1 -1
- data/lib/doorkeeper/oauth/client_credentials/validation.rb +5 -4
- data/lib/doorkeeper/oauth/client_credentials_request.rb +1 -1
- data/lib/doorkeeper/oauth/code_response.rb +2 -2
- data/lib/doorkeeper/oauth/error_response.rb +10 -6
- data/lib/doorkeeper/oauth/forbidden_token_response.rb +1 -1
- data/lib/doorkeeper/oauth/helpers/scope_checker.rb +23 -8
- data/lib/doorkeeper/oauth/helpers/unique_token.rb +13 -1
- data/lib/doorkeeper/oauth/helpers/uri_checker.rb +37 -1
- data/lib/doorkeeper/oauth/invalid_token_response.rb +5 -1
- data/lib/doorkeeper/oauth/password_access_token_request.rb +7 -2
- data/lib/doorkeeper/oauth/pre_authorization.rb +11 -5
- data/lib/doorkeeper/oauth/refresh_token_request.rb +5 -2
- data/lib/doorkeeper/oauth/scopes.rb +5 -3
- data/lib/doorkeeper/oauth/token.rb +2 -2
- data/lib/doorkeeper/oauth/token_introspection.rb +74 -8
- data/lib/doorkeeper/oauth/token_response.rb +9 -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 +21 -57
- data/lib/doorkeeper/orm/active_record/stale_records_cleaner.rb +10 -3
- data/lib/doorkeeper/orm/active_record.rb +6 -6
- data/lib/doorkeeper/rails/helpers.rb +1 -1
- data/lib/doorkeeper/rails/routes/mapping.rb +7 -7
- data/lib/doorkeeper/rails/routes.rb +11 -11
- data/lib/doorkeeper/rake/db.rake +13 -13
- data/lib/doorkeeper/rake.rb +1 -1
- data/lib/doorkeeper/request.rb +1 -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/stale_records_cleaner.rb +1 -1
- data/lib/doorkeeper/version.rb +3 -3
- data/lib/doorkeeper.rb +69 -60
- 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 +120 -13
- data/lib/generators/doorkeeper/templates/migration.rb.erb +15 -7
- 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 +54 -52
- data/spec/controllers/authorizations_controller_spec.rb +139 -145
- data/spec/controllers/protected_resources_controller_spec.rb +78 -76
- data/spec/controllers/token_info_controller_spec.rb +14 -12
- data/spec/controllers/tokens_controller_spec.rb +167 -108
- 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 +2 -0
- data/spec/dummy/app/controllers/full_protected_resources_controller.rb +4 -2
- data/spec/dummy/app/controllers/home_controller.rb +5 -3
- 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 +25 -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 +3 -1
- data/spec/dummy/config/initializers/backtrace_silencers.rb +2 -0
- data/spec/dummy/config/initializers/doorkeeper.rb +5 -2
- 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 +17 -10
- data/spec/dummy/db/migrate/20170822064514_enable_pkce.rb +2 -0
- data/spec/dummy/db/schema.rb +1 -1
- data/spec/dummy/script/rails +5 -3
- data/spec/factories.rb +8 -6
- 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 +17 -15
- 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 -0
- data/spec/generators/views_generator_spec.rb +14 -12
- data/spec/grape/grape_integration_spec.rb +34 -32
- data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +9 -7
- data/spec/lib/config_spec.rb +268 -99
- data/spec/lib/doorkeeper_spec.rb +3 -1
- 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 +34 -11
- data/spec/lib/oauth/base_request_spec.rb +20 -8
- data/spec/lib/oauth/base_response_spec.rb +3 -1
- data/spec/lib/oauth/client/credentials_spec.rb +24 -22
- data/spec/lib/oauth/client_credentials/creator_spec.rb +56 -10
- data/spec/lib/oauth/client_credentials/issuer_spec.rb +27 -18
- data/spec/lib/oauth/client_credentials/validation_spec.rb +20 -15
- data/spec/lib/oauth/client_credentials_integration_spec.rb +7 -5
- 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 +8 -6
- 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 +115 -95
- data/spec/lib/oauth/invalid_token_response_spec.rb +3 -1
- data/spec/lib/oauth/password_access_token_request_spec.rb +79 -30
- data/spec/lib/oauth/pre_authorization_spec.rb +80 -54
- data/spec/lib/oauth/refresh_token_request_spec.rb +36 -33
- data/spec/lib/oauth/scopes_spec.rb +63 -61
- data/spec/lib/oauth/token_request_spec.rb +79 -24
- data/spec/lib/oauth/token_response_spec.rb +40 -38
- data/spec/lib/oauth/token_spec.rb +60 -44
- 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 +16 -14
- data/spec/lib/stale_records_cleaner_spec.rb +17 -17
- data/spec/models/doorkeeper/access_grant_spec.rb +80 -15
- data/spec/models/doorkeeper/access_token_spec.rb +198 -73
- data/spec/models/doorkeeper/application_spec.rb +280 -288
- data/spec/requests/applications/applications_request_spec.rb +98 -66
- data/spec/requests/applications/authorized_applications_spec.rb +20 -18
- data/spec/requests/endpoints/authorization_spec.rb +25 -23
- data/spec/requests/endpoints/token_spec.rb +38 -36
- data/spec/requests/flows/authorization_code_errors_spec.rb +26 -24
- data/spec/requests/flows/authorization_code_spec.rb +193 -151
- data/spec/requests/flows/client_credentials_spec.rb +54 -52
- data/spec/requests/flows/implicit_grant_errors_spec.rb +10 -8
- data/spec/requests/flows/implicit_grant_spec.rb +27 -25
- data/spec/requests/flows/password_spec.rb +59 -55
- data/spec/requests/flows/refresh_token_spec.rb +45 -43
- data/spec/requests/flows/revoke_token_spec.rb +40 -54
- 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 +35 -33
- 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 +3 -1
- 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 +3 -1
- data/spec/support/helpers/request_spec_helper.rb +5 -3
- data/spec/support/helpers/url_helper.rb +9 -7
- 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 +18 -16
- 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 +74 -45
- data/spec/version/version_spec.rb +7 -5
- metadata +60 -26
- data/gemfiles/rails_4_2.gemfile +0 -13
- data/spec/dummy/config/initializers/new_framework_defaults.rb +0 -8
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Doorkeeper
|
|
4
|
-
class ApplicationMetalController < ActionController::
|
|
5
|
-
|
|
6
|
-
ActionController::Instrumentation,
|
|
7
|
-
AbstractController::Rendering,
|
|
8
|
-
ActionController::Rendering,
|
|
9
|
-
ActionController::Renderers::All,
|
|
10
|
-
AbstractController::Callbacks,
|
|
11
|
-
Helpers::Controller
|
|
12
|
-
].freeze
|
|
13
|
-
|
|
14
|
-
MODULES.each do |mod|
|
|
15
|
-
include mod
|
|
16
|
-
end
|
|
4
|
+
class ApplicationMetalController < ActionController::API
|
|
5
|
+
include Helpers::Controller
|
|
17
6
|
|
|
18
7
|
before_action :enforce_content_type,
|
|
19
8
|
if: -> { Doorkeeper.configuration.enforce_content_type }
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Doorkeeper
|
|
4
4
|
class ApplicationsController < Doorkeeper::ApplicationController
|
|
5
|
-
layout
|
|
5
|
+
layout "doorkeeper/admin" unless Doorkeeper.configuration.api_only
|
|
6
6
|
|
|
7
7
|
before_action :authenticate_admin!
|
|
8
8
|
before_action :set_application, only: %i[show edit update destroy]
|
|
@@ -19,7 +19,7 @@ module Doorkeeper
|
|
|
19
19
|
def show
|
|
20
20
|
respond_to do |format|
|
|
21
21
|
format.html
|
|
22
|
-
format.json { render json: @application
|
|
22
|
+
format.json { render json: @application }
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
@@ -35,12 +35,16 @@ module Doorkeeper
|
|
|
35
35
|
|
|
36
36
|
respond_to do |format|
|
|
37
37
|
format.html { redirect_to oauth_application_url(@application) }
|
|
38
|
-
format.json { render json: @application
|
|
38
|
+
format.json { render json: @application }
|
|
39
39
|
end
|
|
40
40
|
else
|
|
41
41
|
respond_to do |format|
|
|
42
42
|
format.html { render :new }
|
|
43
|
-
format.json
|
|
43
|
+
format.json do
|
|
44
|
+
errors = @application.errors.full_messages
|
|
45
|
+
|
|
46
|
+
render json: { errors: errors }, status: :unprocessable_entity
|
|
47
|
+
end
|
|
44
48
|
end
|
|
45
49
|
end
|
|
46
50
|
end
|
|
@@ -49,22 +53,26 @@ module Doorkeeper
|
|
|
49
53
|
|
|
50
54
|
def update
|
|
51
55
|
if @application.update(application_params)
|
|
52
|
-
flash[:notice] = I18n.t(:notice, scope:
|
|
56
|
+
flash[:notice] = I18n.t(:notice, scope: i18n_scope(:update))
|
|
53
57
|
|
|
54
58
|
respond_to do |format|
|
|
55
59
|
format.html { redirect_to oauth_application_url(@application) }
|
|
56
|
-
format.json { render json: @application
|
|
60
|
+
format.json { render json: @application }
|
|
57
61
|
end
|
|
58
62
|
else
|
|
59
63
|
respond_to do |format|
|
|
60
64
|
format.html { render :edit }
|
|
61
|
-
format.json
|
|
65
|
+
format.json do
|
|
66
|
+
errors = @application.errors.full_messages
|
|
67
|
+
|
|
68
|
+
render json: { errors: errors }, status: :unprocessable_entity
|
|
69
|
+
end
|
|
62
70
|
end
|
|
63
71
|
end
|
|
64
72
|
end
|
|
65
73
|
|
|
66
74
|
def destroy
|
|
67
|
-
flash[:notice] = I18n.t(:notice, scope:
|
|
75
|
+
flash[:notice] = I18n.t(:notice, scope: i18n_scope(:destroy)) if @application.destroy
|
|
68
76
|
|
|
69
77
|
respond_to do |format|
|
|
70
78
|
format.html { redirect_to oauth_applications_url }
|
|
@@ -82,5 +90,9 @@ module Doorkeeper
|
|
|
82
90
|
params.require(:doorkeeper_application)
|
|
83
91
|
.permit(:name, :redirect_uri, :scopes, :confidential)
|
|
84
92
|
end
|
|
93
|
+
|
|
94
|
+
def i18n_scope(action)
|
|
95
|
+
%i[doorkeeper flash applications] << action
|
|
96
|
+
end
|
|
85
97
|
end
|
|
86
98
|
end
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
module Doorkeeper
|
|
4
4
|
class TokenInfoController < Doorkeeper::ApplicationMetalController
|
|
5
5
|
def show
|
|
6
|
-
if doorkeeper_token
|
|
6
|
+
if doorkeeper_token&.accessible?
|
|
7
7
|
render json: doorkeeper_token, status: :ok
|
|
8
8
|
else
|
|
9
|
-
error = OAuth::
|
|
9
|
+
error = OAuth::InvalidTokenResponse.new
|
|
10
10
|
response.headers.merge!(error.headers)
|
|
11
11
|
render json: error.body, status: error.status
|
|
12
12
|
end
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
module Doorkeeper
|
|
4
4
|
class TokensController < Doorkeeper::ApplicationMetalController
|
|
5
5
|
def create
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
handle_token_exception e
|
|
6
|
+
headers.merge!(authorize_response.headers)
|
|
7
|
+
render json: authorize_response.body,
|
|
8
|
+
status: authorize_response.status
|
|
9
|
+
rescue Errors::DoorkeeperError => error
|
|
10
|
+
handle_token_exception(error)
|
|
12
11
|
end
|
|
13
12
|
|
|
14
13
|
# OAuth 2.0 Token Revocation - http://tools.ietf.org/html/rfc7009
|
|
@@ -33,8 +32,8 @@ module Doorkeeper
|
|
|
33
32
|
if introspection.authorized?
|
|
34
33
|
render json: introspection.to_json, status: 200
|
|
35
34
|
else
|
|
36
|
-
error =
|
|
37
|
-
|
|
35
|
+
error = introspection.error_response
|
|
36
|
+
headers.merge!(error.headers)
|
|
38
37
|
render json: error.body, status: error.status
|
|
39
38
|
end
|
|
40
39
|
end
|
|
@@ -59,6 +58,7 @@ module Doorkeeper
|
|
|
59
58
|
# https://tools.ietf.org/html/rfc7009
|
|
60
59
|
def authorized?
|
|
61
60
|
return unless token.present?
|
|
61
|
+
|
|
62
62
|
# Client is confidential, therefore client authentication & authorization
|
|
63
63
|
# is required
|
|
64
64
|
if token.application_id? && token.application.confidential?
|
|
@@ -75,12 +75,12 @@ module Doorkeeper
|
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
def token
|
|
78
|
-
@token ||= AccessToken.by_token(
|
|
79
|
-
|
|
78
|
+
@token ||= AccessToken.by_token(params["token"]) ||
|
|
79
|
+
AccessToken.by_refresh_token(params["token"])
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
def strategy
|
|
83
|
-
@strategy ||= server.token_request
|
|
83
|
+
@strategy ||= server.token_request(params[:grant_type])
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
def authorize_response
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "uri"
|
|
4
4
|
|
|
5
5
|
class RedirectUriValidator < ActiveModel::EachValidator
|
|
6
6
|
def self.native_redirect_uri
|
|
@@ -9,11 +9,14 @@ class RedirectUriValidator < ActiveModel::EachValidator
|
|
|
9
9
|
|
|
10
10
|
def validate_each(record, attribute, value)
|
|
11
11
|
if value.blank?
|
|
12
|
+
return if Doorkeeper.configuration.allow_blank_redirect_uri?(record)
|
|
13
|
+
|
|
12
14
|
record.errors.add(attribute, :blank)
|
|
13
15
|
else
|
|
14
16
|
value.split.each do |val|
|
|
15
17
|
uri = ::URI.parse(val)
|
|
16
18
|
next if native_redirect_uri?(uri)
|
|
19
|
+
|
|
17
20
|
record.errors.add(attribute, :forbidden_uri) if forbidden_uri?(uri)
|
|
18
21
|
record.errors.add(attribute, :fragment_present) unless uri.fragment.nil?
|
|
19
22
|
record.errors.add(attribute, :relative_uri) if uri.scheme.nil? || uri.host.nil?
|
|
@@ -36,7 +39,7 @@ class RedirectUriValidator < ActiveModel::EachValidator
|
|
|
36
39
|
|
|
37
40
|
def invalid_ssl_uri?(uri)
|
|
38
41
|
forces_ssl = Doorkeeper.configuration.force_ssl_in_redirect_uri
|
|
39
|
-
non_https = uri.try(:scheme) ==
|
|
42
|
+
non_https = uri.try(:scheme) == "http"
|
|
40
43
|
|
|
41
44
|
if forces_ssl.respond_to?(:call)
|
|
42
45
|
forces_ssl.call(uri) && non_https
|
|
@@ -25,6 +25,12 @@
|
|
|
25
25
|
<%= raw t('doorkeeper.applications.help.native_redirect_uri', native_redirect_uri: content_tag(:code, class: 'bg-light') { Doorkeeper.configuration.native_redirect_uri }) %>
|
|
26
26
|
</span>
|
|
27
27
|
<% end %>
|
|
28
|
+
|
|
29
|
+
<% if Doorkeeper.configuration.allow_blank_redirect_uri?(application) %>
|
|
30
|
+
<span class="form-text text-secondary">
|
|
31
|
+
<%= t('doorkeeper.applications.help.blank_redirect_uri') %>
|
|
32
|
+
</span>
|
|
33
|
+
<% end %>
|
|
28
34
|
</div>
|
|
29
35
|
</div>
|
|
30
36
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<p><code class="bg-light" id="application_id"><%= @application.uid %></code></p>
|
|
9
9
|
|
|
10
10
|
<h4><%= t('.secret') %>:</h4>
|
|
11
|
-
<p><code class="bg-light" id="secret"><%= @application.
|
|
11
|
+
<p><code class="bg-light" id="secret"><%= @application.plaintext_secret %></code></p>
|
|
12
12
|
|
|
13
13
|
<h4><%= t('.scopes') %>:</h4>
|
|
14
14
|
<p><code class="bg-light" id="scopes"><%= @application.scopes.presence || raw(' ') %></code></p>
|
|
@@ -17,9 +17,11 @@
|
|
|
17
17
|
<li class="nav-item <%= 'active' if request.path == oauth_applications_path %>">
|
|
18
18
|
<%= link_to t('doorkeeper.layouts.admin.nav.applications'), oauth_applications_path, class: 'nav-link' %>
|
|
19
19
|
</li>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
<% if respond_to?(:root_path) %>
|
|
21
|
+
<li class="nav-item">
|
|
22
|
+
<%= link_to t('doorkeeper.layouts.admin.nav.home'), root_path, class: 'nav-link' %>
|
|
23
|
+
</li>
|
|
24
|
+
<% end %>
|
|
23
25
|
</ul>
|
|
24
26
|
</div>
|
|
25
27
|
</nav>
|
data/bin/console
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
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/config/locales/en.yml
CHANGED
|
@@ -32,6 +32,7 @@ en:
|
|
|
32
32
|
help:
|
|
33
33
|
confidential: 'Application will be used where the client secret can be kept confidential. Native mobile apps and Single Page Apps are considered non-confidential.'
|
|
34
34
|
redirect_uri: 'Use one line per URI'
|
|
35
|
+
blank_redirect_uri: "Leave it blank if you configured your provider to use Client Credentials, Resource Owner Password Credentials or any other grant type that doesn't require redirect URI."
|
|
35
36
|
native_redirect_uri: 'Use %{native_redirect_uri} if you want to add localhost URIs for development purposes'
|
|
36
37
|
scopes: 'Separate scopes with spaces. Leave blank to use the default scopes.'
|
|
37
38
|
edit:
|
data/doorkeeper.gemspec
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
$LOAD_PATH.push File.expand_path("lib", __dir__)
|
|
4
|
+
|
|
5
|
+
require "doorkeeper/version"
|
|
4
6
|
|
|
5
7
|
Gem::Specification.new do |gem|
|
|
6
|
-
gem.name =
|
|
8
|
+
gem.name = "doorkeeper"
|
|
7
9
|
gem.version = Doorkeeper.gem_version
|
|
8
|
-
gem.authors = [
|
|
9
|
-
gem.email = %w
|
|
10
|
-
gem.homepage =
|
|
11
|
-
gem.summary =
|
|
12
|
-
gem.description =
|
|
13
|
-
gem.license =
|
|
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"
|
|
14
16
|
|
|
15
17
|
gem.files = `git ls-files`.split("\n")
|
|
16
18
|
gem.test_files = `git ls-files -- spec/*`.split("\n")
|
|
17
|
-
gem.require_paths = [
|
|
19
|
+
gem.require_paths = ["lib"]
|
|
18
20
|
|
|
19
|
-
gem.add_dependency
|
|
20
|
-
gem.required_ruby_version =
|
|
21
|
+
gem.add_dependency "railties", ">= 5"
|
|
22
|
+
gem.required_ruby_version = ">= 2.4"
|
|
21
23
|
|
|
22
|
-
gem.add_development_dependency
|
|
23
|
-
gem.add_development_dependency
|
|
24
|
-
gem.add_development_dependency
|
|
25
|
-
gem.add_development_dependency
|
|
26
|
-
gem.add_development_dependency
|
|
27
|
-
gem.add_development_dependency
|
|
28
|
-
gem.add_development_dependency
|
|
29
|
-
gem.add_development_dependency
|
|
30
|
-
gem.add_development_dependency
|
|
24
|
+
gem.add_development_dependency "appraisal"
|
|
25
|
+
gem.add_development_dependency "capybara"
|
|
26
|
+
gem.add_development_dependency "coveralls"
|
|
27
|
+
gem.add_development_dependency "danger", "~> 6.0"
|
|
28
|
+
gem.add_development_dependency "database_cleaner", "~> 1.6"
|
|
29
|
+
gem.add_development_dependency "factory_bot", "~> 5.0"
|
|
30
|
+
gem.add_development_dependency "generator_spec", "~> 0.9.3"
|
|
31
|
+
gem.add_development_dependency "grape"
|
|
32
|
+
gem.add_development_dependency "rake", ">= 11.3.0"
|
|
33
|
+
gem.add_development_dependency "rspec-rails"
|
|
31
34
|
end
|
data/gemfiles/rails_5_0.gemfile
CHANGED
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
5
|
gem "rails", "~> 5.0.0"
|
|
6
|
-
gem "
|
|
7
|
-
gem "
|
|
8
|
-
gem "
|
|
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", branch: "4-0-dev", git: "https://github.com/rspec/rspec-rails.git"
|
|
10
|
+
gem "rspec-support", git: "https://github.com/rspec/rspec-support.git"
|
|
11
|
+
gem "rubocop", "~> 0.66"
|
|
12
|
+
gem "bcrypt", "~> 3.1", require: false
|
|
13
|
+
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
|
14
|
+
gem "sqlite3", "~> 1.3", "< 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
|
|
9
15
|
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw]
|
|
10
|
-
gem "rspec-rails", "~> 3.5"
|
|
11
16
|
|
|
12
17
|
gemspec path: "../"
|
data/gemfiles/rails_5_1.gemfile
CHANGED
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
5
|
gem "rails", "~> 5.1.0"
|
|
6
|
-
gem "
|
|
7
|
-
gem "
|
|
8
|
-
gem "
|
|
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", branch: "4-0-dev", git: "https://github.com/rspec/rspec-rails.git"
|
|
10
|
+
gem "rspec-support", git: "https://github.com/rspec/rspec-support.git"
|
|
11
|
+
gem "rubocop", "~> 0.66"
|
|
12
|
+
gem "bcrypt", "~> 3.1", require: false
|
|
13
|
+
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
|
14
|
+
gem "sqlite3", "~> 1.3", "< 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
|
|
9
15
|
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw]
|
|
10
|
-
gem "rspec-rails", "~> 3.7"
|
|
11
16
|
|
|
12
17
|
gemspec path: "../"
|
data/gemfiles/rails_5_2.gemfile
CHANGED
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
gem "rails", "5.2.0"
|
|
6
|
-
gem "
|
|
7
|
-
gem "
|
|
8
|
-
gem "
|
|
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", branch: "4-0-dev", git: "https://github.com/rspec/rspec-rails.git"
|
|
10
|
+
gem "rspec-support", git: "https://github.com/rspec/rspec-support.git"
|
|
11
|
+
gem "rubocop", "~> 0.66"
|
|
12
|
+
gem "bcrypt", "~> 3.1", require: false
|
|
13
|
+
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
|
14
|
+
gem "sqlite3", "~> 1.3", "< 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
|
|
9
15
|
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw]
|
|
10
|
-
gem "rspec-rails", "~> 3.7"
|
|
11
16
|
|
|
12
17
|
gemspec path: "../"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "rails", "~> 6.0.0.beta3"
|
|
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", branch: "4-0-dev", git: "https://github.com/rspec/rspec-rails.git"
|
|
10
|
+
gem "rspec-support", git: "https://github.com/rspec/rspec-support.git"
|
|
11
|
+
gem "rubocop", "~> 0.66"
|
|
12
|
+
gem "bcrypt", "~> 3.1", require: false
|
|
13
|
+
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
|
14
|
+
gem "sqlite3", "~> 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
|
|
15
|
+
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw]
|
|
16
|
+
|
|
17
|
+
gemspec path: "../"
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
gem "rails", git:
|
|
6
|
-
gem "
|
|
7
|
-
|
|
8
|
-
gem "
|
|
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", branch: "4-0-dev", git: "https://github.com/rspec/rspec-rails.git"
|
|
10
|
+
gem "rspec-support", git: "https://github.com/rspec/rspec-support.git"
|
|
11
|
+
gem "rubocop", "~> 0.66"
|
|
12
|
+
gem "bcrypt", "~> 3.1", require: false
|
|
9
13
|
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
|
10
|
-
gem "sqlite3", platform: [:ruby, :mswin, :mingw, :x64_mingw]
|
|
14
|
+
gem "sqlite3", "~> 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
|
|
11
15
|
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw]
|
|
12
16
|
|
|
13
|
-
%w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib|
|
|
14
|
-
gem lib, git: "https://github.com/rspec/#{lib}.git", branch: 'master'
|
|
15
|
-
end
|
|
16
|
-
|
|
17
17
|
gemspec path: "../"
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Doorkeeper
|
|
4
|
+
class Config
|
|
5
|
+
# Doorkeeper configuration option DSL
|
|
6
|
+
module Option
|
|
7
|
+
# Defines configuration option
|
|
8
|
+
#
|
|
9
|
+
# When you call option, it defines two methods. One method will take place
|
|
10
|
+
# in the +Config+ class and the other method will take place in the
|
|
11
|
+
# +Builder+ class.
|
|
12
|
+
#
|
|
13
|
+
# The +name+ parameter will set both builder method and config attribute.
|
|
14
|
+
# If the +:as+ option is defined, the builder method will be the specified
|
|
15
|
+
# option while the config attribute will be the +name+ parameter.
|
|
16
|
+
#
|
|
17
|
+
# If you want to introduce another level of config DSL you can
|
|
18
|
+
# define +builder_class+ parameter.
|
|
19
|
+
# Builder should take a block as the initializer parameter and respond to function +build+
|
|
20
|
+
# that returns the value of the config attribute.
|
|
21
|
+
#
|
|
22
|
+
# ==== Options
|
|
23
|
+
#
|
|
24
|
+
# * [:+as+] Set the builder method that goes inside +configure+ block
|
|
25
|
+
# * [+:default+] The default value in case no option was set
|
|
26
|
+
# * [+:builder_class+] Configuration option builder class
|
|
27
|
+
#
|
|
28
|
+
# ==== Examples
|
|
29
|
+
#
|
|
30
|
+
# option :name
|
|
31
|
+
# option :name, as: :set_name
|
|
32
|
+
# option :name, default: 'My Name'
|
|
33
|
+
# option :scopes builder_class: ScopesBuilder
|
|
34
|
+
#
|
|
35
|
+
def option(name, options = {})
|
|
36
|
+
attribute = options[:as] || name
|
|
37
|
+
attribute_builder = options[:builder_class]
|
|
38
|
+
|
|
39
|
+
Builder.instance_eval do
|
|
40
|
+
remove_method name if method_defined?(name)
|
|
41
|
+
define_method name do |*args, &block|
|
|
42
|
+
value = if attribute_builder
|
|
43
|
+
attribute_builder.new(&block).build
|
|
44
|
+
else
|
|
45
|
+
block || args.first
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
@config.instance_variable_set(:"@#{attribute}", value)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
define_method attribute do |*_args|
|
|
53
|
+
if instance_variable_defined?(:"@#{attribute}")
|
|
54
|
+
instance_variable_get(:"@#{attribute}")
|
|
55
|
+
else
|
|
56
|
+
options[:default]
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
public attribute
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|