Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2715 from Pylons/bugfix/authtkt_bad_cookie
Fix AuthTktCookieHelper so that it doesn't create bad cookies
  • Loading branch information
mmerickel committed Sep 1, 2016
2 parents ab0be8a + cf428a8 commit 9f77472
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pyramid/authentication.py
Expand Up @@ -5,6 +5,7 @@
import base64
import re
import time as time_mod
import warnings

from zope.interface import implementer

Expand Down Expand Up @@ -947,8 +948,19 @@ def remember(self, request, userid, max_age=None, tokens=()):

if encoding_data:
encoding, encoder = encoding_data
userid = encoder(userid)
user_data = 'userid_type:%s' % encoding
else:
warnings.warn(
"userid is of type {}, and is not supported by the "
"AuthTktAuthenticationPolicy. Explicitly converting to string "
"and storing as base64. Subsequent requests will receive a "
"string as the userid, it will not be decoded back to the type "
"provided.".format(type(userid)), RuntimeWarning
)
encoding, encoder = self.userid_type_encoders.get(text_type)
userid = str(userid)

userid = encoder(userid)
user_data = 'userid_type:%s' % encoding

new_tokens = []
for token in tokens:
Expand Down

0 comments on commit 9f77472

Please sign in to comment.