Support Bearer token authentication in EEPROM.
This commit is contained in:
parent
7cd0dcfab4
commit
998ee715a2
2 changed files with 3 additions and 3 deletions
|
@ -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
|
||||
);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue