Skip to content

Conversation

@TamiTakamiya
Copy link
Contributor

For AAP-18031

@TamiTakamiya TamiTakamiya force-pushed the ttakamiy/AAP-18031/GitHub-Codespaces-Support-PoC branch from bdb380e to 24611cb Compare November 14, 2023 13:26
@ansible ansible deleted a comment from github-actions bot Nov 14, 2023
@ansible ansible deleted a comment from github-actions bot Nov 14, 2023
@ansible ansible deleted a comment from github-actions bot Nov 14, 2023
@ansible ansible deleted a comment from github-actions bot Nov 14, 2023
@ansible ansible deleted a comment from github-actions bot Nov 14, 2023
@ansible ansible deleted a comment from github-actions bot Nov 14, 2023
@ansible ansible deleted a comment from github-actions bot Nov 14, 2023
@ansible ansible deleted a comment from github-actions bot Nov 14, 2023
@ansible ansible deleted a comment from github-actions bot Nov 14, 2023
@TamiTakamiya TamiTakamiya force-pushed the ttakamiy/AAP-18031/GitHub-Codespaces-Support-PoC branch from 2aaafb6 to ca88f5e Compare November 15, 2023 13:08
@ansible ansible deleted a comment from github-actions bot Nov 15, 2023
@TamiTakamiya TamiTakamiya force-pushed the ttakamiy/AAP-18031/GitHub-Codespaces-Support-PoC branch from ca88f5e to 9be812b Compare November 15, 2023 14:31
@ansible ansible deleted a comment from github-actions bot Nov 15, 2023
@ansible ansible deleted a comment from github-actions bot Nov 15, 2023
@TamiTakamiya TamiTakamiya force-pushed the ttakamiy/AAP-18031/GitHub-Codespaces-Support-PoC branch 2 times, most recently from 66521d6 to 0eb0c40 Compare November 16, 2023 03:00
@ansible ansible deleted a comment from github-actions bot Nov 16, 2023
@TamiTakamiya TamiTakamiya force-pushed the ttakamiy/AAP-18031/GitHub-Codespaces-Support-PoC branch from 0eb0c40 to 69b52c4 Compare November 22, 2023 00:15
@ansible ansible deleted a comment from github-actions bot Nov 22, 2023
@ansible ansible deleted a comment from github-actions bot Nov 22, 2023
@TamiTakamiya TamiTakamiya force-pushed the ttakamiy/AAP-18031/GitHub-Codespaces-Support-PoC branch from 1f823eb to 8ca575a Compare November 24, 2023 00:56
@ansible ansible deleted a comment from github-actions bot Nov 24, 2023
@TamiTakamiya TamiTakamiya force-pushed the ttakamiy/AAP-18031/GitHub-Codespaces-Support-PoC branch from 8ca575a to ee4afee Compare November 24, 2023 15:12
@ansible ansible deleted a comment from github-actions bot Nov 24, 2023
@TamiTakamiya TamiTakamiya force-pushed the ttakamiy/AAP-18031/GitHub-Codespaces-Support-PoC branch from ee4afee to 5a413ed Compare November 27, 2023 15:57
@ansible ansible deleted a comment from github-actions bot Nov 27, 2023
@TamiTakamiya TamiTakamiya marked this pull request as ready for review November 27, 2023 16:26
"""


default_app_config = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this? It looks like default_app_config was deprecated and then removed from django.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. I just copied from the URL in the comment and that's the only reason that I included it here.

I found there was a PR on removing default_app_config from django-oauth-toolkit as well. I will remove that line.

def _uri_is_allowed(allowed_uri, uri):
"""Check that the URI conforms to these rules."""
schemes_match = allowed_uri.scheme == uri.scheme
netloc_matches_pattern = re.fullmatch(allowed_uri.netloc, 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.

While I know we discussed that we would be very careful with our regexs that we specify in our applications, should we also consider enforcing e.g. that the top level domain is an exact match, and only the subdomain can have a wildcard? I came across this wildcard_redirect support in okta that takes this approach and seems to help limit the risk: https://developer.okta.com/docs/reference/api/apps/#details

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current implementation accepts general expressions, but if we put limitations like Okta's implementation, we should just support "wildcard" ('*') even though we will use regex in internal processing. I will re-design this part in that way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have implemented a new design in the latest commit:

  • Instead of accepting a given string for allowed URI as a regex pattern, allow only wildcards (asterisk *) in a redirect URI
  • A wildcard matches any (0 or more) characters except for slashes (/).
  • In a netloc part, wildcards should appear only in the subdomain, not in the root domain.
  • Matching with wildcards is not performed against IP addresses. For example, even if an allowed URI is set to http://*.*.0.1:8080/callback, http://123.123.0.1:8080/callback does not match to it.

}

#
# We need to run 'manage.py migrate' before adding our own OAuth2 application model.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be seeing a migration file in this PR for this new application? Assuming yes, I'm not entirely clear on the order of operations for getting everything set up correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, we will not have a new migration file with this PR. The new "wildcard" OAuth app will swap the default app as it is defined as "swappable" and the same db table will be used as the default one,

Copy link
Contributor

@robinbobbitt robinbobbitt left a comment

Choose a reason for hiding this comment

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

This is awesome work and I'm excited to get it in! Sent you a few comments and questions. Thanks!

@ansible ansible deleted a comment from github-actions bot Dec 5, 2023
@TamiTakamiya
Copy link
Contributor Author

@robinbobbitt I have addressed to your comments in the latest commit. Would you take a look? Thank you!

@robinbobbitt
Copy link
Contributor

For anybody else testing this PR, Jeff's test script here is handy: #84 (comment)

Copy link
Contributor

@robinbobbitt robinbobbitt left a comment

Choose a reason for hiding this comment

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

Thanks @TamiTakamiya ! This looks great. I tested with valid and invalid redirect uris in the Application configuration and in the authorize flow and all looks good.

@TamiTakamiya TamiTakamiya merged commit c1afdef into main Dec 7, 2023
@TamiTakamiya TamiTakamiya deleted the ttakamiy/AAP-18031/GitHub-Codespaces-Support-PoC branch December 7, 2023 20:38
Sign up for free to 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.

2 participants