v7.0.0 release
This commit is contained in:
1 parent
0e7fa04b03
commit
c4ea9a6cd1
3582 files changed
+626189
-160151
No files matched your search
+55
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Plugins\Sirsoft\VerificationKginicis\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Api\Base\PublicBaseController;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Plugins\Sirsoft\VerificationKginicis\Services\InicisCallbackResolver;
|
||||
|
||||
/**
|
||||
* 이니시스 매뉴얼 STEP2 콜백 수신 → STEP3 호출 위임 → bridge 페이지 redirect 컨트롤러.
|
||||
*
|
||||
* 코어 표준 라우트 (`POST /api/identity/callback/{providerId}`) 를 사용할 수 없는 이유는
|
||||
* 이니시스가 challenge_id 를 callback 에 echo 하지 않기 때문 (매뉴얼 STEP2 명시).
|
||||
* 본 컨트롤러는 InicisCallbackResolver Service 에 비즈니스 로직을 위임하고, 결과를
|
||||
* popup-bridge 페이지로 302 redirect 한다.
|
||||
*
|
||||
* FormRequest 미사용 사유: 외부 PG 가 보내는 임의 필드를 strict validation 으로 차단하면
|
||||
* 이니시스 응답을 받을 수 없다. 본 컨트롤러는 raw form POST 를 그대로 Resolver 에 전달.
|
||||
*
|
||||
* @since 1.0.0-beta.1
|
||||
*/
|
||||
class InicisCallbackController extends PublicBaseController
|
||||
{
|
||||
/**
|
||||
* @param InicisCallbackResolver $resolver callback 비즈니스 로직 Service
|
||||
*/
|
||||
public function __construct(
|
||||
protected readonly InicisCallbackResolver $resolver,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* 이니시스 콜백 수신 + Resolver 위임 + bridge 페이지로 302 redirect.
|
||||
*
|
||||
* @param Request $request 이니시스 form POST body
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request): RedirectResponse
|
||||
{
|
||||
$outcome = $this->resolver->resolve(
|
||||
callbackInput: $request->all(),
|
||||
context: [
|
||||
'ip_address' => $request->ip(),
|
||||
'user_agent' => substr((string) $request->userAgent(), 0, 512),
|
||||
],
|
||||
);
|
||||
|
||||
$bridgeUrl = url('/plugins/sirsoft-verification_kginicis/plugin/inicis/popup-bridge')
|
||||
.'?'.http_build_query($outcome->toBridgeQuery());
|
||||
|
||||
return redirect()->away($bridgeUrl);
|
||||
}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace Plugins\Sirsoft\VerificationKginicis\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Api\Base\PublicBaseController;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
/**
|
||||
* 이니시스 매뉴얼 STEP4 결과 전달 페이지 — 데스크톱 팝업 / 모바일 redirect 분기.
|
||||
*
|
||||
* Callback 컨트롤러가 302 redirect 한 query (verification_token / challenge_id / identity_error)
|
||||
* 를 받아서, 사용자 브라우저 환경에 따라 두 가지 분기를 수행한다:
|
||||
*
|
||||
* - 데스크톱 (window.opener 존재): 부모창에 postMessage + window.close
|
||||
* - 모바일 (window.opener 부재): sessionStorage 의 redirectStash 복원 후 원 페이지로 redirect
|
||||
* (verification_token query 부착 — formStash 복원은 launcher 책임)
|
||||
*
|
||||
* G7 컨벤션 (sirsoft-pay_kginicis UserEscrowConfirmController 참고): 외부 PG 콜백 후 사용자
|
||||
* 브라우저에 노출되는 결과 페이지는 컨트롤러 인라인 HTML 응답으로 처리한다 (Blade 미사용).
|
||||
*
|
||||
* @since 1.0.0-beta.1
|
||||
*/
|
||||
class InicisPopupBridgeController extends PublicBaseController
|
||||
{
|
||||
/**
|
||||
* Bridge 페이지를 렌더링한다.
|
||||
*
|
||||
* @param Request $request callback 컨트롤러가 전달한 query (verification_token / challenge_id / identity_error)
|
||||
* @return Response
|
||||
*/
|
||||
public function show(Request $request): Response
|
||||
{
|
||||
$payloadJson = json_encode([
|
||||
'verification_token' => (string) $request->query('verification_token', ''),
|
||||
'challenge_id' => (string) $request->query('challenge_id', ''),
|
||||
'identity_error' => (string) $request->query('identity_error', ''),
|
||||
], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_UNESCAPED_UNICODE);
|
||||
|
||||
return $this->htmlResponse($this->renderBridgeHtml($payloadJson));
|
||||
}
|
||||
|
||||
/**
|
||||
* UTF-8 HTML 응답 헬퍼.
|
||||
*
|
||||
* @param string $html
|
||||
* @return Response
|
||||
*/
|
||||
protected function htmlResponse(string $html): Response
|
||||
{
|
||||
return response($html, 200, ['Content-Type' => 'text/html; charset=UTF-8']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bridge 페이지 HTML 을 생성한다.
|
||||
*
|
||||
* sessionStorage 키는 코어 `IDENTITY_REDIRECT_STASH_KEY` 상수와 동일해야 launcher 가
|
||||
* stash 한 redirectStash 를 정상적으로 복원할 수 있다.
|
||||
*
|
||||
* @param string $payloadJson json_encode 결과 (script 컨텍스트 안전 — JSON_HEX_* 적용됨)
|
||||
* @return string
|
||||
*/
|
||||
protected function renderBridgeHtml(string $payloadJson): string
|
||||
{
|
||||
return <<<HTML
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<title>본인인증 결과</title>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
(function () {
|
||||
var REDIRECT_STASH_KEY = 'g7.identity.redirectStash';
|
||||
var payload = {$payloadJson};
|
||||
|
||||
// 데스크톱: 부모창 postMessage + 자기 창 닫기
|
||||
if (window.opener && !window.opener.closed) {
|
||||
try {
|
||||
window.opener.postMessage({
|
||||
type: 'identity_result',
|
||||
verification_token: payload.verification_token,
|
||||
challenge_id: payload.challenge_id,
|
||||
identity_error: payload.identity_error
|
||||
}, window.location.origin);
|
||||
} catch (e) { /* opener cross-origin — 무시 */ }
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
|
||||
// 모바일: sessionStorage redirectStash 복원 후 원 페이지로 이동
|
||||
var stashRaw = null;
|
||||
try { stashRaw = window.sessionStorage.getItem(REDIRECT_STASH_KEY); } catch (e) {}
|
||||
var stash = null;
|
||||
if (stashRaw) {
|
||||
try { stash = JSON.parse(stashRaw); } catch (e) {}
|
||||
}
|
||||
try { window.sessionStorage.removeItem(REDIRECT_STASH_KEY); } catch (e) {}
|
||||
|
||||
var dest = (stash && stash.return_url) ? stash.return_url : '/';
|
||||
var sep = dest.indexOf('?') >= 0 ? '&' : '?';
|
||||
if (payload.verification_token) {
|
||||
dest += sep + 'verification_token=' + encodeURIComponent(payload.verification_token);
|
||||
} else if (payload.identity_error) {
|
||||
dest += sep + 'identity_error=' + encodeURIComponent(payload.identity_error);
|
||||
}
|
||||
window.location.replace(dest);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
HTML;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Plugins\Sirsoft\VerificationKginicis\Http\Controllers;
|
||||
|
||||
use App\Helpers\ResponseHelper;
|
||||
use App\Http\Controllers\Api\Base\AuthBaseController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Plugins\Sirsoft\VerificationKginicis\Http\Resources\InicisIdentityResource;
|
||||
use Plugins\Sirsoft\VerificationKginicis\Services\InicisIdentityCardService;
|
||||
|
||||
/**
|
||||
* 마이페이지 본인인증 카드 데이터 제공 API.
|
||||
*
|
||||
* 사용자가 자기 본인확인 정보 (마스킹) 를 조회한다. record 가 없으면 data=null 반환
|
||||
* (코어 표준 null 처리 패턴 — Resource 가 null 처리 안 하므로 컨트롤러에서 분기).
|
||||
*
|
||||
* @since 1.0.0-beta.1
|
||||
*/
|
||||
class MyInicisIdentityShowController extends AuthBaseController
|
||||
{
|
||||
/**
|
||||
* @param InicisIdentityCardService $cardService 본인인증 카드 데이터 Service
|
||||
*/
|
||||
public function __construct(
|
||||
protected readonly InicisIdentityCardService $cardService,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/me/identity/inicis — 현재 사용자의 이니시스 본인확인 정보 조회.
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function show(): JsonResponse
|
||||
{
|
||||
$record = $this->cardService->findForUser((int) Auth::id());
|
||||
|
||||
if ($record === null) {
|
||||
return ResponseHelper::success('messages.success', null);
|
||||
}
|
||||
|
||||
return ResponseHelper::success(
|
||||
'messages.success',
|
||||
(new InicisIdentityResource($record))->resolve(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user