|
8 | 8 | from tornado.log import app_log
|
9 | 9 | from tornado.web import HTTPError
|
10 | 10 |
|
11 |
| -from .utils import HTTP_METHOD_TO_AUTH_ACTION, warn_disabled_authorization |
| 11 | +from .utils import HTTP_METHOD_TO_AUTH_ACTION |
12 | 12 |
|
13 | 13 |
|
14 | 14 | def authorized(
|
@@ -57,18 +57,13 @@ def inner(self, *args, **kwargs):
|
57 | 57 | if not user:
|
58 | 58 | app_log.warning("Attempting to authorize request without authentication!")
|
59 | 59 | raise HTTPError(status_code=403, log_message=message)
|
60 |
| - |
61 |
| - # Handle the case where an authorizer wasn't attached to the handler. |
62 |
| - if not self.authorizer: |
63 |
| - warn_disabled_authorization() |
64 |
| - return method(self, *args, **kwargs) |
65 |
| - |
66 |
| - # Only return the method if the action is authorized. |
| 60 | + # If the user is allowed to do this action, |
| 61 | + # call the method. |
67 | 62 | if self.authorizer.is_authorized(self, user, action, resource):
|
68 | 63 | return method(self, *args, **kwargs)
|
69 |
| - |
70 |
| - # Raise an exception if the method wasn't returned (i.e. not authorized) |
71 |
| - raise HTTPError(status_code=403, log_message=message) |
| 64 | + # else raise an exception. |
| 65 | + else: |
| 66 | + raise HTTPError(status_code=403, log_message=message) |
72 | 67 |
|
73 | 68 | return inner
|
74 | 69 |
|
|
0 commit comments