Commit 23e06887 authored by Nsukami Patrick's avatar Nsukami Patrick
Browse files

Flake8: fix E301, E302, E305

parent 0bac385cd64d
......@@ -32,6 +32,7 @@ from cubicweb.server.sources import native
from cubicweb_trustedauth.cryptutils import build_cypher
class XRemoteUserAuthentifier(native.BaseAuthentifier):
""" a source authentifier plugin
login comes encrypted + base64 encoded
......
......@@ -16,6 +16,7 @@
from Crypto.Cipher import AES
def build_cypher(key):
""" see
http://www.dlitz.net/software/pycrypto/doc/#crypto-cipher-encryption-algorithms
......
......@@ -20,6 +20,7 @@ from cubicweb import ConfigurationError
CONFENTRY = 'trustedauth-secret-key-file'
def set_secret(config, secretfile):
try:
secret = open(secretfile).read().strip()
......@@ -34,6 +35,8 @@ def set_secret(config, secretfile):
# the presence of this registration callback here is a small hack to
# make sure the secret key file is loaded on both sides of cw (repo
# and web)
def registration_callback(vreg):
secretfile = vreg.config.get(CONFENTRY, "").strip()
if not secretfile:
......
......@@ -21,6 +21,7 @@ from cubicweb.server import hook
from cubicweb_trustedauth.authplugin import XRemoteUserAuthentifier
class ServerStartupHook(hook.Hook):
"""register authentifier at startup"""
__regid__ = 'trustedauth.xremoteuserinit'
......
......@@ -30,6 +30,7 @@ logger = logging.getLogger(__name__)
# authenticated_userid (pyramid_cubicweb expects this method to return
# a CWUser eid).
@implementer(IAuthenticationPolicy)
class TrustedAuthenticationPolicy(object):
......
......@@ -34,6 +34,7 @@ from cubicweb_trustedauth.cryptutils import build_cypher
# web authentication info retreiver ############################################
class XRemoteUserRetriever(authentication.WebAuthInfoRetriever):
""" authenticate by the x-remote-user http header """
__regid__ = 'x-remote-user'
......@@ -86,6 +87,7 @@ class XRemoteUserRetriever(authentication.WebAuthInfoRetriever):
return None
return login
@objectify_predicate
def trust_authenticated(cls, req, rset=None, **kwargs):
return int(getattr(req.cnx, 'trusted_cwuser', False))
......@@ -98,6 +100,7 @@ class LogoutController(basecontrollers.LogoutController):
msg = self._cw.__('you have been logged out')
return self._cw.build_url('view', vid='index', __message=msg)
def registration_callback(vreg):
actions.LogoutAction.__select__ = actions.LogoutAction.__select__ & ~trust_authenticated()
vreg.register_and_replace(LogoutController, basecontrollers.LogoutController)
......
......@@ -18,6 +18,7 @@ class TestController(Controller):
class PyramidTrustedAuthRequestTC(PyramidCWTest):
test_db_id = 'trustedauth'
def includeme(self, config):
includeme(config)
......
......@@ -22,6 +22,7 @@ from cubicweb.web import LogOut
from cubicweb_trustedauth.entities import set_secret
class TrustedAuthTC(CubicWebTC):
@classmethod
......@@ -48,6 +49,7 @@ class TrustedAuthTC(CubicWebTC):
self.assertRaises(LogOut, self.app_publish, req, 'logout')
self.assertEqual(len(self.open_sessions), 0)
if __name__ == "__main__":
from logilab.common.testlib import unittest_main
unittest_main()
[tox]
envlist = py27,py3
envlist = py27,py3,flake8
[testenv]
deps =
......@@ -13,3 +13,14 @@ commands =
python_files = *test_*.py
testpaths = test
addopts = -r fEs
[testenv:flake8]
basepython = python3
skip_install = true
deps =
flake8
commands = flake8
[flake8]
max-line-length=120
exclude = cubicweb_trustedauth/migration/*,test/data/*,.tox/*,cubicweb_trustedauth/wdoc/*
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment