Show More
@@ -1298,7 +1298,7 b' def set_available_permissions(config):' | |||
|
1298 | 1298 | meta.Session.remove() |
|
1299 | 1299 | |
|
1300 | 1300 | |
|
1301 |
def get_csrf_token(session |
|
|
1301 | def get_csrf_token(session, force_new=False, save_if_missing=True): | |
|
1302 | 1302 | """ |
|
1303 | 1303 | Return the current authentication token, creating one if one doesn't |
|
1304 | 1304 | already exist and the save_if_missing flag is present. |
@@ -1311,9 +1311,6 b' def get_csrf_token(session=None, force_n' | |||
|
1311 | 1311 | # NOTE(marcink): probably should be replaced with below one from pyramid 1.9 |
|
1312 | 1312 | # from pyramid.csrf import get_csrf_token |
|
1313 | 1313 | |
|
1314 | if not session: | |
|
1315 | from pylons import session | |
|
1316 | ||
|
1317 | 1314 | if (csrf_token_key not in session and save_if_missing) or force_new: |
|
1318 | 1315 | token = hashlib.sha1(str(random.getrandbits(128))).hexdigest() |
|
1319 | 1316 | session[csrf_token_key] = token |
@@ -1372,7 +1369,7 b' class CSRFRequired(object):' | |||
|
1372 | 1369 | if request.method in self.except_methods: |
|
1373 | 1370 | return func(*fargs, **fkwargs) |
|
1374 | 1371 | |
|
1375 | cur_token = get_csrf_token(save_if_missing=False) | |
|
1372 | cur_token = get_csrf_token(request.session, save_if_missing=False) | |
|
1376 | 1373 | if self.check_csrf(request, cur_token): |
|
1377 | 1374 | if request.POST.get(self.token): |
|
1378 | 1375 | del request.POST[self.token] |
General Comments 0
You need to be logged in to leave comments.
Login now