통합인증 : 이니시스 모듈 추가

This commit is contained in:
projectSylas
2021-09-13 06:08:11 +00:00
parent 5fc6fcd4ac
commit 353a1ad784
5 changed files with 271 additions and 148 deletions

View File

@ -0,0 +1,65 @@
<?php
include_once('./_common.php');
global $g5;
$sql = "select MAX(cr_id) as max_cr_id from {$g5['cert_history_table']} limit 1";
$res = sql_fetch($sql);
$max_cr_id = $res['max_cr_id'];
if(empty($max_cr_id)) $max_cr_id = 0;
if($config['cf_cert_use'] == 2) { // 테스트 일때
$mid = "INIiasTest";
$apiKey = "TGdxb2l3enJDWFRTbTgvREU3MGYwUT09";
$mTxId ='test_'.$max_cr_id;
} else {
$mid = 'SRA'.$config['cf_cert_kg_mid']; // 부여받은 MID(상점ID) 입력(영업담당자 문의)
$apiKey = $config['cf_cert_kg_cd']; // 부여받은 MID 에 대한 apiKey
$mTxId ='SIR_'.$max_cr_id.$type;
certify_count_check($member['mb_id'], 'sa'); // 금일 인증시도 횟수 체크
}
$reqSvcCd ='01';
// 등록가맹점 확인
$plainText1 = hash("sha256",(string)$mid.(string)$mTxId.(string)$apiKey);
$authHash = $plainText1;
$flgFixedUser = (!empty($member['mb_id']) && !empty($member['mb_name']) && !empty($member['mb_hp']) && !empty($member['mb_birth']))? 'Y' : 'N'; // 특정사용자 고정시 : Y 세팅및 아래 해시 데이터 생성
if($flgFixedUser == 'Y') {
$userName = $member['mb_name']; // 사용자 이름
$userPhone = preg_replace("/-/","" , $member['mb_hp']); // 사용자 전화번호 하이픈만 제거
$userBirth = $member['mb_birth']; // 사용자 생년월일
$plainText2 = hash("sha256",(string)$userName.(string)$mid.(string)$userPhone.(string)$mTxId.(string)$userBirth.(string)$reqSvcCd);
$userHash = $plainText2;
}
$g5['title'] = 'KG이니시스 통합인증';
include_once(G5_PATH.'/head.sub.php');
?>
<form name="saForm">
<input type="hidden" name="mid" value="<?php echo $mid ?>"> <!-- 필수 값 -->
<input type="hidden" name="reqSvcCd" value="<?php echo $reqSvcCd ?>"> <!-- 필수 값 -->
<input type="hidden" name="mTxId" value="<?php echo $mTxId ?>"> <!-- 필수 값 -->
<input type="hidden" name="authHash" value="<?php echo $authHash ?>"> <!-- 필수 값 -->
<input type="hidden" name="flgFixedUser" value="<?php echo $flgFixedUser ?>"> <!-- 필수 값 Y/N 특정사용자 인증 요청 여부 -->
<input type="hidden" name="userName" value="<?php echo $userName ?>">
<input type="hidden" name="userPhone" value="<?php echo $userPhone ?>">
<input type="hidden" name="userBirth" value="<?php echo $userBirth ?>">
<input type="hidden" name="userHash" value="<?php echo $userHash ?>">
<input type="hidden" name="mbId" value="<?php echo $member['mb_id'] ?>">
<input type="hidden" name="directAgency" value="<?php echo $_POST['directAgency']; ?>">
<input type="hidden" name="successUrl" value="<?php echo G5_KGCERT_URL; ?>/kg_find_result.php"> <!-- 필수 값 -->
<input type="hidden" name="failUrl" value="<?php echo G5_KGCERT_URL; ?>/kg_find_result.php"> <!-- 필수 값 -->
<!-- successUrl / failUrl 은 분리 하여 이용가능!-->
</form>
<script>
document.saForm.setAttribute("target", "_self");
document.saForm.setAttribute("post", "post");
document.saForm.setAttribute("action", "https://sa.inicis.com/auth");
document.saForm.submit();
</script>
<?php
include_once(G5_PATH.'/tail.sub.php');

