Add support for included credentials in webhook targets.
Review Request #8916 — Created April 27, 2017 and submitted
Sometimes, a user may need to dispatch a webhook to an authenticated endpoint.
Django (somewhat sensibly) does not allow inline credentials inURLFields
, both
in forms and models, but in this case we want to allow it.This change makes use of a new backport of Django 1.8's URLValidator, which
supports credentials. The URL is then split and credentials (if included) are
pulled out and added to aHTTPBasicAuthHandler
for the url open.
- Verified that I was able to save webhook targets that included credentials
in the URL. - Checked that things that definitely weren't URLs were still rejected.
- Ran unit tests.
Description | From | Last Updated |
---|---|---|
'django.utils.six.moves.urllib.request.urlopen' imported but unused |
reviewbot | |
*args |
chipx86 | |
**kwargs |
chipx86 | |
Shouldn't you be able to just set this on the field itself above using validators=? |
chipx86 | |
This file's missing a file docstring. (Should also be in in docs/manual/coderef/index.rst). |
chipx86 | |
Hmm, I don't know how else we'd handle this, but I sure wish we didn't have to copy this... This … |
chipx86 | |
This will be more readable using the attribute names instead of indexes. |
chipx86 | |
F811 redefinition of unused 'URLValidator' from line 7 |
reviewbot | |
E501 line too long (80 > 79 characters) |
reviewbot | |
E501 line too long (80 > 79 characters) |
reviewbot | |
you can use url_parts.hostname and urlparts.port instead of splitting this. |
brennie | |
This raises an exception: AttributeError: 'SplitResult' object has no attribute 'params' Instead of url_parts.params there should have been a url_params.fragment: … |
YX yxejamir |
- Commit:
-
52b1ac421a622e81e189668bd63520b07c7765969d987acd1c709167ce61d38855d604b8629abf49
Checks run (2 succeeded, 1 failed with error)
- Description:
-
Sometimes, a user may need to dispatch a webhook to an authenticated endpoint.
Django (somewhat sensibly) does not allow inline credentials in URLFields
, bothin forms and models, but in this case we want to allow it. ~ This change adds a new validator that works like Django's
URLValidator
but~ includes the credentials within the regex. The URL is then split and ~ credentials (if included) are pulled out and added to a HTTPBasicAuthHandler
~ This change makes use of a new backport of Django 1.8's URLValidator, which
~ supports credentials. The URL is then split and credentials (if included) are ~ pulled out and added to a HTTPBasicAuthHandler
for the url open.- for the url open. - Commit:
-
9d987acd1c709167ce61d38855d604b8629abf49bac403535da00dc334c5dcd6ba4435efd2fd8b6c
- Commit:
-
bac403535da00dc334c5dcd6ba4435efd2fd8b6c427b75da2e9d42c35e11eb5a8cea4908b6e51186