25 from logilab.common.deprecation import class_renamed |
25 from logilab.common.deprecation import class_renamed |
26 |
26 |
27 from cubicweb import AuthenticationError, BadConnectionId |
27 from cubicweb import AuthenticationError, BadConnectionId |
28 from cubicweb.view import Component |
28 from cubicweb.view import Component |
29 from cubicweb.web import InvalidSession |
29 from cubicweb.web import InvalidSession |
30 from cubicweb.web.application import AbstractAuthenticationManager |
30 |
31 |
31 |
32 class NoAuthInfo(Exception): pass |
32 class NoAuthInfo(Exception): pass |
33 |
33 |
34 |
34 |
35 class WebAuthInfoRetriever(Component): |
35 class WebAuthInfoRetriever(Component): |
97 |
97 |
98 LoginPasswordRetreiver = class_renamed( |
98 LoginPasswordRetreiver = class_renamed( |
99 'LoginPasswordRetreiver', LoginPasswordRetriever, |
99 'LoginPasswordRetreiver', LoginPasswordRetriever, |
100 '[3.17] LoginPasswordRetreiver had been renamed into LoginPasswordRetriever ' |
100 '[3.17] LoginPasswordRetreiver had been renamed into LoginPasswordRetriever ' |
101 '("ie" instead of "ei")') |
101 '("ie" instead of "ei")') |
|
102 |
|
103 |
|
104 class AbstractAuthenticationManager(Component): |
|
105 """authenticate user associated to a request and check session validity""" |
|
106 __abstract__ = True |
|
107 __regid__ = 'authmanager' |
|
108 |
|
109 def __init__(self, repo): |
|
110 self.vreg = repo.vreg |
|
111 |
|
112 def validate_session(self, req, session): |
|
113 """check session validity, reconnecting it to the repository if the |
|
114 associated connection expired in the repository side (hence the |
|
115 necessity for this method). |
|
116 |
|
117 raise :exc:`InvalidSession` if session is corrupted for a reason or |
|
118 another and should be closed |
|
119 """ |
|
120 raise NotImplementedError() |
|
121 |
|
122 def authenticate(self, req): |
|
123 """authenticate user using connection information found in the request, |
|
124 and return corresponding a :class:`~cubicweb.dbapi.Connection` instance, |
|
125 as well as login and authentication information dictionary used to open |
|
126 the connection. |
|
127 |
|
128 raise :exc:`cubicweb.AuthenticationError` if authentication failed |
|
129 (no authentication info found or wrong user/password) |
|
130 """ |
|
131 raise NotImplementedError() |
102 |
132 |
103 |
133 |
104 class RepositoryAuthenticationManager(AbstractAuthenticationManager): |
134 class RepositoryAuthenticationManager(AbstractAuthenticationManager): |
105 """authenticate user associated to a request and check session validity""" |
135 """authenticate user associated to a request and check session validity""" |
106 |
136 |