Skip to content

Commit d30cc29

Browse files
committed
Added authentication on external feedback endpoint
1 parent f9be6fd commit d30cc29

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

setup.py

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

src/imio/esign/services/external_session_feedback.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22
from datetime import datetime
33
from imio.esign.utils import get_session_annotation
4+
from imio.helpers.ws import verify_auth_token
45
from plone.restapi.deserializer import json_body
56
from plone.restapi.services import Service
67

@@ -99,7 +100,14 @@ def reply(self): # noqa C901
99100

100101
def authorized(self):
101102
"""Check if the user is authorized to access this service."""
102-
return True
103+
auth_header = self.request._auth
104+
if not auth_header or not auth_header.startswith("Bearer "):
105+
return False
106+
try:
107+
token = auth_header.split(" ")[1]
108+
except IndexError:
109+
return False
110+
return verify_auth_token(token, groups=["access_apims-esign"])
103111

104112

105113
"""

0 commit comments

Comments
 (0)