From 64c167ec0a844356be0f2087632c225a8d525249 Mon Sep 17 00:00:00 2001 From: soneill Date: Tue, 7 Sep 2021 18:32:58 +1200 Subject: [PATCH] Adds temporary workaround for issue in pathfinder_esi dep --- Dockerfile | 1 + pathfinder | 2 +- static/pathfinder/Sso.php | 105 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 static/pathfinder/Sso.php diff --git a/Dockerfile b/Dockerfile index ee3464b..b834089 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,6 +34,7 @@ COPY --chown=nobody --from=build /app pathfinder RUN chmod 0766 pathfinder/logs pathfinder/tmp/ && rm index.php && touch /etc/nginx/.setup_pass && chmod +x /entrypoint.sh COPY static/pathfinder/routes.ini /var/www/html/pathfinder/app/ COPY static/pathfinder/environment.ini /var/www/html/pathfinder/app/templateEnvironment.ini +COPY static/pathfinder/Sso.php /var/www/html/pathfinder/vendor/exodus4d/pathfinder_esi/app/Client/Ccp/Sso/Sso.php WORKDIR /var/www/html EXPOSE 80 diff --git a/pathfinder b/pathfinder index 8a3f3f3..3514c2d 160000 --- a/pathfinder +++ b/pathfinder @@ -1 +1 @@ -Subproject commit 8a3f3f380f3c4e5bcf0fc41ddd5f136865c51f74 +Subproject commit 3514c2de7c79d97828675f113012031022194b4a diff --git a/static/pathfinder/Sso.php b/static/pathfinder/Sso.php new file mode 100644 index 0000000..2f33551 --- /dev/null +++ b/static/pathfinder/Sso.php @@ -0,0 +1,105 @@ + get some basic information (like character id) + * -> if more character information is required, use ESI "characters" endpoints request instead + * @param string $accessToken + * @return RequestConfig + */ + protected function getVerifyCharacterRequest(string $accessToken) : RequestConfig { + $requestOptions = [ + 'headers' => $this->getAuthHeader($accessToken, 'Bearer') + ]; + + return new RequestConfig( + WebClient::newRequest('GET', $this->getVerifyUserEndpointURI()), + $requestOptions, + function($body) : array { + $characterData = []; + if(!$body->error){ + $characterData = (new Mapper\Sso\Character($body))->getData(); + } + + return $characterData; + } + ); + } + + /** + * get a valid "access_token" for oAuth 2.0 verification + * -> verify $authCode and get NEW "access_token" + * $requestParams['grant_type] = 'authorization_code' + * $requestParams['code] = 'XXXX' + * -> request NEW "access_token" if isset: + * $requestParams['grant_type] = 'refresh_token' + * $requestParams['refresh_token] = 'XXXX' + * @param array $credentials + * @param array $requestParams + * @return RequestConfig + */ + protected function getAccessRequest(array $credentials, array $requestParams = []) : RequestConfig { + $requestOptions = [ + 'form_params' => $requestParams, + 'auth' => $credentials + ]; + + return new RequestConfig( + WebClient::newRequest('POST', $this->getVerifyAuthorizationCodeEndpointURI()), + $requestOptions, + function($body) : array { + $accessData = []; + if(!$body->error){ + $accessData = (new Mapper\Sso\Access($body))->getData(); + } + + return $accessData; + } + ); + } + + /** + * @return string + */ + public function getAuthorizationEndpointURI() : string { + return '/oauth/authorize'; + } + + /** + * @return string + */ + public function getVerifyUserEndpointURI() : string { + return '/oauth/verify'; + } + + /** + * @return string + */ + public function getVerifyAuthorizationCodeEndpointURI() : string { + return '/oauth/token'; + } + + /** + * @return ConfigInterface + */ + protected function getConfig() : ConfigInterface { + return ($this->config instanceof ConfigInterface) ? $this->config : $this->config = new Config(); + } +} \ No newline at end of file