From 3514e998125938ed78f3b73a5aeb873876759b87 Mon Sep 17 00:00:00 2001 From: Joep de Jong Date: Thu, 27 Jul 2023 22:28:28 +0300 Subject: [PATCH] Add connect2 request --- src/plugins/authiapconnect2/auth.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/plugins/authiapconnect2/auth.php b/src/plugins/authiapconnect2/auth.php index e7eb7da..228523d 100644 --- a/src/plugins/authiapconnect2/auth.php +++ b/src/plugins/authiapconnect2/auth.php @@ -50,7 +50,33 @@ private function getIapToken() */ private function getUserDataFromToken($token) { - // + // Get request to Connect2 + $url = $this->getConf('connect2_endpoint'); + + $curl = curl_init(); + + curl_setopt_array($curl, array( + CURLOPT_URL => $url, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'GET', + CURLOPT_HTTPHEADER => array( + 'X-Goog-IAP-JWT-Assertion: ' . $token + ), + )); + + $response = curl_exec($curl); + + curl_close($curl); + $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + + if ($httpcode != 200) { + throw new Exception('Could not get user data'); + } return json_decode($response, true); }