Skip to content

Conversation

@pauldekkers
Copy link
Contributor

@pauldekkerspauldekkers commented Apr 1, 2021

Description of the Change

Allow loopback redirect URIs with ports using http scheme and localhost addresses (127.0.0.1 or ::1),
as described in RFC8252 (section 7.3).

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added
  • documentation updated
  • CHANGELOG.md updated (only for user relevant changes)
  • author name in AUTHORS

@codecov
Copy link

codecovbot commented Apr 1, 2021

Codecov Report

Merging #953 (947a83d) into master (b4f418b) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@ Coverage Diff @@## master #953 +/- ## ======================================= Coverage 96.61% 96.62% ======================================= Files 31 31 Lines 1713 1716 +3 ======================================= + Hits 1655 1658 +3  Misses 58 58 
Impacted FilesCoverage Δ
oauth2_provider/models.py98.67% <100.00%> (+0.01%)⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b4f418b...947a83d. Read the comment docs.

auvipy
auvipy previously requested changes Apr 2, 2021
Copy link
Contributor

@auvipyauvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for your PR. can you check the PR checklist and update as appripriate? changelog, entry to the author, and possibly unit test?

@pauldekkers
Copy link
ContributorAuthor

I've modified the patch slightly to only accept random redirect_uri ports when there is no explicit port configured in the Application. I've added a line in the documentation, updated the CHANGELOG and AUTHORS.
I'm struggling a bit with the unit test as there is no existing test and these tests are a bit more complex than the suggested change. Would you accept without?

@pauldekkerspauldekkers requested a review from auvipyApril 4, 2021 10:39
@rtpg
Copy link
Contributor

rtpg commented Apr 5, 2021

While reading over this back and forth I took the opportunity to just add in some tests and factor out this logic to make it easier to unit test. Thanks for doing all the legwork on this first though!

I think that this loopback special casing in redirect code (pretty sensitive area, securitywise) warranted a nice chunky comment, but my tests left me pretty happy that this is the "right" way of going forward.

@auvipy since I made a change I feel a bit uncomfortable approving the PR, please look over what I pushed in.

andparsed_allowed_uri.path==parsed_uri.path
) or (
parsed_allowed_uri.scheme==parsed_uri.scheme
andparsed_allowed_uri.netloc==parsed_uri.netloc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at first it looks like both of these branches could be merged! And for scheme and path it can, but netloc is actually inclusive of the port (it's roughly login info + hostname + port) , and for loopback IPs we don't want to be requiring the port to be the same (the whole point is wanting to support ephemeral IPs)

 This adds some unit tests for loopback IP code in particular, as part of reviewing the change
@rtpgrtpgforce-pushed the fix/loopback-redirect-uri branch from ff7c2e2 to 659e1a9CompareApril 5, 2021 15:19
@auvipyauvipy requested a review from n2ygkApril 6, 2021 05:32
@pauldekkers
Copy link
ContributorAuthor

@rtpg Thanks for your modifications and adding those tests, I can now tick the unit-test checkbox too ;-)

FWIW, I've tested your changes locally and of course it works just as well.

@pauldekkers
Copy link
ContributorAuthor

Hi; it looks like this PR is stuck on "changes requested" while I think they were actually applied @auvipy ? I kind of think @rtpg made this PR even better 👍 but I'm not sure where we stand.

@rtpgrtpg dismissed auvipy’s stale reviewApril 12, 2021 13:38

Review comments were handled

Copy link
Contributor

@rtpgrtpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright a bit convoluted but given that @pauldekkers and I have been going back and forth on this I think we can consider this to be reviewed sufficiently

@rtpgrtpg merged commit e5ecd56 into django-oauth:masterApr 12, 2021
@n2ygk
Copy link
Contributor

@rtpg@pauldekkers - Hey welcome to the project. Thanks for your PR. @MattBlack85 and I are trying to be good project leads and stay on top of changes and releases and will try to slot this in to a future release after we review it.

Notably @rtpg I do not see your name in AUTHORS. Please submit a PR to correct that.

@n2ygkn2ygk added this to the 1.5.1 milestone Apr 12, 2021
@kargaj
Copy link

Hi, when you are planning the next release and adding this feature?

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@pauldekkers@rtpg@n2ygk@kargaj@auvipy