mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-13 06:18:17 +02:00
Basic NIS2 support in identica extension
This commit is contained in:
parent
f27e62e125
commit
12c5fa3eb1
4 changed files with 84 additions and 16 deletions
34
docs/epp.md
34
docs/epp.md
|
@ -462,6 +462,23 @@ Each command section below includes real-world XML request and response samples
|
||||||
</epp>
|
</epp>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Response with Identica in database:**
|
||||||
|
|
||||||
|
```xml
|
||||||
|
...
|
||||||
|
<extension>
|
||||||
|
<identica:infData
|
||||||
|
xmlns:identica="https://namingo.org/epp/identica-1.0"
|
||||||
|
xsi:schemaLocation="https://namingo.org/epp/identica-1.0 identica-1.0.xsd">
|
||||||
|
<identica:nin type="personal">1234567890</identica:nin>
|
||||||
|
<identica:status>2</identica:status>
|
||||||
|
<identica:date>2025-07-02T10:34:00.000Z</identica:date>
|
||||||
|
<identica:details>admin42|api|Validated via national ID system</identica:details>
|
||||||
|
</identica:infData>
|
||||||
|
</extension>
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
#### 2.4. Contact Update
|
#### 2.4. Contact Update
|
||||||
|
|
||||||
**Standard request:**
|
**Standard request:**
|
||||||
|
@ -538,6 +555,9 @@ Each command section below includes real-world XML request and response samples
|
||||||
xmlns:identica="https://namingo.org/epp/identica-1.0"
|
xmlns:identica="https://namingo.org/epp/identica-1.0"
|
||||||
xsi:schemaLocation="https://namingo.org/epp/identica-1.0 identica-1.0.xsd">
|
xsi:schemaLocation="https://namingo.org/epp/identica-1.0 identica-1.0.xsd">
|
||||||
<identica:nin type="personal">1234567890</identica:nin>
|
<identica:nin type="personal">1234567890</identica:nin>
|
||||||
|
<identica:status>2</identica:status>
|
||||||
|
<identica:date>2025-07-02T10:34:00.000Z</identica:date>
|
||||||
|
<identica:details>admin42|api|Validated via national ID system</identica:details>
|
||||||
</identica:update>
|
</identica:update>
|
||||||
</extension>
|
</extension>
|
||||||
<clTRID>client-20241128-12345</clTRID>
|
<clTRID>client-20241128-12345</clTRID>
|
||||||
|
@ -1189,20 +1209,6 @@ Each command section below includes real-world XML request and response samples
|
||||||
</epp>
|
</epp>
|
||||||
```
|
```
|
||||||
|
|
||||||
**Response with Identica in database:**
|
|
||||||
|
|
||||||
```xml
|
|
||||||
...
|
|
||||||
<extension>
|
|
||||||
<identica:infData
|
|
||||||
xmlns:identica="https://namingo.org/epp/identica-1.0"
|
|
||||||
xsi:schemaLocation="https://namingo.org/epp/identica-1.0 identica-1.0.xsd">
|
|
||||||
<identica:nin type="personal">1234567890</identica:nin>
|
|
||||||
</identica:infData>
|
|
||||||
</extension>
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 4.4. Domain Update
|
#### 4.4. Domain Update
|
||||||
|
|
||||||
**Request:**
|
**Request:**
|
||||||
|
|
|
@ -612,6 +612,22 @@ class EppWriter {
|
||||||
$writer->text($resp['nin']);
|
$writer->text($resp['nin']);
|
||||||
$writer->endElement(); // End of 'identica:nin'
|
$writer->endElement(); // End of 'identica:nin'
|
||||||
|
|
||||||
|
// Validation status
|
||||||
|
if (isset($resp['validation'])) {
|
||||||
|
$writer->writeElement('identica:status', $resp['validation']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validation timestamp
|
||||||
|
if (!empty($resp['validation_stamp'])) {
|
||||||
|
$stamp = new \DateTime($resp['validation_stamp']);
|
||||||
|
$writer->writeElement('identica:date', $stamp->format('Y-m-d\TH:i:s.v\Z'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validation log
|
||||||
|
if (!empty($resp['validation_log'])) {
|
||||||
|
$writer->writeElement('identica:details', $resp['validation_log']);
|
||||||
|
}
|
||||||
|
|
||||||
$writer->endElement(); // End of 'identica:infData'
|
$writer->endElement(); // End of 'identica:infData'
|
||||||
$writer->endElement(); // End of 'extension'
|
$writer->endElement(); // End of 'extension'
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ function processContactInfo($conn, $db, $xml, $clid, $trans) {
|
||||||
// Optimized single query
|
// Optimized single query
|
||||||
$stmt = $db->prepare("
|
$stmt = $db->prepare("
|
||||||
SELECT c.id, c.identifier, c.voice, c.fax, c.email, c.clid, c.crid, c.crdate, c.upid, c.lastupdate,
|
SELECT c.id, c.identifier, c.voice, c.fax, c.email, c.clid, c.crid, c.crdate, c.upid, c.lastupdate,
|
||||||
c.disclose_voice, c.disclose_fax, c.disclose_email,
|
c.disclose_voice, c.disclose_fax, c.disclose_email, c.nin, c.nin_type, c.validation, c.validation_stamp, c.validation_log,
|
||||||
p.type AS postal_type, p.name, p.org, p.street1, p.street2, p.street3, p.city, p.sp, p.pc, p.cc,
|
p.type AS postal_type, p.name, p.org, p.street1, p.street2, p.street3, p.city, p.sp, p.pc, p.cc,
|
||||||
p.disclose_name_int, p.disclose_name_loc, p.disclose_org_int, p.disclose_org_loc,
|
p.disclose_name_int, p.disclose_name_loc, p.disclose_org_int, p.disclose_org_loc,
|
||||||
p.disclose_addr_int, p.disclose_addr_loc,
|
p.disclose_addr_int, p.disclose_addr_loc,
|
||||||
|
@ -120,6 +120,23 @@ function processContactInfo($conn, $db, $xml, $clid, $trans) {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($contactRow['nin']) && !empty($contactRow['nin_type'])) {
|
||||||
|
$response['nin'] = $contactRow['nin'];
|
||||||
|
$response['nin_type'] = $contactRow['nin_type'];
|
||||||
|
|
||||||
|
if (!is_null($contactRow['validation'])) {
|
||||||
|
$response['validation'] = $contactRow['validation'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($contactRow['validation_stamp'])) {
|
||||||
|
$response['validation_stamp'] = $contactRow['validation_stamp'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($contactRow['validation_log'])) {
|
||||||
|
$response['validation_log'] = $contactRow['validation_log'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$epp = new EPP\EppWriter();
|
$epp = new EPP\EppWriter();
|
||||||
$xml = $epp->epp_writer($response);
|
$xml = $epp->epp_writer($response);
|
||||||
updateTransaction($db, 'info', 'contact', $contactID, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
|
updateTransaction($db, 'info', 'contact', $contactID, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
|
||||||
|
|
|
@ -431,6 +431,13 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
|
||||||
if ($identica_update) {
|
if ($identica_update) {
|
||||||
$nin = (string)$identica_update->xpath('//identica:nin[1]')[0];
|
$nin = (string)$identica_update->xpath('//identica:nin[1]')[0];
|
||||||
$nin_type = (string)$identica_update->xpath('//identica:nin/@type[1]')[0];
|
$nin_type = (string)$identica_update->xpath('//identica:nin/@type[1]')[0];
|
||||||
|
$status = $identica_update->xpath('//identica:status[1]');
|
||||||
|
$statusDate = $identica_update->xpath('//identica:date[1]');
|
||||||
|
$statusDetails = $identica_update->xpath('//identica:details[1]');
|
||||||
|
|
||||||
|
$validation = isset($status[0]) ? (string)$status[0] : null;
|
||||||
|
$validation_stamp = isset($statusDate[0]) ? (string)$statusDate[0] : null;
|
||||||
|
$validation_log = isset($statusDetails[0]) ? (string)$statusDetails[0] : null;
|
||||||
|
|
||||||
if (!preg_match('/\d/', $nin)) {
|
if (!preg_match('/\d/', $nin)) {
|
||||||
sendEppError($conn, $db, 2005, 'NIN should contain one or more numbers', $clTRID, $trans);
|
sendEppError($conn, $db, 2005, 'NIN should contain one or more numbers', $clTRID, $trans);
|
||||||
|
@ -441,6 +448,21 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
|
||||||
sendEppError($conn, $db, 2005, 'NIN Type should contain personal or business', $clTRID, $trans);
|
sendEppError($conn, $db, 2005, 'NIN Type should contain personal or business', $clTRID, $trans);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($validation !== null && !in_array($validation, ['0','1','2','3','4'])) {
|
||||||
|
sendEppError($conn, $db, 2005, 'Validation status must be 0–4', $clTRID, $trans);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($validation_stamp !== null && !preg_match('/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/', $validation_stamp)) {
|
||||||
|
sendEppError($conn, $db, 2005, 'Invalid status date format. Use ISO 8601 format like 2025-07-02T12:00:00.000Z', $clTRID, $trans);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($validation_log !== null && strlen($validation_log) > 255) {
|
||||||
|
sendEppError($conn, $db, 2005, 'Validation log exceeds maximum allowed length (255 characters)', $clTRID, $trans);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($contactRem)) {
|
if (!empty($contactRem)) {
|
||||||
|
@ -703,7 +725,11 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($identica_update) {
|
if ($identica_update) {
|
||||||
$query = "UPDATE contact SET nin = ?, nin_type = ?, upid = ?, lastupdate = CURRENT_TIMESTAMP(3) WHERE id = ?";
|
$query = "
|
||||||
|
UPDATE contact
|
||||||
|
SET nin = ?, nin_type = ?, validation = ?, validation_stamp = ?, validation_log = ?, upid = ?, lastupdate = CURRENT_TIMESTAMP(3)
|
||||||
|
WHERE id = ?
|
||||||
|
";
|
||||||
$stmt = $db->prepare($query);
|
$stmt = $db->prepare($query);
|
||||||
|
|
||||||
if (!$stmt) {
|
if (!$stmt) {
|
||||||
|
@ -714,6 +740,9 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
|
||||||
$result = $stmt->execute([
|
$result = $stmt->execute([
|
||||||
$nin ?: null,
|
$nin ?: null,
|
||||||
$nin_type ?: null,
|
$nin_type ?: null,
|
||||||
|
$validation,
|
||||||
|
$validation_stamp ?: null,
|
||||||
|
$validation_log ?: null,
|
||||||
$clid,
|
$clid,
|
||||||
$contact_id
|
$contact_id
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue