Skip to content

Fix uri comparing #974

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

Merged
merged 1 commit into from
Jan 26, 2018
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 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