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

Perhaps this needs to be improved, or at least documented #7

Closed
avianna opened this issue Jan 22, 2021 · 2 comments
Closed

Perhaps this needs to be improved, or at least documented #7

avianna opened this issue Jan 22, 2021 · 2 comments

Comments

@avianna
Copy link

avianna commented Jan 22, 2021

https://github.com/tm-kn/django-basic-auth-ip-whitelist/blob/318006b15b598c035cf52031c8fa63dbf241440f/baipw/utils.py#L23

This is the situation:

  • this default get_client_ip is called by self._get_client_ip()
  • which takes whatever this returns and passes it to ipaddress.ip_address()
  • which doesn't accept None as an input
  • so if this code path is hit, ipaddress.ip_address() will exception out
  • but baipw doesn't handle this exception, so it just escalates up, and the whole app just ends up 500-ing.

So this code path is problematic, if there isn't a saner return, then at least maybe warn others that if this code branch is hit, the app will blow up.

@tm-kn
Copy link
Member

tm-kn commented Feb 3, 2021

I have a plan to re-work getting the IP. The current way is quite flimsy as you've noticed yourself.

@tm-kn
Copy link
Member

tm-kn commented Feb 3, 2021

Closing in favour of #9. Pull requests welcome if you want to update the documentation.

@tm-kn tm-kn closed this as completed Feb 3, 2021
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

No branches or pull requests

2 participants