Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ function verifyUsernamePasswordAndSSO(string $username, string $password): bool
}

try {
$response = json_decode($output[0], true);
// Split on first { and take everything after it
$jsonParts = explode('{', $output[0], 2);
if (count($jsonParts) < 2) {
my_logger("SSO Login Attempt Failed: No JSON found in response");
return false;
}
$response = json_decode('{' . $jsonParts[1], true);
if (isset($response['valid']) && $response['valid'] === true) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Index: /usr/local/emhttp/plugins/dynamix/include/.login.php
===================================================================
--- /usr/local/emhttp/plugins/dynamix/include/.login.php original
+++ /usr/local/emhttp/plugins/dynamix/include/.login.php modified
@@ -1,6 +1,51 @@
@@ -1,6 +1,57 @@
<?php
+
+
Expand Down Expand Up @@ -38,7 +38,13 @@ Index: /usr/local/emhttp/plugins/dynamix/include/.login.php
+ }
+
+ try {
+ $response = json_decode($output[0], true);
+ // Split on first { and take everything after it
+ $jsonParts = explode('{', $output[0], 2);
+ if (count($jsonParts) < 2) {
+ my_logger("SSO Login Attempt Failed: No JSON found in response");
+ return false;
+ }
+ $response = json_decode('{' . $jsonParts[1], true);
+ if (isset($response['valid']) && $response['valid'] === true) {
+ return true;
+ }
Expand All @@ -54,7 +60,7 @@ Index: /usr/local/emhttp/plugins/dynamix/include/.login.php
// Only start a session to check if they have a cookie that looks like our session
$server_name = strtok($_SERVER['HTTP_HOST'],":");
if (!empty($_COOKIE['unraid_'.md5($server_name)])) {
@@ -202,11 +247,11 @@
@@ -202,11 +253,11 @@
if ($failCount == $maxFails) my_logger("Ignoring login attempts for {$username} from {$remote_addr}");
throw new Exception(_('Too many invalid login attempts'));
}
Expand All @@ -67,7 +73,7 @@ Index: /usr/local/emhttp/plugins/dynamix/include/.login.php
if (isWildcardCert() && $twoFactorRequired && !verifyTwoFactorToken($username, $token)) throw new Exception(_('Invalid 2FA token'));

// Successful login, start session
@@ -536,10 +581,11 @@
@@ -536,10 +587,11 @@
document.body.textContent = '';
document.body.appendChild(errorElement);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class SSOFileModification extends FileModification {
protected async generatePatch(overridePath?: string): Promise<string> {
// Define the new PHP function to insert
/* eslint-disable no-useless-escape */
const newFunction = `
const newFunction = /** PHP */ `
function verifyUsernamePasswordAndSSO(string $username, string $password): bool {
if ($username != "root") return false;

Expand Down Expand Up @@ -45,7 +45,13 @@ function verifyUsernamePasswordAndSSO(string $username, string $password): bool
}

try {
$response = json_decode($output[0], true);
// Split on first { and take everything after it
$jsonParts = explode('{', $output[0], 2);
if (count($jsonParts) < 2) {
my_logger("SSO Login Attempt Failed: No JSON found in response");
return false;
}
$response = json_decode('{' . $jsonParts[1], true);
if (isset($response['valid']) && $response['valid'] === true) {
return true;
}
Expand Down
Loading