Skip to content

Commit

Permalink
Disable introspection endpoints if disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
nbulaj committed May 22, 2020
1 parent 4dd7c51 commit 358b37c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
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

0 comments on commit 358b37c

Please sign in to comment.