File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,6 @@ open Common
5
5
open Github_j
6
6
open Slack_j
7
7
8
- let log = Log. from " slack"
9
-
10
8
let empty_attachments =
11
9
{
12
10
mrkdwn_in = None ;
@@ -361,23 +359,19 @@ let generate_commit_comment_notification api_commit notification channel =
361
359
in
362
360
{ channel; text = None ; attachments = Some [ attachment ]; blocks = None }
363
361
364
- let has_valid_signature ?(version = " v0" ) ?signing_key ~headers body =
362
+ let validate_signature ?(version = " v0" ) ?signing_key ~headers body =
365
363
match signing_key with
366
- | None -> true
364
+ | None -> Ok ()
367
365
| Some key ->
368
366
match List.Assoc. find headers " x-slack-signature" ~equal: String. equal with
369
- | None ->
370
- log#error " unable to find header X-Slack-Signature" ;
371
- false
367
+ | None -> Error " unable to find header X-Slack-Signature"
372
368
| Some signature ->
373
369
match List.Assoc. find headers " x-slack-request-timestamp" ~equal: String. equal with
374
- | None ->
375
- log#error " unable to find header X-Slack-Request-Timestamp" ;
376
- false
370
+ | None -> Error " unable to find header X-Slack-Request-Timestamp"
377
371
| Some timestamp ->
378
372
let basestring = Printf. sprintf " %s:%s:%s" version timestamp body in
379
373
let expected_signature = Printf. sprintf " %s=%s" version (Common. sign_string_sha256 ~key ~basestring ) in
380
- String. equal expected_signature signature
374
+ if String. equal expected_signature signature then Ok () else Error " signatures don't match "
381
375
382
376
let has_valid_state ?oauth_state ~args =
383
377
match oauth_state with
You can’t perform that action at this time.
0 commit comments