fix: 워크스페이스 탭 중첩 셸 방지 + 세션 만료 시 로그인 리다이렉트
- EmbedRedirectFilter 추가: 임베드(embed=1) 요청의 리다이렉트 Location에 embed 유지(중첩 셸 방지) - bag/* 전체에 loginAuth 적용, 임베드 대시보드 로그아웃 시 로그인으로 이동 - 기본코드 종류 선택 시 embed 유지, 일괄입고 오류 복귀를 명시 URL로(back() 제거) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
54
app/Filters/EmbedRedirectFilter.php
Normal file
54
app/Filters/EmbedRedirectFilter.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filters;
|
||||
|
||||
use CodeIgniter\Filters\FilterInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
|
||||
/**
|
||||
* 워크스페이스 탭(iframe, embed=1) 안에서 발생한 리다이렉트가 embed 파라미터를 잃지 않도록
|
||||
* 응답 Location 헤더에 embed=1 을 유지시킨다.
|
||||
*
|
||||
* 배경: 폼 전송 후 redirect()->to(...) 하면 Location 에 embed 가 빠지고, iframe 안에서
|
||||
* 그 주소로 다시 GET 하면(특히 HTTP 환경에서 Sec-Fetch-Dest 미전송) 전체 셸(헤더·사이드바)이
|
||||
* 한 번 더 렌더되어 "화면 안에 전체 화면이 또" 생긴다. 이를 전역에서 한 번에 방지한다.
|
||||
*/
|
||||
class EmbedRedirectFilter implements FilterInterface
|
||||
{
|
||||
public function before(RequestInterface $request, $arguments = null)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string>|null $arguments
|
||||
*/
|
||||
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
|
||||
{
|
||||
// 임베드 요청에서 시작된 리다이렉트만 처리
|
||||
if ($request->getGet('embed') === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$location = $response->getHeaderLine('Location');
|
||||
if ($location === '') {
|
||||
return; // 리다이렉트 응답이 아님
|
||||
}
|
||||
|
||||
// 이미 embed 파라미터가 있으면 그대로 둔다
|
||||
if (preg_match('/[?&]embed=/', $location) === 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 인증 흐름(로그인/로그아웃/회원가입)은 상위 프레임에서 처리하므로 embed 를 붙이지 않는다
|
||||
if (preg_match('#/(login|logout|register)(/|\?|$)#', $location) === 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sep = strpos($location, '?') !== false ? '&' : '?';
|
||||
$response->setHeader('Location', $location . $sep . 'embed=1');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user