Skip to content

Commit 809a7c6

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

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/imio/esign/services/external_session_feedback.py

Lines changed: 10 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,15 @@ 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+
# TODO test this code works correctly
104+
auth_header = self.request._auth
105+
if not auth_header or not auth_header.startswith("Bearer "):
106+
return False
107+
try:
108+
token = auth_header.split(" ")[1]
109+
except IndexError:
110+
return False
111+
return verify_auth_token(token, groups=["access_apims-esign"])
103112

104113

105114
"""

0 commit comments

Comments
 (0)