Skip to content

Commit

Permalink
Merge pull request #31 from plone/small-fixes
Browse files Browse the repository at this point in the history
Small fixes
  • Loading branch information
mauritsvanrees authored Aug 24, 2022
2 parents e10c43a + 74caee0 commit ea96eaa
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 15 deletions.
2 changes: 1 addition & 1 deletion news/26.feature.txt → news/26.feature
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Creating per-user keyrings in order to have session invalidation on log-out (server-side logout). [david-batranu]
Creating per-user keyrings in order to have session invalidation on log-out (server-side logout). [david-batranu]
4 changes: 2 additions & 2 deletions plone/session/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from AccessControl.Permissions import add_user_folders
from plone.session.plugins import session
from Products.PluggableAuthService.PluggableAuthService import \
registerMultiPlugin
from Products.PluggableAuthService.PluggableAuthService import registerMultiPlugin


registerMultiPlugin(session.SessionPlugin.meta_type)

Expand Down
2 changes: 1 addition & 1 deletion plone/session/hiddenprofiles.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from zope.interface import implementer
from Products.CMFPlone.interfaces import INonInstallable
from zope.interface import implementer


@implementer(INonInstallable)
Expand Down
14 changes: 10 additions & 4 deletions plone/session/plugins/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,26 @@
from plone.session import tktauth
from plone.session.interfaces import ISessionPlugin
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.PluggableAuthService.interfaces.plugins import IAuthenticationPlugin # noqa
from Products.PluggableAuthService.interfaces.plugins import ICredentialsResetPlugin # noqa
from Products.PluggableAuthService.interfaces.plugins import ICredentialsUpdatePlugin # noqa
from Products.PluggableAuthService.interfaces.plugins import (
IAuthenticationPlugin,
)
from Products.PluggableAuthService.interfaces.plugins import (
ICredentialsResetPlugin,
)
from Products.PluggableAuthService.interfaces.plugins import (
ICredentialsUpdatePlugin,
)
from Products.PluggableAuthService.interfaces.plugins import IExtractionPlugin
from Products.PluggableAuthService.permissions import ManageUsers
from Products.PluggableAuthService.plugins.BasePlugin import BasePlugin
from zope.component import getUtility
from zope.component import queryUtility
from zope.interface import implementer
from zope.interface import alsoProvides

import binascii
import time


EMPTY_GIF = (
'GIF89a\x01\x00\x01\x00\xf0\x01\x00\xff\xff\xff'
'\x00\x00\x00!\xf9\x04\x01\n\x00\x00\x00'
Expand Down
7 changes: 4 additions & 3 deletions plone/session/tests/testDocTests.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# coding=utf-8
from plone.session import tktauth

import doctest
import unittest
import six
import re
import six
import unittest

from plone.session import tktauth

optionflags = doctest.ELLIPSIS

Expand Down
4 changes: 2 additions & 2 deletions plone/session/tests/testPAS.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from DateTime import DateTime
from plone.app.testing import logout
from zope.publisher.browser import TestRequest
from plone.session.interfaces import ISessionPlugin
from plone.session.testing import PLONE_SEESION_FUNCTIONAL_TESTING
from zope.publisher.browser import TestRequest

import base64
import six
Expand Down Expand Up @@ -208,4 +208,4 @@ def testCookieValidAfterLogout(self):

creds = session.extractCredentials(request)
auth = session._validateTicket(creds["cookie"])
self.assertIsNotNone(auth)
self.assertIsNotNone(auth)
7 changes: 5 additions & 2 deletions plone/session/tktauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
>>> data is not None
True
"""
""" # noqa: E501

from socket import inet_aton
from struct import pack
Expand All @@ -153,6 +153,7 @@ def safe_encode(value, encoding='utf-8'):
value = value.encode(encoding)
return value


def safe_text(value, encoding='utf-8'):
"""Converts a value to text, even it is already a text string.
Expand All @@ -177,6 +178,7 @@ def safe_text(value, encoding='utf-8'):
value = value.decode('utf-8', 'replace')
return value


def is_equal(val1, val2):
# constant time comparison
if not isinstance(val1, six.binary_type) or \
Expand Down Expand Up @@ -300,8 +302,9 @@ def validateTicket(secret, ticket, ip='0.0.0.0', timeout=0, now=None,

# doctest runner
def _test():
import doctest
from plone.session.tests.testDocTests import Py23DocChecker

import doctest
doctest.testmod(
optionflags=doctest.ELLIPSIS + doctest.NORMALIZE_WHITESPACE,
checker=Py23DocChecker(),
Expand Down
9 changes: 9 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
[bdist_wheel]
universal = 0

[flake8]
max-line-length = 88

[isort]
profile = black
force_alphabetical_sort=True
force_single_line=True
lines_after_imports=2
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from setuptools import find_packages
from setuptools import setup


version = '4.0.0b2.dev0'
longdescription = open('README.rst').read()
longdescription += '\n'
Expand Down

0 comments on commit ea96eaa

Please sign in to comment.