View File

@ -0,0 +1,96 @@
<?php
include_once('./_common.php');
$txId = $_POST['txId'];
$mid = substr($txId, 6, 10);
if ($_POST["resultCode"] === "0000") {
$data = array(
'mid' => $mid,
'txId' => $txId
);
$post_data = json_encode($data);
// curl 통신 시작
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_POST["authRequestUrl"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
$res_data = json_decode($response, true);
if($res_data['resultCode'] == "0000") {
@insert_cert_history('@password_lost@', 'kg', 'sa'); // 인증성공 시 내역 기록
$cert_type = 'sa'; // 인증타입
$cert_no = $res_data['txId']; // 이니시스 트랜잭션 ID
$phone_no = $res_data['userPhone']; // 전화번호
$user_name = $res_data['userName']; // 이름
$birth_day = $res_data['userBirthday']; // 생년월일
$ci = $res_data['userCi']; // CI
if(!$phone_no)
alert_close("정상적인 인증이 아닙니다. 올바른 방법으로 이용해 주세요.");
$md5_ci = md5($ci . $ci);
$phone_no = hyphen_hp_number($phone_no);
$mb_dupinfo = $md5_ci;
$row = sql_fetch("select * from {$g5['member_table']} where mb_id <> '{$member['mb_id']}' and mb_dupinfo = '{$mb_dupinfo}'");
if (!$row['mb_id']) {
$row = sql_fetch("select * from {$g5['member_table']} where mb_id <> '{$member['mb_id']}' and mb_name ='{$user_name}' and mb_birth='{$birth_day}' and mb_hp='{$phone_no}'");
if(!$row['mb_id']){
alert_close("인증하신 정보로 가입된 회원정보가 없습니다.");
exit;
}
}
}else{
// 인증실패 curl의 인증실패 체크
alert_close('코드 : '.$res_data['resultCode'].' '.urldecode($res_data['resultMsg']));
exit;
}
} else { // resultCode===0000 아닐경우 아래 인증 실패를 출력함
// 인증실패
alert_close('코드 : '.$_POST['resultCode'].' '.urldecode($_POST['resultMsg']));
exit;
}
$g5['title'] = 'KG이니시스 통합인증 결과';
include_once(G5_PATH.'/head.sub.php');
?>
<form name="mbFindForm">
<input type="hidden" name="mb_id" value="<?php echo $row["mb_id"]; ?>">
</form>
<script>
jQuery(function($) {
var $opener = window.opener;
var is_mobile = false;
$opener.name="parentPage";
if (typeof g5_is_mobile != "undefined" && g5_is_mobile ) {
$opener = window.parent;
is_mobile = true;
} else {
$opener = window.opener;
}
document.mbFindForm.target = "parentPage";
document.mbFindForm.action = "<?php echo G5_BBS_URL.'/password_reset.php'?>";
document.mbFindForm.submit();
alert("본인인증이 완료되었습니다.");
window.close();
});
</script>
<?php
include_once(G5_PATH.'/tail.sub.php');

View File

@ -7,19 +7,18 @@
$max_cr_id = $res['max_cr_id'];
if(empty($max_cr_id)) $max_cr_id = 0;
certify_count_check($member['mb_id'], 'sa'); // 금일 인증시도 횟수 체크
//$mid = 'SRA'.$config['cf_cert_kg_mid'];
$mid = $config['cf_cert_kg_mid']; // 부여받은 MID(상점ID) 입력(영업담당자 문의)
$apiKey = $config['cf_cert_kg_cd']; // 부여받은 MID 에 대한 apiKey
$mTxId ='SIR'.$max_cr_id;
if($config['cf_cert_use'] == 2) { // 테스트 일때
$mid = "INIiasTest";
$apiKey = "TGdxb2l3enJDWFRTbTgvREU3MGYwUT09";
$mTxId ='test_'.$max_cr_id;
} else {
$mid = 'SRA'.$config['cf_cert_kg_mid']; // 부여받은 MID(상점ID) 입력(영업담당자 문의)
$apiKey = $config['cf_cert_kg_cd']; // 부여받은 MID 에 대한 apiKey
$mTxId ='SIR_'.$max_cr_id.$type;
certify_count_check($member['mb_id'], 'sa'); // 금일 인증시도 횟수 체크
}
$reqSvcCd ='01';
if($config['cf_cert_use'] != 2) { // 테스트모드일때
$mid = $config['cf_cert_kg_mid'];
$apiKey = $config['cf_cert_kg_cd'];
$mTxId ='test_'.$max_cr_id;
}
// 등록가맹점 확인
$plainText1 = hash("sha256",(string)$mid.(string)$mTxId.(string)$apiKey);
$authHash = $plainText1;
@ -34,20 +33,10 @@
$plainText2 = hash("sha256",(string)$userName.(string)$mid.(string)$userPhone.(string)$mTxId.(string)$userBirth.(string)$reqSvcCd);
$userHash = $plainText2;
}
$g5['title'] = '통합인증 결과';
include_once(G5_PATH.'/head.sub.php');
$g5['title'] = 'KG이니시스 통합인증';
include_once(G5_PATH.'/head.sub.php');
?>
<script language="javascript">
function callSa() {
document.saForm.setAttribute("target", "_self");
document.saForm.setAttribute("post", "post");
document.saForm.setAttribute("action", "https://sa.inicis.com/auth");
document.saForm.submit();
}
</script>
</head>
<body>
<form name="saForm">
<input type="hidden" name="mid" value="<?php echo $mid ?>"> <!-- 필수 값 -->
<input type="hidden" name="reqSvcCd" value="<?php echo $reqSvcCd ?>"> <!-- 필수 값 -->
@ -63,9 +52,14 @@
<input type="hidden" name="directAgency" value="<?php echo $_POST['directAgency']; ?>">
<input type="hidden" name="successUrl" value="<?php echo G5_KGCERT_URL; ?>/kg_result.php"> <!-- 필수 값 -->
<input type="hidden" name="failUrl" value="<?php echo G5_KGCERT_URL; ?>/kg_response.php"> <!-- 필수 값 -->
<input type="hidden" name="failUrl" value="<?php echo G5_KGCERT_URL; ?>/kg_result.php"> <!-- 필수 값 -->
<!-- successUrl / failUrl 은 분리 하여 이용가능!-->
</form>
<script>
callSa();
document.saForm.setAttribute("target", "_self");
document.saForm.setAttribute("post", "post");
document.saForm.setAttribute("action", "https://sa.inicis.com/auth");
document.saForm.submit();
</script>
<?php
include_once(G5_PATH.'/tail.sub.php');

