Skip to content

Commit cb9ea8e

Browse files
authored
Update token comparison (#243)
1 parent 45cf929 commit cb9ea8e

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/Auth/SignatureAuthenticator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class SignatureAuthenticator implements WebhookAuthenticator
1111
public function validate(Request $request): Request
1212
{
1313
if (! hash_equals(
14-
$request->header(config('workflows.webhook_auth.signature.header')) ?? '',
15-
hash_hmac('sha256', $request->getContent(), config('workflows.webhook_auth.signature.secret'))
14+
(string) $request->header(config('workflows.webhook_auth.signature.header')),
15+
(string) hash_hmac('sha256', $request->getContent(), config('workflows.webhook_auth.signature.secret'))
1616
)) {
1717
abort(401, 'Unauthorized');
1818
}

src/Auth/TokenAuthenticator.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ class TokenAuthenticator implements WebhookAuthenticator
1010
{
1111
public function validate(Request $request): Request
1212
{
13-
if ($request->header(config('workflows.webhook_auth.token.header')) !== config(
14-
'workflows.webhook_auth.token.token'
13+
if (! hash_equals(
14+
(string) config('workflows.webhook_auth.token.token'),
15+
(string) $request->header(config('workflows.webhook_auth.token.header'))
1516
)) {
1617
abort(401, 'Unauthorized');
1718
}

0 commit comments

Comments
 (0)