|
| 1 | +from authlib.common.errors import ContinueIteration |
1 | 2 | from .authenticate_client import ClientAuthentication |
2 | 3 | from .requests import OAuth2Request, JsonRequest |
3 | 4 | from .errors import ( |
@@ -186,7 +187,8 @@ def register_endpoint(self, endpoint_cls): |
186 | 187 |
|
187 | 188 | :param endpoint_cls: A endpoint class |
188 | 189 | """ |
189 | | - self._endpoints[endpoint_cls.ENDPOINT_NAME] = endpoint_cls(self) |
| 190 | + endpoints = self._endpoints.setdefault(endpoint_cls.ENDPOINT_NAME, []) |
| 191 | + endpoints.append(endpoint_cls(self)) |
190 | 192 |
|
191 | 193 | def get_authorization_grant(self, request): |
192 | 194 | """Find the authorization grant for current request. |
@@ -231,12 +233,15 @@ def create_endpoint_response(self, name, request=None): |
231 | 233 | if name not in self._endpoints: |
232 | 234 | raise RuntimeError(f'There is no "{name}" endpoint.') |
233 | 235 |
|
234 | | - endpoint = self._endpoints[name] |
235 | | - request = endpoint.create_endpoint_request(request) |
236 | | - try: |
237 | | - return self.handle_response(*endpoint(request)) |
238 | | - except OAuth2Error as error: |
239 | | - return self.handle_error_response(request, error) |
| 236 | + endpoints = self._endpoints[name] |
| 237 | + for endpoint in endpoints: |
| 238 | + request = endpoint.create_endpoint_request(request) |
| 239 | + try: |
| 240 | + return self.handle_response(*endpoint(request)) |
| 241 | + except ContinueIteration: |
| 242 | + continue |
| 243 | + except OAuth2Error as error: |
| 244 | + return self.handle_error_response(request, error) |
240 | 245 |
|
241 | 246 | def create_authorization_response(self, request=None, grant_user=None): |
242 | 247 | """Validate authorization request and create authorization response. |
|
0 commit comments