Changeset 8665 for mauRepo/dj_security


Ignore:
Timestamp:
06/11/12 09:05:35 (7 years ago)
Author:
mnagni
Message:

Small refactoring and fix the name of context_processor module

Location:
mauRepo/dj_security/trunk
Files:
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • mauRepo/dj_security/trunk/README

    r8664 r8665  
    99 
    10101) APPLICATION_ROOT: the root where the HTTP service is available, say "dj_security" 
    11 2) the deafult dataset 'DB_xxx' parameters, that is: 
     112) SHARED_SECRET: the secret key used to encrypt the generated 'auth_tkt' cookie 
     123) the deafult dataset 'DB_xxx' parameters, that is: 
    1213'ENGINE':   'DB_ENGINE',  
    1314'NAME':     'DB_NAME', 
  • mauRepo/dj_security/trunk/dj_security/settings.py

    r8664 r8665  
    132132) 
    133133 
     134SHARED_SECRET = 'sharedsecret'    
    134135APPLICATION_ROOT = 'PROJECT_NAME_PAR/' 
    135136if APPLICATION_ROOT.startswith('PROJECT_NAME_'): 
  • mauRepo/dj_security/trunk/dj_security/views/my_profile.py

    r8652 r8665  
    99from paste.auth.auth_tkt import BadTicket 
    1010from paste.auth import auth_tkt 
     11from django.conf import settings 
    1112 
    1213def get_user_profile(request): 
     
    2526    context = {} 
    2627    if request.COOKIES.has_key('auth_tkt'): 
    27         try: 
    28             timestamp, userid, tokens, user_data = auth_tkt.parse_ticket( 
    29                     'sharedsecret', request.COOKIES['auth_tkt'], '127.0.0.1') 
     28        try:   
     29            timestamp, userid, tokens, user_data = \ 
     30                auth_tkt.parse_ticket( 
     31                        getattr(settings, 'SHARED_SECRET', 'sharedsecret'),  
     32                        request.COOKIES['auth_tkt'],  
     33                        request.META['REMOTE_ADDR']) 
    3034 
     35            context['timestamp'] = timestamp 
    3136            context['username'] = userid 
     37            context['tokens'] = tokens                         
     38            context['user_data'] = user_data 
    3239            return render_to_response('logged_in.html', context) 
    33         except BadTicket as ex: 
     40        except BadTicket: 
    3441            pass 
    3542         
  • mauRepo/dj_security/trunk/dj_security/views/my_view.py

    r8650 r8665  
    1010from django.http import HttpResponseRedirect 
    1111from paste.auth.auth_tkt import AuthTicket 
     12from django.conf import settings 
    1213 
    1314def errorHandle(request, context): 
     
    3435                    #}) 
    3536                     
    36                     token = AuthTicket('sharedsecret', username, request.META['REMOTE_ADDR']) 
     37                    token = AuthTicket(getattr(settings, 'SHARED_SECRET', 'sharedsecret'), username, request.META['REMOTE_ADDR']) 
    3738                    #self.request().environ()['REMOTE_ADDR'], tokens=['admin']) 
    3839                    #self.response().setCookie('auth_tkt', token.cookie_value()) 
Note: See TracChangeset for help on using the changeset viewer.