Skip to content

Commit

Permalink
add nil check operator in token checking at token introspection
Browse files Browse the repository at this point in the history
  • Loading branch information
linhdangduy committed Apr 10, 2019
1 parent 9bb03f8 commit c976f78
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Expand Up @@ -7,6 +7,7 @@ User-visible changes worth mentioning.

## master

- [#1243]: Add nil check operator in token checking at token introspection.
- [#1241] Explaining foreign key options for resource owner in a single place
- [#1237] Allow to set blank redirect URI if Doorkeeper configured to use redirect URI-less grant flows.
- [#1234] Fix `StaleRecordsCleaner` to properly work with big amount of records.
Expand Down
2 changes: 1 addition & 1 deletion lib/doorkeeper/oauth/token_introspection.rb
Expand Up @@ -163,7 +163,7 @@ def valid_token?

# RFC7662 Section 2.1
def authorized_token_matches_introspected?
authorized_token.token == @token.token
authorized_token.token == @token&.token
end

# If token doesn't belong to some client, then it is public.
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/tokens_controller_spec.rb
Expand Up @@ -213,14 +213,14 @@
end

context "authorized using invalid Bearer token" do
let(:token_for_introspection) do
let(:access_token) do
FactoryBot.create(:access_token, application: client, revoked_at: 1.day.ago)
end

it "responds with invalid token error" do
request.headers["Authorization"] = "Bearer #{token_for_introspection.token}"
request.headers["Authorization"] = "Bearer #{access_token.token}"

post :introspect, params: { token: access_token.token }
post :introspect, params: { token: token_for_introspection.token }

response_status_should_be 401

Expand Down

0 comments on commit c976f78

Please sign in to comment.