[web] move AbstractAuthManager near its immediate concrete subclass

Related to #1381328.

authorAurelien Campeas <aurelien.campeas@logilab.fr>
changeset2d3c01e64d2e
branchdefault
phasedraft
hiddenyes
parent revision#d96e33bcbc42 [web] move abstract session manager to web/sessions
child revision#225ecd5942ef [web] the AuthenticationMAnager is no more an appobject
files modified by this revision
web/application.py
web/views/authentication.py
# HG changeset patch
# User Aurelien Campeas <aurelien.campeas@logilab.fr>
# Date 1392305860 -3600
# Thu Feb 13 16:37:40 2014 +0100
# Node ID 2d3c01e64d2e1a99335c84b1e3870845755504eb
# Parent d96e33bcbc425067201ef70d1e90a720c46ba30a
[web] move AbstractAuthManager near its immediate concrete subclass

Related to #1381328.

diff --git a/web/application.py b/web/application.py
@@ -60,39 +60,10 @@
1      finally:
2          req.set_cnx(orig_cnx)
3 
4 
5 
6 -class AbstractAuthenticationManager(component.Component):
7 -    """authenticate user associated to a request and check session validity"""
8 -    __regid__ = 'authmanager'
9 -
10 -    def __init__(self, repo):
11 -        self.vreg = repo.vreg
12 -
13 -    def validate_session(self, req, session):
14 -        """check session validity, reconnecting it to the repository if the
15 -        associated connection expired in the repository side (hence the
16 -        necessity for this method).
17 -
18 -        raise :exc:`InvalidSession` if session is corrupted for a reason or
19 -        another and should be closed
20 -        """
21 -        raise NotImplementedError()
22 -
23 -    def authenticate(self, req):
24 -        """authenticate user using connection information found in the request,
25 -        and return corresponding a :class:`~cubicweb.dbapi.Connection` instance,
26 -        as well as login and authentication information dictionary used to open
27 -        the connection.
28 -
29 -        raise :exc:`cubicweb.AuthenticationError` if authentication failed
30 -        (no authentication info found or wrong user/password)
31 -        """
32 -        raise NotImplementedError()
33 -
34 -
35  class CookieSessionHandler(object):
36      """a session handler using a cookie to store the session identifier"""
37 
38      def __init__(self, appli):
39          self.repo = appli.repo
diff --git a/web/views/authentication.py b/web/views/authentication.py
@@ -25,11 +25,11 @@
40  from logilab.common.deprecation import class_renamed
41 
42  from cubicweb import AuthenticationError, BadConnectionId
43  from cubicweb.view import Component
44  from cubicweb.web import InvalidSession
45 -from cubicweb.web.application import AbstractAuthenticationManager
46 +
47 
48  class NoAuthInfo(Exception): pass
49 
50 
51  class WebAuthInfoRetriever(Component):
@@ -99,10 +99,40 @@
52      'LoginPasswordRetreiver', LoginPasswordRetriever,
53      '[3.17] LoginPasswordRetreiver had been renamed into LoginPasswordRetriever '
54      '("ie" instead of "ei")')
55 
56 
57 +class AbstractAuthenticationManager(Component):
58 +    """authenticate user associated to a request and check session validity"""
59 +    __abstract__ = True
60 +    __regid__ = 'authmanager'
61 +
62 +    def __init__(self, repo):
63 +        self.vreg = repo.vreg
64 +
65 +    def validate_session(self, req, session):
66 +        """check session validity, reconnecting it to the repository if the
67 +        associated connection expired in the repository side (hence the
68 +        necessity for this method).
69 +
70 +        raise :exc:`InvalidSession` if session is corrupted for a reason or
71 +        another and should be closed
72 +        """
73 +        raise NotImplementedError()
74 +
75 +    def authenticate(self, req):
76 +        """authenticate user using connection information found in the request,
77 +        and return corresponding a :class:`~cubicweb.dbapi.Connection` instance,
78 +        as well as login and authentication information dictionary used to open
79 +        the connection.
80 +
81 +        raise :exc:`cubicweb.AuthenticationError` if authentication failed
82 +        (no authentication info found or wrong user/password)
83 +        """
84 +        raise NotImplementedError()
85 +
86 +
87  class RepositoryAuthenticationManager(AbstractAuthenticationManager):
88      """authenticate user associated to a request and check session validity"""
89 
90      def __init__(self, repo):
91          super(RepositoryAuthenticationManager, self).__init__(repo)