Skip to content

Commit a3f518f

Browse files
committed
Added authentication on external feedback endpoint
1 parent aaec66e commit a3f518f

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"collective.compoundcriterion",
5656
"collective.eeafaceted.z3ctable",
5757
"eea.facetednavigation",
58-
"imio.helpers>1.3.8",
58+
"imio.helpers>1.3.10",
5959
"imio.prettylink",
6060
"imio.pyutils",
6161
# 'z3c.jbot',

src/imio/esign/services/external_session_feedback.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from datetime import datetime
33
from imio.esign import logger
44
from imio.esign.utils import get_session_annotation
5+
from imio.helpers.ws import verify_auth_token
56
from plone.restapi.deserializer import json_body
67
from plone.restapi.services import Service
78

@@ -95,4 +96,20 @@ def reply(self): # noqa C901
9596

9697
def authorized(self):
9798
"""Check if the user is authorized to access this service."""
98-
return True
99+
auth_header = self.request._auth
100+
if not auth_header or not auth_header.startswith("Bearer "):
101+
return False
102+
try:
103+
token = auth_header.split(" ")[1]
104+
except IndexError:
105+
return False
106+
return verify_auth_token(token, groups=["access_imio-apps-docs"])
107+
108+
109+
"""
110+
State:
111+
to_create_session
112+
to_sign
113+
to_upload
114+
refused
115+
"""

0 commit comments

Comments
 (0)