fix a few bugs in cert issuance and comment out a check in cluster deletion until they are converted to have an ID

set default cluster in gulpfile for new user
fix cert table to colspan missing columns in the ad form and make "not in db" shown correctly
develop
Thomas Lynch 1 year ago
parent 6ece796b18
commit d1b490a41d
  1. 4
      controllers/certs.js
  2. 8
      controllers/clusters.js
  3. 2
      docker-compose.yml
  4. 2
      gulpfile.js
  5. 6
      pages/_app.js
  6. 3
      pages/certs.js

@ -86,12 +86,12 @@ exports.addCert = async (req, res, next) => {
map: process.env.HOSTS_MAP_NAME map: process.env.HOSTS_MAP_NAME
}) })
.then(res => res.data); .then(res => res.data);
const backendDomainEntry = backendMap && backendMap.find(e => e.value === req.body.subject); const backendDomainEntry = backendMap && backendMap.find(e => e.key === req.body.subject);
if (!backendDomainEntry) { if (!backendDomainEntry) {
return dynamicResponse(req, res, 400, { error: 'Add a backend for the domain first before generating a certificate' }); return dynamicResponse(req, res, 400, { error: 'Add a backend for the domain first before generating a certificate' });
} }
const noBackend = await db.db.collection('certs').findOne({ _id: subject }); const existingCert = await db.db.collection('certs').findOne({ _id: subject });
if (existingCert) { if (existingCert) {
return dynamicResponse(req, res, 400, { error: 'Cert with this subject already exists' }); return dynamicResponse(req, res, 400, { error: 'Cert with this subject already exists' });
} }

@ -76,10 +76,10 @@ exports.deleteClusters = async (req, res, next) => {
|| !req.body.cluster.some(c => existingClusters.has(c))) { || !req.body.cluster.some(c => existingClusters.has(c))) {
return dynamicResponse(req, res, 400, { error: 'Invalid cluster' }); return dynamicResponse(req, res, 400, { error: 'Invalid cluster' });
} }
const filteredClusters = res.locals.user.clusters.filter(c => !req.body.cluster.includes(c)); const filteredClusters = res.locals.clusters.filter(c => !req.body.cluster.includes(c));
if (filteredClusters.length === 0) { // if (filteredClusters.length === 0) {
return dynamicResponse(req, res, 400, { error: 'Cannot delete last cluster' }); // return dynamicResponse(req, res, 400, { error: 'Cannot delete last cluster' });
} // }
let newActiveCluster = res.locals.user.activeCluster; let newActiveCluster = res.locals.user.activeCluster;
if (res.locals.user.activeCluster > filteredClusters.length-1) { if (res.locals.user.activeCluster > filteredClusters.length-1) {
newActiveCluster = 0; newActiveCluster = 0;

@ -3,7 +3,6 @@ services:
haproxy_panel_next: haproxy_panel_next:
restart: always restart: always
build: . build: .
network_mode: host
ports: ports:
- "127.0.0.1:3000:3000" - "127.0.0.1:3000:3000"
environment: environment:
@ -15,7 +14,6 @@ services:
haproxy_panel_mongo: haproxy_panel_mongo:
restart: always restart: always
image: mongo:latest image: mongo:latest
network_mode: host
ports: ports:
- "127.0.0.1:27017:27017" - "127.0.0.1:27017:27017"
networks: networks:

@ -16,7 +16,7 @@ async function reset() {
_id: 'admin', _id: 'admin',
passwordHash: passwordHash, passwordHash: passwordHash,
domains: ['localhost'], domains: ['localhost'],
clusters: ['http://admin:admin@127.0.0.1:2001'], clusters: [process.env.DEFAULT_CLUSTER],
activeCluster: 0, activeCluster: 0,
balance: 0, balance: 0,
}); });

@ -27,8 +27,10 @@ export default function App({ Component, pageProps }) {
.nav-link:hover { color: #6aa6fd; } .nav-link:hover { color: #6aa6fd; }
.mobile-menu { margin: 0 -16px; } .mobile-menu { margin: 0 -16px; }
.fs-xs { font-size: small; } .fs-xs { font-size: small; }
.text-decoration-none { .table, .list-group { box-shadow: 0 0px 3px rgba(0,0,0,.1); max-width: max-content; min-width: 600px; }
color: var(--bs-body-color); .text-decoration-none { color: var(--bs-body-color); }
@media (max-width: 650px) {
.table, .list-group { min-width: unset; }
} }
@media (min-width: 800px) { @media (min-width: 800px) {
.mobile-btn { display: none!important; } .mobile-btn { display: none!important; }

@ -54,7 +54,7 @@ export default function Certs(props) {
const clusterOnlyCerts = clusterCerts const clusterOnlyCerts = clusterCerts
.filter(c => !dbCerts.some(dc => dc.storageName === c.storage_name)) .filter(c => !dbCerts.some(dc => dc.storageName === c.storage_name))
.filter(c => !c.storage_name === 'selfsigned.pem'); //no point showing this .filter(c => c.storage_name !== 'selfsigned.pem'); //no point showing this
const clusterOnlyCertList = clusterOnlyCerts.map((c, i) => { const clusterOnlyCertList = clusterOnlyCerts.map((c, i) => {
const approxSubject = c.storage_name const approxSubject = c.storage_name
.replace('_', '.') .replace('_', '.')
@ -183,6 +183,7 @@ export default function Certs(props) {
<input className="form-control me-3" type="text" name="altnames" placeholder="www.domain.com,staging.domain.com,etc..." required /> <input className="form-control me-3" type="text" name="altnames" placeholder="www.domain.com,staging.domain.com,etc..." required />
</form> </form>
</td> </td>
<td colSpan="2"></td>
</tr> </tr>
</tbody> </tbody>

Loading…
Cancel
Save