Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for LDAPServerFieldURI error if number present in top-level-domain #4774

Closed

Conversation

fosterseth
Copy link
Member

SUMMARY

related to #3646

LDAP server URI field does not validate if top-level-domain contains a number, throwing a generic 400 error to the user.

The URI field is passed to a built-in django validator that does a regex match to check for validity.

This URI validator can take in a custom regex. My solution sets up a custom regex in the LDAPServerURIField class and passes it to the URLValidator that is appended in the parent class init.

For the custom regex, I simply grabbed the default URLValidator regex defined here,
https://github.com/django/django/blob/55b68de643b5c2d5f0a8ea7587ab3b2966021ccc/django/core/validators.py#L89

and added number capabilities,

r'(?:[a-z' + URLValidator.ul + r'0-9' + '-]{2,63}' # domain label

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
  • API
AWX VERSION
awx: 7.0.0

ADDITIONAL INFORMATION

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@fosterseth fosterseth requested review from abenokraitis, AlanCoding and jbradberry and removed request for abenokraitis September 18, 2019 15:35
Copy link
Member

@AlanCoding AlanCoding left a comment

Choose a reason for hiding this comment

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

Looks like this is shaping up well!

Let's get some unit tests

…unit test makes sure valid URIs, including ones with numbers in top level domain, are cleanly passed through the run_validators() method. It also checks that an invalid URI raises the correct exception.
@fosterseth fosterseth closed this Sep 19, 2019
@fosterseth fosterseth deleted the fix-lpadservername-validator branch September 19, 2019 15:14
@fosterseth fosterseth changed the title fix for LPADServerFieldURI error if number present in top-level-domain fix for LDAPServerFieldURI error if number present in top-level-domain Sep 19, 2019
chrismeyersfsu pushed a commit to chrismeyersfsu/awx that referenced this pull request Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants