Skip to content

Commit 61310e6

Browse files
benoitlavigneRoach
authored andcommitted
modified token verification (#6)
* modified token verification * added exception to token verification * moved token verification after challenge * removed whitespace
1 parent ca3e9c4 commit 61310e6

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

slackeventsapi/server.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,14 @@ def event():
2222
event_data.get("challenge"), 200, {"content_type": "application/json"}
2323
)
2424

25+
# Verify the request token
26+
request_token = event_data.get("token")
27+
if self.verification_token != request_token:
28+
emitter.emit('error', 'invalid verification token')
29+
return make_response("Request contains invalid Slack verification token", 403)
30+
2531
# Parse the Event payload and emit the event to the event listener
2632
if "event" in event_data:
27-
# Verify the request token
28-
request_token = event_data.get("token")
29-
if self.verification_token != request_token:
30-
emitter.emit('error', 'invalid verification token')
31-
message = "Request contains invalid Slack verification token: %s\n" \
32-
"Slack adapter has: %s" % (request_token, self.verification_token)
33-
return make_response(message, 403)
34-
3533
event_type = event_data["event"]["type"]
3634
emitter.emit(event_type, event_data)
3735
return make_response("", 200)

0 commit comments

Comments
 (0)