Package restkit :: Package filters :: Module basicauth
[hide private]
[frames] | no frames]

Source Code for Module restkit.filters.basicauth

 1  # -*- coding: utf-8 - 
 2  # 
 3  # This file is part of restkit released under the MIT license.  
 4  # See the NOTICE for more information. 
 5   
 6   
 7  import base64 
 8   
 9   
10 -class BasicAuth(object):
11 """ Simple filter to manage basic authentification""" 12
13 - def __init__(self, username, password):
14 self.credentials = (username, password)
15
16 - def on_request(self, req):
17 encode = base64.b64encode("%s:%s" % self.credentials) 18 req.headers.append(('Authorization', 'Basic %s' % encode))
19