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/z4X2qaCpW/GHS+XFccT1h8CxqsFxnAhnecjdMCv/TJLXMNk9LihEeUEZo
4U7bitCfyO17dt6NC/7wbGZCJmNPO7V3YYeI8MwzOkvmXqLcHz0IPQATuLMB1HKr
oG/Vrwq029ftqnuDluS/DzmuIqWLuAT+2nIe1JLWFlS9OUTi4i+y0NDlxWCZOaGp
ucR+ueFKv1de3nVjdd6oN+MIO9gQ3NE53FrO46A3APy6Ex02Mxub8nNnQjXcStHZ
BHO6KilQ+QLzSektD8IpHM7tR6P+5PP6AQ==
=NePe
-----END PGP PUBLIC KEY BLOCK-----
On 25/12/2022 20.52, tristant wrote:
> Is there a mechanism in Django where we can identify the location of
> login? Any reading sources regarding this functionality would be much
> appreciated.
>

What you're looking for is something called geoip. To the best of my
knowledge there's no such thing build into Django (wouldn't really make
much sense anyway) but it should be trivial to query some geoip database
from your code and get a somewhat reliable idea on where that IP is
coming from.

There's no way that can be accurate but it might be useful for something
like detecting a locale (that the user can then change) or similar.


> Along the same line, is there a way to prevent a login attempt if the
> location is within certain blacklisted IP subnets?
>

It is trivial to spoof a source IP address once you reach the Django
application part of the communication. That's more of a feature than a
bug actually because of things like proxies etc.

If you want to blacklist IPs you have to do that on a lower level. For a
single server running Linux something like netfilter/iptables might be
used but I'm sure there are some more convenient scripts/services etc.
that might be used. The main point is that you cannot do this from your
Django code.

Hope that helps you in the right direction.

Kind regards,
Kasper Laudrup

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e83a7b85-6fd3-ced8-b4bf-fdf77650cfe8%40stacktrace.dk.

No comments:

Post a Comment