CentreForDigitalHumanities / CentreForDigitalHumanities/Development-IdP

Django's URLValidator prevents talking to hosts without a domain

Open
#6 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

But wait, isn't `localhost` a domainless hostname? That works right?

Correct, but `localhost` is a hard-coded exception in the regex jungle of Django URL validation. A metadata URL like `http://django:8000/saml/metadata/` will not work, and cause a subsequent `KeyError` in `SPCreateForm`.

These kinds of hostnames actually come up quite a bit. When running multiple related containers using docker-compose each container (by default) gets a hostname from its service name. So your app, IdP, database, and gateway would each communicate with each other with hostnames like `django`, `idp`, `postgres`, and `nginx`.

Thankfully there's a workaround in docker-compose which involves manually aliasing hosts to `whatever.local` in your network yaml. But it would be nicer to fix it here, as this will come up in practically every Docker deployment.

My suggested solution would be to just turn the `metadata_url` field into a CharField. My dev tools don't need no fancy validation. If that's good with you @tymees I'll include this change in the Dockerfile PR.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.