Skip to content

Commit

Permalink
Merge pull request #974 from earlymarket/fix-uri-comparing
Browse files Browse the repository at this point in the history
Fix uri comparison
  • Loading branch information
nbulaj authored Jan 26, 2018
2 parents ef3d4b1 + df6ddc9 commit 2645f46
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ User-visible changes worth mentioning.
## master

- [#970] Escape certain attributes in authorization forms.
- [#974] Redirect URI is checked without query params within AuthorizationCodeRequest.

## 4.2.5

Expand Down
5 changes: 4 additions & 1 deletion lib/doorkeeper/oauth/authorization_code_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ def validate_grant
end

def validate_redirect_uri
grant.redirect_uri == redirect_uri
Helpers::URIChecker.valid_for_authorization?(
redirect_uri,
grant.redirect_uri
)
end
end
end
Expand Down
13 changes: 12 additions & 1 deletion spec/lib/oauth/authorization_code_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ module Doorkeeper::OAuth
end
let(:grant) { FactoryGirl.create :access_grant }
let(:client) { grant.application }
let(:redirect_uri) { client.redirect_uri }
let(:params) { { redirect_uri: redirect_uri } }

subject do
AuthorizationCodeRequest.new server, grant, client, redirect_uri: client.redirect_uri
AuthorizationCodeRequest.new server, grant, client, params
end

it 'issues a new token for the client' do
Expand Down Expand Up @@ -76,5 +78,14 @@ module Doorkeeper::OAuth
subject.authorize
end.to_not change { Doorkeeper::AccessToken.count }
end

context "when redirect_uri contains some query params" do
let(:redirect_uri) { client.redirect_uri + "?query=q" }

it "compares only host part with grant's redirect_uri" do
subject.validate
expect(subject.error).to eq(nil)
end
end
end
end

0 comments on commit 2645f46

Please sign in to comment.