Authenticate by IP address in Django

后端 未结 6 1959
别那么骄傲
别那么骄傲 2020-12-24 15:08

I have a small Django application with a view that I want to restrict to certain users. Anyone from a specific network should be able to see that view without any further au

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-24 15:38

    There's no need to write an authentication backend for the use case you have written. Writing an IP based dispatcher in the middleware layer will likely be sufficient

    If your app's url(s) is/are matched, process_request should check for an authenticated django user and match that user to a whitelist.

提交回复
热议问题