View File

@ -1,25 +0,0 @@
<?php
include_once('./_common.php');
extract($_POST);
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> ';
print_r2($_COOKIE);
// STEP2 에 이어 인증결과가 성공일(resultCode=0000) 경우 STEP2 에서 받은 인증결과로 아래 승인요청 진행
$txId = $_POST['txId'];
$mid = substr($txId, 6, 10);
print_r2($_SERVER);
print_r2($_SESSION);
print_r2($_POST);
die;
// echo '<인증결과내역>'."<br/><br/>";
// echo 'resultCode : '.$_REQUEST["resultCode"]."<br/>";
// echo 'resultMsg : '.$_REQUEST["resultMsg"]."<br/>";
// echo 'authRequestUrl : '.$_REQUEST["authRequestUrl"]."<br/>";
// echo 'txId : '.$_REQUEST["txId"]."<br/>";
// 인증실패
alert_close('코드 : '.$_POST['res_cd'].' '.urldecode($_POST['res_msg']));
exit;
include_once(G5_PATH.'/tail.sub.php');

View File

@ -1,116 +1,109 @@
<?php
include_once('./_common.php');
include_once('./_common.php');
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> ';
$txId = $_POST['txId'];
$mid = substr($txId, 6, 10);
if ($_POST["resultCode"] === "0000") {
$txId = $_POST['txId'];
$mid = substr($txId, 6, 10);
$data = array(
'mid' => $mid,
'txId' => $txId
);
if ($_POST["resultCode"] === "0000") {
$post_data = json_encode($data);
$data = array(
'mid' => $mid,
'txId' => $txId
);
// curl 통신 시작
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_POST["authRequestUrl"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
$res_data = json_decode($response, true);
// -------------------- 결과 수신 -------------------------------------------
echo '<결과내역>'." '{$mid}' <br/><br/>";
echo $response;
print_r2($_SESSION);
// print_r2($response);
if($res_data['resultCode'] == "0000") {
$post_data = json_encode($data);
@insert_cert_history($member['mb_id'], 'kg', 'sa'); // 인증성공 시 내역 기록
$cert_no = $res_data['txId']; // LG 인증처리번호
$phone_no = $res_data['userPhone']; // 전화번호
$user_name = $res_data['userName']; // 이름
$birth_day = $res_data['userBirthday']; // 생년월일
$ci = $res_data['userCi']; // CI
// curl 통신 시작
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_POST["authRequestUrl"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if(!$phone_no)
alert_close("정상적인 인증이 아닙니다. 올바른 방법으로 이용해 주세요.");
$response = curl_exec($ch);
curl_close($ch);
$res_data = json_decode($response, true);
// -------------------- 결과 수신 -------------------------------------------
// echo '<결과내역>'." '{$mid}' <br/><br/>";
// echo $response;
$ci_hash = md5($ci . $ci);
$phone_no = hyphen_hp_number($phone_no);
$mb_dupinfo = $ci_hash;
if($res_data['resultCode'] == "0000") {
$sql = " select mb_id from {$g5['member_table']} where mb_id <> '{$member['mb_id']}' and mb_dupinfo = '{$mb_dupinfo}' ";
$row = sql_fetch($sql);
if ($row['mb_id']) {
alert_close("입력하신 본인확인 정보로 가입된 내역이 존재합니다.\\n회원아이디 : ".$row['mb_id']);
@insert_cert_history($member['mb_id'], 'kg', 'sa'); // 인증성공 시 내역 기록
$cert_type = 'sa'; // 인증타입
$cert_no = $res_data['txId']; // 이니시스 트랜잭션 ID
$phone_no = $res_data['userPhone']; // 전화번호
$user_name = $res_data['userName']; // 이름
$birth_day = $res_data['userBirthday']; // 생년월일
$ci = $res_data['userCi']; // CI
if(!$phone_no)
alert_close("정상적인 인증이 아닙니다. 올바른 방법으로 이용해 주세요.");
$md5_ci = md5($ci . $ci);
$phone_no = hyphen_hp_number($phone_no);
$mb_dupinfo = $md5_ci;
$sql = " select mb_id from {$g5['member_table']} where mb_id <> '{$member['mb_id']}' and mb_dupinfo = '{$mb_dupinfo}' ";
$row = sql_fetch($sql);
if ($row['mb_id']) {
alert_close("입력하신 본인확인 정보로 가입된 내역이 존재합니다.\\n회원아이디 : ".$row['mb_id']);
}
// hash 데이터
$md5_cert_no = md5($cert_no);
$hash_data = md5($user_name.$cert_type.$birth_day.$md5_cert_no);
// 성인인증결과
$adult_day = date("Ymd", strtotime("-19 years", G5_SERVER_TIME));
$adult = ((int)$birth_day <= (int)$adult_day) ? 1 : 0;
set_session("ss_cert_type", $cert_type);
set_session("ss_cert_no", $md5_cert_no);
set_session("ss_cert_hash", $hash_data);
set_session("ss_cert_adult", $adult);
set_session("ss_cert_birth", $birth_day);
//set_session("ss_cert_sex", ($sex_code=="01"?"M":"F")); // 이니시스 통합인증은 성별정보 리턴 없음
set_session('ss_cert_dupinfo', $mb_dupinfo);
}else{
// 인증실패 curl의 인증실패 체크
alert_close('코드 : '.$res_data['resultCode'].' '.urldecode($res_data['resultMsg']));
exit;
}
// hash 데이터
$cert_type = 'sa';
$md5_cert_no = md5($cert_no);
$hash_data = md5($user_name.$cert_type.$birth_day.$md5_cert_no);
// 성인인증결과
$adult_day = date("Ymd", strtotime("-19 years", G5_SERVER_TIME));
$adult = ((int)$birth_day <= (int)$adult_day) ? 1 : 0;
set_session("ss_cert_type", $cert_type);
set_session("ss_cert_no", $md5_cert_no);
set_session("ss_cert_hash", $hash_data);
set_session("ss_cert_adult", $adult);
set_session("ss_cert_birth", $birth_day);
//set_session("ss_cert_sex", ($sex_code=="01"?"M":"F"));
set_session('ss_cert_dupinfo', $mb_dupinfo);
}else{
} else { // resultCode===0000 아닐경우 아래 인증 실패를 출력함
// 인증실패
alert_close('코드 : '.$res_data['resultCode'].' '.urldecode($res_data['resultMsg']));
alert_close('코드 : '.$_POST['resultCode'].' '.urldecode($_POST['resultMsg']));
exit;
}
} else { // resultCode===0000 아닐경우 아래 인증 실패를 출력함
// 인증실패
alert_close('코드 : '.$_POST['resultCode'].' '.urldecode($_POST['resultMsg']));
exit;
}
$g5['title'] = '통합인증 결과';
include_once(G5_PATH.'/head.sub.php');
?>
$g5['title'] = 'KG이니시스 통합인증 결과';
include_once(G5_PATH.'/head.sub.php');
?>
<script>
jQuery(function($) {
var $opener = window.opener;
var is_mobile = false;
jQuery(function($) {
var $opener = window.opener;
if (typeof g5_is_mobile != "undefined" && g5_is_mobile ) {
$opener = window.parent;
is_mobile = true;
} else {
$opener = window.opener;
}
if (typeof g5_is_mobile != "undefined" && g5_is_mobile ) {
$opener = window.parent;
is_mobile = true;
} else {
$opener = window.opener;
}
// 인증정보
$opener.$("input[name=cert_type]").val("<?php echo $cert_type; ?>");
$opener.$("input[name=mb_name]").val("<?php echo $user_name; ?>").attr("readonly", true);
$opener.$("input[name=mb_hp]").val("<?php echo $phone_no; ?>").attr("readonly", true);
$opener.$("input[name=cert_no]").val("<?php echo $md5_cert_no; ?>");
// 인증정보
$opener.$("input[name=cert_type]").val("<?php echo $cert_type; ?>");
$opener.$("input[name=mb_name]").val("<?php echo $user_name; ?>").attr("readonly", true);
$opener.$("input[name=mb_hp]").val("<?php echo $phone_no; ?>").attr("readonly", true);
$opener.$("input[name=cert_no]").val("<?php echo $md5_cert_no; ?>");
if(is_mobile) {
$opener.$("#cert_info").css("display", "");
$opener.$("#lgu_cert" ).css("display", "none");
}
alert("본인인증이 완료되었습니다.");
window.close();
});
alert("본인인증이 완료되었습니다.");
window.close();
});
</script>
<?php
include_once(G5_PATH.'/tail.sub.php');
include_once(G5_PATH.'/tail.sub.php');