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 aHTTPBasicAuthHandlerfor 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 |
|
|
|
*args |
|
|
|
**kwargs |
|
|
|
Shouldn't you be able to just set this on the field itself above using validators=? |
|
|
|
This file's missing a file docstring. (Should also be in in docs/manual/coderef/index.rst). |
|
|
|
Hmm, I don't know how else we'd handle this, but I sure wish we didn't have to copy this... This … |
|
|
|
This will be more readable using the attribute names instead of indexes. |
|
|
|
F811 redefinition of unused 'URLValidator' from line 7 |
|
|
|
E501 line too long (80 > 79 characters) |
|
|
|
E501 line too long (80 > 79 characters) |
|
|
|
you can use url_parts.hostname and urlparts.port instead of splitting this. |
|
|
|
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
URLValidatorbut~ 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 HTTPBasicAuthHandlerfor the url open.- for the url open. - Commit:
-
9d987acd1c709167ce61d38855d604b8629abf49bac403535da00dc334c5dcd6ba4435efd2fd8b6c
- Commit:
-
bac403535da00dc334c5dcd6ba4435efd2fd8b6c427b75da2e9d42c35e11eb5a8cea4908b6e51186