Check prefix path is member route
Change-Id: I20c0bb159eef04bc88d208a3d4853d6b190c1dae
This commit is contained in:
parent
a7d8ba5031
commit
a9133e72d5
|
@ -100,11 +100,17 @@ class AuthorizationHook(hooks.PecanHook):
|
|||
self.member_routes = member_routes
|
||||
super(AuthorizationHook, self).__init__()
|
||||
|
||||
def is_path_in_routes(self, path):
|
||||
for p in self.member_routes:
|
||||
if path.startswith(p):
|
||||
return True
|
||||
return False
|
||||
|
||||
def before(self, state):
|
||||
ctx = state.request.context
|
||||
|
||||
if not ctx.is_admin and not ctx.is_public_api and \
|
||||
state.request.path not in self.member_routes:
|
||||
not self.is_path_in_routes(state.request.path):
|
||||
raise exc.HTTPForbidden()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue