From 998ee715a23974324c20cb160db38d95742fe130 Mon Sep 17 00:00:00 2001 From: flashwave Date: Tue, 27 Aug 2024 02:23:27 +0000 Subject: [PATCH] Support Bearer token authentication in EEPROM. --- src/Auth/AuthRoutes.php | 3 ++- src/Auth/ChatAuth.php | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Auth/AuthRoutes.php b/src/Auth/AuthRoutes.php index ca96874..7987c1c 100644 --- a/src/Auth/AuthRoutes.php +++ b/src/Auth/AuthRoutes.php @@ -26,9 +26,10 @@ class AuthRoutes extends RouteHandler { $authMethod = strval($authParts[0] ?? ''); $authToken = strval($authParts[1] ?? ''); - if($authMethod === 'Misuzu') { + if(strcasecmp($authMethod, 'misuzu') === 0 || strcasecmp($authMethod, 'bearer') === 0) { $authResult = ChatAuth::attempt( $this->config->getString('endpoint'), + $authMethod, $this->config->getString('secret'), $authToken ); diff --git a/src/Auth/ChatAuth.php b/src/Auth/ChatAuth.php index 790d9d4..4f7ba5d 100644 --- a/src/Auth/ChatAuth.php +++ b/src/Auth/ChatAuth.php @@ -4,9 +4,8 @@ namespace EEPROM\Auth; use stdClass; final class ChatAuth { - public static function attempt(string $endPoint, string $secret, string $cookie): stdClass { + public static function attempt(string $endPoint, string $method, string $secret, string $cookie): stdClass { if(!empty($cookie)) { - $method = 'Misuzu'; $signature = sprintf('verify#%s#%s#%s', $method, $cookie, $_SERVER['REMOTE_ADDR']); $signature = hash_hmac('sha256', $signature, $secret);