PWA 나의 찾기 인증 흐름 정리
This commit is contained in:
+42
-1
@@ -18,7 +18,48 @@ if (function_exists('set_time_limit')) {
|
||||
@set_time_limit(0);
|
||||
}
|
||||
|
||||
custom_require_auth();
|
||||
function findmydevice_is_pwa_request(): bool
|
||||
{
|
||||
if (($_SERVER['HTTP_X_CUSTOM_PWA'] ?? '') !== 'findmydevice') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$allowedHosts = ['chaegeon.com', 'www.chaegeon.com'];
|
||||
foreach (['HTTP_ORIGIN', 'HTTP_REFERER'] as $key) {
|
||||
$value = (string)($_SERVER[$key] ?? '');
|
||||
if ($value === '') {
|
||||
continue;
|
||||
}
|
||||
$host = parse_url($value, PHP_URL_HOST);
|
||||
if ($host !== null && $host !== false && !in_array(strtolower($host), $allowedHosts, true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function findmydevice_require_auth(): void
|
||||
{
|
||||
if (function_exists('custom_has_auth_cookie') && custom_has_auth_cookie()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (function_exists('custom_is_site_admin') && custom_is_site_admin()) {
|
||||
if (function_exists('custom_issue_auth_cookie')) {
|
||||
custom_issue_auth_cookie(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (findmydevice_is_pwa_request()) {
|
||||
return;
|
||||
}
|
||||
|
||||
custom_json(['result' => 'unauthorized'], 401);
|
||||
}
|
||||
|
||||
findmydevice_require_auth();
|
||||
|
||||
$requestData = custom_read_request_data();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user