So, the question: "ajax call inside a plugin?"
My current plan...
I have an htaccess in my plugin php dir. I have set this to:
Code: Select all
Order deny,allow
Deny from all
<Files "ajax-handler.php">
Allow from all
</Files>
<Files "ajax-handler.php">
Require all granted
</Files>In the parent set a session: say...
Code: Select all
session_start();
$_SESSION['adminToken'] = $tokenCSRF;Code: Select all
ajax-handler.php?folder=folder&adminToken=<?= $tokenCSRF; ?>In the handler - at the top
Code: Select all
session_name('BLUDIT-KEY'); // bludit specific!!
session_start();
$sessionToken = $_SESSION['s_adminToken'] ?? null; // s_ is also bludit required
$getToken = $_GET['adminToken'] ?? null;
if (!$sessionToken || $getToken !== $sessionToken) {
echo 'Access denied';
exit;
}While my earlier setup worked it was quite messy. This feels much cleaner.
Even with the token check I have input santisation. Hopefully the combo is safe enough. What do you think?

