mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-09-23 23:10:34 +00:00
DNS Provider configuration
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import express from "express";
|
||||
import dnsPlugins from "../../global/certbot-dns-plugins.json" with { type: "json" };
|
||||
import internalCertificate from "../../internal/certificate.js";
|
||||
import errs from "../../lib/error.js";
|
||||
import jwtdecode from "../../lib/express/jwt-decode.js";
|
||||
@@ -72,6 +73,38 @@ router
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* /api/nginx/certificates/dns-providers
|
||||
*/
|
||||
router
|
||||
.route("/dns-providers")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
.all(jwtdecode())
|
||||
|
||||
/**
|
||||
* GET /api/nginx/certificates/dns-providers
|
||||
*
|
||||
* Get list of all supported DNS providers
|
||||
*/
|
||||
.get(async (req, res, next) => {
|
||||
try {
|
||||
if (!res.locals.access.token.getUserId()) {
|
||||
throw new errs.PermissionError("Login required");
|
||||
}
|
||||
const clean = Object.keys(dnsPlugins).map((key) => ({
|
||||
id: key,
|
||||
name: dnsPlugins[key].name,
|
||||
credentials: dnsPlugins[key].credentials,
|
||||
}));
|
||||
res.status(200).send(clean);
|
||||
} catch (err) {
|
||||
logger.debug(`${req.method.toUpperCase()} ${req.path}: ${err}`);
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Test HTTP challenge for domains
|
||||
*
|
||||
@@ -107,6 +140,41 @@ router
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Validate Certs before saving
|
||||
*
|
||||
* /api/nginx/certificates/validate
|
||||
*/
|
||||
router
|
||||
.route("/validate")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
.all(jwtdecode())
|
||||
|
||||
/**
|
||||
* POST /api/nginx/certificates/validate
|
||||
*
|
||||
* Validate certificates
|
||||
*/
|
||||
.post(async (req, res, next) => {
|
||||
if (!req.files) {
|
||||
res.status(400).send({ error: "No files were uploaded" });
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await internalCertificate.validate({
|
||||
files: req.files,
|
||||
});
|
||||
res.status(200).send(result);
|
||||
} catch (err) {
|
||||
logger.debug(`${req.method.toUpperCase()} ${req.path}: ${err}`);
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Specific certificate
|
||||
*
|
||||
@@ -266,38 +334,4 @@ router
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Validate Certs before saving
|
||||
*
|
||||
* /api/nginx/certificates/validate
|
||||
*/
|
||||
router
|
||||
.route("/validate")
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
.all(jwtdecode())
|
||||
|
||||
/**
|
||||
* POST /api/nginx/certificates/validate
|
||||
*
|
||||
* Validate certificates
|
||||
*/
|
||||
.post(async (req, res, next) => {
|
||||
if (!req.files) {
|
||||
res.status(400).send({ error: "No files were uploaded" });
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await internalCertificate.validate({
|
||||
files: req.files,
|
||||
});
|
||||
res.status(200).send(result);
|
||||
} catch (err) {
|
||||
logger.debug(`${req.method.toUpperCase()} ${req.path}: ${err}`);
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
@@ -14,11 +14,12 @@ router
|
||||
.options((_, res) => {
|
||||
res.sendStatus(204);
|
||||
})
|
||||
.all(jwtdecode())
|
||||
|
||||
/**
|
||||
* GET /reports/hosts
|
||||
*/
|
||||
.get(jwtdecode(), async (req, res, next) => {
|
||||
.get(async (req, res, next) => {
|
||||
try {
|
||||
const data = await internalReport.getHostsReport(res.locals.access);
|
||||
res.status(200).send(data);
|
||||
|
Reference in New Issue
Block a user