[web] move AbstractAuthManager near its immediate concrete subclass
Related to #1381328.
--- a/web/application.py Thu Feb 13 16:32:41 2014 +0100
+++ b/web/application.py Thu Feb 13 16:37:40 2014 +0100
@@ -62,35 +62,6 @@
-class AbstractAuthenticationManager(component.Component):
- """authenticate user associated to a request and check session validity"""
- __regid__ = 'authmanager'
-
- def __init__(self, repo):
- self.vreg = repo.vreg
-
- def validate_session(self, req, session):
- """check session validity, reconnecting it to the repository if the
- associated connection expired in the repository side (hence the
- necessity for this method).
-
- raise :exc:`InvalidSession` if session is corrupted for a reason or
- another and should be closed
- """
- raise NotImplementedError()
-
- def authenticate(self, req):
- """authenticate user using connection information found in the request,
- and return corresponding a :class:`~cubicweb.dbapi.Connection` instance,
- as well as login and authentication information dictionary used to open
- the connection.
-
- raise :exc:`cubicweb.AuthenticationError` if authentication failed
- (no authentication info found or wrong user/password)
- """
- raise NotImplementedError()
-
-
class CookieSessionHandler(object):
"""a session handler using a cookie to store the session identifier"""
--- a/web/views/authentication.py Thu Feb 13 16:32:41 2014 +0100
+++ b/web/views/authentication.py Thu Feb 13 16:37:40 2014 +0100
@@ -27,7 +27,7 @@
from cubicweb import AuthenticationError, BadConnectionId
from cubicweb.view import Component
from cubicweb.web import InvalidSession
-from cubicweb.web.application import AbstractAuthenticationManager
+
class NoAuthInfo(Exception): pass
@@ -101,6 +101,36 @@
'("ie" instead of "ei")')
+class AbstractAuthenticationManager(Component):
+ """authenticate user associated to a request and check session validity"""
+ __abstract__ = True
+ __regid__ = 'authmanager'
+
+ def __init__(self, repo):
+ self.vreg = repo.vreg
+
+ def validate_session(self, req, session):
+ """check session validity, reconnecting it to the repository if the
+ associated connection expired in the repository side (hence the
+ necessity for this method).
+
+ raise :exc:`InvalidSession` if session is corrupted for a reason or
+ another and should be closed
+ """
+ raise NotImplementedError()
+
+ def authenticate(self, req):
+ """authenticate user using connection information found in the request,
+ and return corresponding a :class:`~cubicweb.dbapi.Connection` instance,
+ as well as login and authentication information dictionary used to open
+ the connection.
+
+ raise :exc:`cubicweb.AuthenticationError` if authentication failed
+ (no authentication info found or wrong user/password)
+ """
+ raise NotImplementedError()
+
+
class RepositoryAuthenticationManager(AbstractAuthenticationManager):
"""authenticate user associated to a request and check session validity"""