Skip to content

Commit b34116e

Browse files
author
Dmitry Trager
committed
# This is a combination of 3 commits.
# The first commit's message is: Compare redirect_uri and grant uri without query when doing checks from authorization code request # This is the 2nd commit message: Fix xss by escaping tags content_tag body is correctly escaped when rendered even if called is wrapped by raw # This is the 3rd commit message: Fix CI review
1 parent 4967b04 commit b34116e

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ User-visible changes worth mentioning.
55
## master
66

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

910
## 4.2.5
1011

lib/doorkeeper/oauth/authorization_code_request.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ def validate_grant
4444
end
4545

4646
def validate_redirect_uri
47-
grant.redirect_uri == redirect_uri
47+
Helpers::URIChecker.valid_for_authorization?(
48+
redirect_uri,
49+
grant.redirect_uri
50+
)
4851
end
4952
end
5053
end

spec/lib/oauth/authorization_code_request_spec.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ module Doorkeeper::OAuth
1010
end
1111
let(:grant) { FactoryGirl.create :access_grant }
1212
let(:client) { grant.application }
13+
let(:redirect_uri) { client.redirect_uri }
14+
let(:params) { { redirect_uri: redirect_uri } }
1315

1416
subject do
15-
AuthorizationCodeRequest.new server, grant, client, redirect_uri: client.redirect_uri
17+
AuthorizationCodeRequest.new server, grant, client, params
1618
end
1719

1820
it 'issues a new token for the client' do
@@ -76,5 +78,14 @@ module Doorkeeper::OAuth
7678
subject.authorize
7779
end.to_not change { Doorkeeper::AccessToken.count }
7880
end
81+
82+
context "when redirect_uri contains some query params" do
83+
let(:redirect_uri) { client.redirect_uri + "?query=q" }
84+
85+
it "compares only host part with grant's redirect_uri" do
86+
subject.validate
87+
expect(subject.error).to eq(nil)
88+
end
89+
end
7990
end
8091
end

0 commit comments

Comments
 (0)