sageteamorg / django-sage-tools

Reusable, generic mixins for Django
MIT License
6 stars 5 forks source link

✨ Add IP Restriction Mixin Django View #18

Open ARYAN-NIKNEZHAD opened 4 months ago

ARYAN-NIKNEZHAD commented 4 months ago

Description

We need to implement a mixin that restricts access to Django views based on client IP addresses. This mixin will help in adding an additional layer of security by allowing or denying access to specific IP addresses.

Requirements

  1. Mixin Functionality:

    • Create a mixin class IPRestrictionMixin that can be used with Django views.
    • Allow specifying allowed and denied IP addresses as class attributes.
    • Implement methods to check the client’s IP address against the allowed and denied lists.
    • Provide clear error messages when access is denied.
  2. Integration:

    • Ensure compatibility with existing authentication and permission systems.

Acceptance Criteria