Changes between Version 9 and Version 10 of CookBookIPAccessMiddleware


Ignore:
Timestamp:
Dec 22, 2006, 3:44:43 AM (17 years ago)
Author:
anonymous
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CookBookIPAccessMiddleware

    v9 v10  
    33== The idea ==
    44
    5 Controling IP access in your web app. The idea provided in this cookbook let you define specific ip addresses, and controlling accessing from those ips. If an user access from a certain IP, automatically authenticates with a defined user.
     5The idea of this recipe is to provide automatic user authentication based on specified IP addresses for some client computers.
    66
    77== IPAccess Model ==
    88
    9 You must define a model that permits defining a tuple (ip addr, user): ip from browser that connect, and users that authenticated.
     9You must define a model that allows defining tuples of type (IP addr, user): IP of the client computer with the web browser, user to be authenticated.
    1010
    11 This is the model proposed (it would be in a file like ''myproj/myapp/models.py''):
     11This is the proposed model (suppose ''myproj/myapp/models.py''):
    1212
    1313{{{
     
    3434== IPAccess Middleware ==
    3535
    36 Middleware mission is authenticate automatically with an user defined in models, '''only if''' the browser remote ip address exists in ''IPAccess'' table.
     36The mission of this middleware is to authenticate automatically with an user defined in models, '''only if''' the browser's remote IP address exists in the ''IPAccess'' table.
    3737
    3838This is the code (in file ''myproj/myapp/middleware.py''):
     
    5858== Settings ==
    5959
    60 The middleware installation requires you insert ''IPAccessMiddleware'' into ''MIDDLEWARE_CLASSES''. Obviusly, it also requires the installation of ''!AuthenticationMiddleware''.
     60For the middleware to work, you have to insert a line with ''IPAccessMiddleware'' into ''MIDDLEWARE_CLASSES'' of the settings.py file. Obviously, it also requires the installation of ''!AuthenticationMiddleware''.
    6161
    62 The code would be like that:
     62The code should be something like this:
    6363
    6464{{{
     
    6969    'django.contrib.auth.middleware.AuthenticationMiddleware',
    7070    'django.middleware.doc.XViewMiddleware',
    71     'aceprensa.apps.news.middleware.IPAccessMiddleware',
     71    'yourproject.apps.news.middleware.IPAccessMiddleware',
    7272)
    7373
    7474}}}
    7575
    76 == Complete Application ==
     76== A Complete Application ==
    7777
    78 I also developed [attachment:ipaccess.tgz ipaccess application] which offers this functionality. For installing you have to untar compressed application and put in ''apps'' directory in your project. Then, you have to ''update'' import statements and add to applications installed settings:
     78I also developed [attachment:ipaccess.tgz ipaccess an application] which offers this functionality. To install it, just untar the files in this archive and put it in ''apps'' directory in your project, then ''change'' the import statements and add a two lines to the settings.py file:
    7979
    8080{{{
     
    9292
    9393}}}
     94
     95
     96Have fun.
Back to Top