Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable introspection endpoints if disabled #1416

Merged
merged 1 commit into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ User-visible changes worth mentioning.

## master

- [#1416] Don't add introspection route if token introspection completely disabled.
- [#1410] Properly memoize `current_resource_owner` value (consider `nil` and `false` values).

## 5.4.0
Expand Down
4 changes: 3 additions & 1 deletion lib/doorkeeper/rails/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def generate_routes!(options)
map_route(:authorizations, :authorization_routes)
map_route(:tokens, :token_routes)
map_route(:tokens, :revoke_routes)
map_route(:tokens, :introspect_routes)
unless Doorkeeper.config.allow_token_introspection.is_a?(FalseClass)
map_route(:tokens, :introspect_routes)
end
map_route(:applications, :application_routes)
map_route(:authorized_applications, :authorized_applications_routes)
map_route(:token_info, :token_info_routes)
Expand Down
9 changes: 9 additions & 0 deletions spec/routing/scoped_routes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

RSpec.describe "Scoped routes" do
before :all do
Doorkeeper.configure do
orm DOORKEEPER_ORM
allow_token_introspection false
end

Rails.application.routes.disable_clear_and_finalize = true

Rails.application.routes.draw do
Expand Down Expand Up @@ -44,4 +49,8 @@
it "GET /scope/token/info route to authorized TokenInfo controller" do
expect(get("/scope/token/info")).to route_to("doorkeeper/token_info#show")
end

it "POST /scope/introspect routes not to exist" do
expect(post("/scope/introspect")).not_to be_routable
end
end