From 868a06f036ac22d0ecfd7e2595cb7c40986116fc Mon Sep 17 00:00:00 2001 From: flashwave Date: Mon, 26 Aug 2024 18:09:02 +0000 Subject: [PATCH] Fixed oversights with basic authentication. --- src/AuthzContext.php | 13 +++++++++++++ src/OAuth2/OAuth2Routes.php | 1 + 2 files changed, 14 insertions(+) diff --git a/src/AuthzContext.php b/src/AuthzContext.php index 3459cf4..5e07042 100644 --- a/src/AuthzContext.php +++ b/src/AuthzContext.php @@ -137,6 +137,19 @@ class AuthzContext { $this->expires = $info['expires']; } + public function dump(): array { + return [ + 'authed' => $this->authed, + 'error' => $this->error, + 'method' => $this->method, + 'type' => $this->type, + 'user' => $this->userId, + 'app' => $this->appId, + 'scope' => $this->scope, + 'expires' => $this->expires, + ]; + } + private function attemptBasicAppAuthInternal(string $remoteAddr, string $clientId, string $clientSecret = ''): void { try { $this->handleRpcResponse($this->rpcClient->procedure('hanyuu:oauth2:attemptAppAuth', [ diff --git a/src/OAuth2/OAuth2Routes.php b/src/OAuth2/OAuth2Routes.php index d61c42e..70fa04c 100644 --- a/src/OAuth2/OAuth2Routes.php +++ b/src/OAuth2/OAuth2Routes.php @@ -124,6 +124,7 @@ class OAuth2Routes extends RouteHandler { if(!$authz->hasAuthed()) { $authzHeader = false; $authz->attemptBasicAppAuth( + (string)filter_input(INPUT_SERVER, 'REMOTE_ADDR'), (string)$content->getParam('client_id'), (string)$content->getParam('client_secret') );