Exemplo n.º 1
0
 def getAuthCookie(self, userid):
     """ It fakes the cookie (__ac) """
     acl_users = getToolByName(self.context, "acl_users")
     cookie = tktauth.createTicket(
         secret=acl_users.session._getSigningSecret(), userid=userid, mod_auth_tkt=False, encoding="utf-8"
     )
     cookie = binascii.b2a_base64(cookie).rstrip()
     return {"__ac": cookie}
Exemplo n.º 2
0
 def _setupSession(self, userid, response, tokens=(), user_data=''):
     cookie = tktauth.createTicket(secret=self._getSigningSecret(),
                                   userid=userid,
                                   tokens=tokens,
                                   user_data=user_data,
                                   mod_auth_tkt=self.mod_auth_tkt,
                                   encoding="utf-8")
     self._setCookie(cookie, response)
Exemplo n.º 3
0
 def _setupSession(self, userid, response, tokens=(), user_data=u''):
     cookie = tktauth.createTicket(
         secret=self._getSigningSecret(),
         userid=userid,
         tokens=tokens,
         user_data=user_data,
         mod_auth_tkt=self.mod_auth_tkt,
         )
     self._setCookie(cookie, response)
 def _makeTicket(self, userid='userid', remote_addr='0.0.0.0',
                 tokens=tuple(), userdata='userdata',
                 cookie_name='auth_tkt', enhanced_hashing=True,
                 time=None):
     import binascii
     from plone.session.tktauth import createTicket
     tkt = createTicket('secret', userid, tokens, userdata, ip=remote_addr,
                  timestamp=time, mod_auth_tkt=enhanced_hashing)
     return binascii.b2a_base64(tkt).strip()
Exemplo n.º 5
0
def encode(secret_key, email):
    """
    Encode email with secret key and current timestamp
    Return url safe string
    """
    timestamp = time.time()
    ticket = tktauth.createTicket(secret_key, email, timestamp=timestamp)
    urlsafe_string = base64.urlsafe_b64encode(ticket)
    return urlsafe_string
Exemplo n.º 6
0
 def _initCookie(self,userid,tokens=(),user_data=''):
     #_setupSession(self, userid, response, tokens=(), user_data=''):
     cookie = tktauth.createTicket(
         secret=self._getSigningSecret(),
         userid=userid,
         tokens=tokens,
         user_data=user_data,
         mod_auth_tkt=self.mod_auth_tkt,
     )
     cookie = binascii.b2a_base64(cookie).rstrip()
     return cookie
Exemplo n.º 7
0
 def getAuthCookie(self, userid):
     """ It fakes the cookie (__ac) """
     acl_users = getToolByName(self.context, 'acl_users')
     cookie = tktauth.createTicket(
         secret=acl_users.session._getSigningSecret(),
         userid=userid,
         mod_auth_tkt=False,
         encoding='utf-8',
     )
     cookie = binascii.b2a_base64(cookie).rstrip()
     return {'__ac': cookie}
 def _makeTicket(self,
                 userid='userid',
                 remote_addr='0.0.0.0',
                 tokens=tuple(),
                 userdata='userdata',
                 cookie_name='auth_tkt',
                 enhanced_hashing=True,
                 time=None):
     import binascii
     from plone.session.tktauth import createTicket
     tkt = createTicket('secret',
                        userid,
                        tokens,
                        userdata,
                        ip=remote_addr,
                        timestamp=time,
                        mod_auth_tkt=enhanced_hashing)
     return binascii.b2a_base64(tkt).strip()