All checks were successful
ci/woodpecker/push/push Pipeline was successful
## Added - CoT (Cursor on Target) server on port 8089 enabling ATAK/iTAK device connectivity - Support for TAK stream protocol and traditional XML CoT messages - TLS/SSL support with automatic fallback to plain TCP - Username/password authentication for CoT connections - Real-time device position tracking with TTL-based expiration (90s default) - API endpoints: `/api/cot/config`, `/api/cot/server-package`, `/api/cot/truststore`, `/api/me/cot-password` - TAK Server section in Settings with QR code for iTAK setup - ATAK password management in Account page for OIDC users - CoT device markers on map showing real-time positions - Comprehensive documentation in `docs/` directory - Environment variables: `COT_PORT`, `COT_TTL_MS`, `COT_REQUIRE_AUTH`, `COT_SSL_CERT`, `COT_SSL_KEY`, `COT_DEBUG` - Dependencies: `fast-xml-parser`, `jszip`, `qrcode` ## Changed - Authentication system supports CoT password management for OIDC users - Database schema includes `cot_password_hash` field - Test suite refactored to follow functional design principles ## Removed - Consolidated utility modules: `authConfig.js`, `authSkipPaths.js`, `bootstrap.js`, `poiConstants.js`, `session.js` ## Security - XML entity expansion protection in CoT parser - Enhanced input validation and SQL injection prevention - Authentication timeout to prevent hanging connections ## Breaking Changes - Port 8089 must be exposed for CoT server. Update firewall rules and Docker/Kubernetes configurations. ## Migration Notes - OIDC users must set ATAK password via Account settings before connecting - Docker: expose port 8089 (`-p 8089:8089`) - Kubernetes: update Helm values to expose port 8089 Co-authored-by: Madison Grubb <madison@elastiflow.com> Reviewed-on: #6
61 lines
2.2 KiB
JavaScript
61 lines
2.2 KiB
JavaScript
import { existsSync } from 'node:fs'
|
|
import JSZip from 'jszip'
|
|
import { getCotSslPaths, getCotPort, TRUSTSTORE_PASSWORD, COT_TLS_REQUIRED_MESSAGE, buildP12FromCertPath } from '../../utils/cotSsl.js'
|
|
import { requireAuth } from '../../utils/authHelpers.js'
|
|
|
|
/**
|
|
* Build config.pref XML for iTAK: server connection + CA cert for trust (credentials entered in app).
|
|
* connectString format: host:port:ssl or host:port:tcp
|
|
*/
|
|
function buildConfigPref(hostname, port, ssl) {
|
|
const connectString = `${hostname}:${port}:${ssl ? 'ssl' : 'tcp'}`
|
|
return `<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
|
|
<preference-set id="com.atakmap.app_preferences">
|
|
<entry key="connectionEntry">1</entry>
|
|
<entry key="description">KestrelOS</entry>
|
|
<entry key="enabled">true</entry>
|
|
<entry key="connectString">${escapeXml(connectString)}</entry>
|
|
<entry key="caCertPath">cert/caCert.p12</entry>
|
|
<entry key="caCertPassword">${escapeXml(TRUSTSTORE_PASSWORD)}</entry>
|
|
<entry key="cacheCredentials">true</entry>
|
|
</preference-set>
|
|
`
|
|
}
|
|
|
|
function escapeXml(s) {
|
|
return String(s)
|
|
.replace(/&/g, '&')
|
|
.replace(/</g, '<')
|
|
.replace(/>/g, '>')
|
|
.replace(/"/g, '"')
|
|
}
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
requireAuth(event)
|
|
const config = useRuntimeConfig()
|
|
const paths = getCotSslPaths(config)
|
|
if (!paths || !existsSync(paths.certPath)) {
|
|
setResponseStatus(event, 404)
|
|
return { error: `CoT server is not using TLS. Server package ${COT_TLS_REQUIRED_MESSAGE} Use the QR code and add the server with SSL disabled (plain TCP) instead.` }
|
|
}
|
|
|
|
const hostname = getRequestURL(event).hostname
|
|
const port = getCotPort()
|
|
|
|
try {
|
|
const p12 = buildP12FromCertPath(paths.certPath, TRUSTSTORE_PASSWORD)
|
|
const zip = new JSZip()
|
|
zip.file('config.pref', buildConfigPref(hostname, port, true))
|
|
zip.folder('cert').file('caCert.p12', p12)
|
|
|
|
const blob = await zip.generateAsync({ type: 'nodebuffer' })
|
|
setHeader(event, 'Content-Type', 'application/zip')
|
|
setHeader(event, 'Content-Disposition', 'attachment; filename="kestrelos-itak-server-package.zip"')
|
|
return blob
|
|
}
|
|
catch (err) {
|
|
setResponseStatus(event, 500)
|
|
return { error: 'Failed to build server package.', detail: err?.message }
|
|
}
|
|
})
|