Support Bearer token authentication in EEPROM.

This commit is contained in:
flash 2024-08-27 02:23:27 +00:00
parent 7cd0dcfab4
commit 998ee715a2
2 changed files with 3 additions and 3 deletions

View file

@ -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
);

View file

@ -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);