Skip to content

Commit 2c90e84

Browse files
committed
refactor (Tornado): rename AUTH_PROPS to DEFAULT_AUTHORIZATION
1 parent 490a4c9 commit 2c90e84

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/DIRAC/Core/Tornado/Server/private/BaseRequestHandler.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,9 @@ def post(self, *args, **kwargs): # pylint: disable=arguments-differ
178178
# System name with which this component is associated
179179
SYSTEM = None
180180

181-
# Auth requirements
182-
AUTH_PROPS = None
181+
# Authorization requirements, properties that applied by default to all handler methods, if defined.
182+
# Note that `auth_methodName` will have a higher priority.
183+
DEFAULT_AUTHORIZATION = None
183184

184185
# Type of component
185186
MONITORING_COMPONENT = MonitoringClient.COMPONENT_WEB
@@ -409,9 +410,11 @@ def _getMethodAuthProps(self):
409410
410411
:return: list
411412
"""
412-
if self.AUTH_PROPS and not isinstance(self.AUTH_PROPS, (list, tuple)):
413-
self.AUTH_PROPS = [p.strip() for p in self.AUTH_PROPS.split(",") if p.strip()]
414-
return getattr(self, "auth_" + self.mehtodName, self.AUTH_PROPS)
413+
# Convert default authorization requirements to list
414+
if self.DEFAULT_AUTHORIZATION and not isinstance(self.DEFAULT_AUTHORIZATION, (list, tuple)):
415+
self.DEFAULT_AUTHORIZATION = [p.strip() for p in self.DEFAULT_AUTHORIZATION.split(",") if p.strip()]
416+
# Use auth_< method name > as primary value of the authorization requirements
417+
return getattr(self, "auth_" + self.mehtodName, self.DEFAULT_AUTHORIZATION)
415418

416419
def _getMethod(self):
417420
"""Get method function to call.

src/DIRAC/FrameworkSystem/API/AuthHandler.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
:dedent: 2
77
:caption: Auth options
88
"""
9-
from __future__ import absolute_import
10-
from __future__ import division
11-
from __future__ import print_function
12-
139
import json
1410
import pprint
1511

@@ -30,8 +26,7 @@
3026
class AuthHandler(TornadoREST):
3127
# Authorization access to all methods handled by AuthServer instance
3228
USE_AUTHZ_GRANTS = ["JWT", "VISITOR"]
33-
SYSTEM = "Framework"
34-
AUTH_PROPS = "all"
29+
DEFAULT_AUTHORIZATION = "all"
3530
LOCATION = "/auth"
3631

3732
@classmethod

0 commit comments

Comments
 (0)