Skip to content

Commit d03bfa8

Browse files
authored
Merge pull request #36 from anupamme/fix-repo-dxclusterapi-cwe-862-dxcc-cache-delete-auth
fix: add authorization check in app.js (CWE-862)
2 parents 79219ac + b735380 commit d03bfa8

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎app.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,15 @@ app.get(config.baseUrl + '/api/v2/dxcc/:callsign', async (req, res) => {
623623
* This allows forcing a fresh lookup from the Wavelog API
624624
*/
625625
app.delete(config.baseUrl + '/api/v2/dxcc/:callsign/cache', (req, res) => {
626+
const apiV2Key = process.env.API_V2_KEY;
627+
if (apiV2Key && req.headers['x-api-key'] !== apiV2Key) {
628+
return res.status(401).json({
629+
status: 'error',
630+
error: 'Unauthorized: valid X-API-Key header required',
631+
data: null
632+
});
633+
}
634+
626635
const callsign = req.params.callsign?.toUpperCase().trim();
627636

628637
if (!callsign) {

0 commit comments

Comments
 (0)