diff options
author | Minteck <contact@minteck.org> | 2023-01-29 15:19:02 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2023-01-29 15:19:02 +0100 |
commit | bdc6e413162587faea3e528fed4efa81e0f8a73f (patch) | |
tree | 36da38844f84b5cf84b0a6e3b942f0a04b09111a | |
parent | ee4628eb4596c1c12a7efcbfc04abd2d48f05f0b (diff) | |
download | pluralconnect-bdc6e413162587faea3e528fed4efa81e0f8a73f.tar.gz pluralconnect-bdc6e413162587faea3e528fed4efa81e0f8a73f.tar.bz2 pluralconnect-bdc6e413162587faea3e528fed4efa81e0f8a73f.zip |
Updated 3 files and deleted 2 files (automated)
-rw-r--r-- | Authentication/Callback/index.php | 14 | ||||
-rw-r--r-- | Authentication/PublicCallback/index.php | 3 | ||||
-rw-r--r-- | Authentication/PublicStart/index.php | 3 | ||||
-rw-r--r-- | Authentication/Start/index.php | 5 | ||||
-rw-r--r-- | i18n/en.json | 2 |
5 files changed, 12 insertions, 15 deletions
diff --git a/Authentication/Callback/index.php b/Authentication/Callback/index.php index 4c591af..508326b 100644 --- a/Authentication/Callback/index.php +++ b/Authentication/Callback/index.php @@ -1,7 +1,6 @@ <?php -$channel = "private"; -$server = "privateauth.equestria.dev"; +$server = "auth.equestria.horse"; header("Content-Type: text/plain"); @@ -9,18 +8,18 @@ if (!isset($_GET['code'])) { die(); } -$appdata = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)[$channel]; +$appdata = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); $crl = curl_init('https://' . $server . '/hub/api/rest/oauth2/token'); curl_setopt($crl, CURLOPT_RETURNTRANSFER, true); curl_setopt($crl, CURLINFO_HEADER_OUT, true); curl_setopt($crl, CURLOPT_POST, true); curl_setopt($crl, CURLOPT_HTTPHEADER, [ - "Authorization: Basic " . base64_encode($appdata["id"] . ":" . $appdata["secret"]), + "Authorization: Basic " . base64_encode($appdata["oauth"]["id"] . ":" . $appdata["oauth"]["secret"]), "Content-Type: application/x-www-form-urlencoded", "Accept: application/json" ]); -curl_setopt($crl, CURLOPT_POSTFIELDS, "grant_type=authorization_code&redirect_uri=" . urlencode("http" . ($_SERVER['HTTPS'] ? "s" : "") . "://" . $_SERVER['HTTP_HOST'] . "/Authentication/Callback") . "&code=" . $_GET['code']); +curl_setopt($crl, CURLOPT_POSTFIELDS, "grant_type=authorization_code&redirect_uri=" . urlencode("https://ponies.equestria.horse/Authentication/Callback") . "&code=" . $_GET['code']); $result = curl_exec($crl); $result = json_decode($result, true); @@ -39,6 +38,11 @@ if (isset($result["access_token"])) { $result = curl_exec($crl); $result = json_decode($result, true); + if (!in_array($result["id"], $appdata["oauth"]["allowed"])) { + header("Location: /"); + die(); + } + if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens")) mkdir($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens"); $token = bin2hex(random_bytes(32)); diff --git a/Authentication/PublicCallback/index.php b/Authentication/PublicCallback/index.php deleted file mode 100644 index 7f6a11b..0000000 --- a/Authentication/PublicCallback/index.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php - -return;
\ No newline at end of file diff --git a/Authentication/PublicStart/index.php b/Authentication/PublicStart/index.php deleted file mode 100644 index 7f6a11b..0000000 --- a/Authentication/PublicStart/index.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php - -return;
\ No newline at end of file diff --git a/Authentication/Start/index.php b/Authentication/Start/index.php index 18bde88..99f393f 100644 --- a/Authentication/Start/index.php +++ b/Authentication/Start/index.php @@ -1,7 +1,6 @@ <?php -$channel = "private"; -$server = "privateauth.equestria.dev"; +$server = "auth.equestria.horse"; -header("Location: https://$server/hub/api/rest/oauth2/auth?client_id=" . json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)[$channel]["id"] . "&response_type=code&redirect_uri=http" . ($_SERVER['HTTPS'] ? "s" : "") . "://" . $_SERVER['HTTP_HOST'] . "/Authentication/Callback&scope=Hub&request_credentials=default&access_type=offline"); +header("Location: https://$server/hub/api/rest/oauth2/auth?client_id=" . json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["oauth"]["id"] . "&response_type=code&redirect_uri=https://ponies.equestria.horse/Authentication/Callback&scope=Hub&request_credentials=default&access_type=offline"); die(); diff --git a/i18n/en.json b/i18n/en.json index 6567d55..e11ed07 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -292,7 +292,7 @@ ], "select": "Select how you want to log in to", "private": [ - "Equestria.dev Private Authentication", + "Equestria.dev Authentication", "For website administrators, allows to change content and access private information.", "Continue" ] |