Skip to content

Feature: Add multi factor authentication #4345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add dead_hosts and redirection_hosts
  • Loading branch information
badkeyy committed Jan 9, 2025
commit 50f7bfc7261d16bc1ecbcba5b8bbfd8549e5783c
4 changes: 4 additions & 0 deletions backend/internal/certificate.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ const internalCertificate = {
.andWhere('id', data.id)
.allowGraph('[owner]')
.allowGraph('[proxy_hosts]')
.allowGraph('[redirection_hosts]')
.allowGraph('[dead_hosts]')
.first();

if (access_data.permission_visibility !== 'all') {
Expand Down Expand Up @@ -466,6 +468,8 @@ const internalCertificate = {
.groupBy('id')
.allowGraph('[owner]')
.allowGraph('[proxy_hosts]')
.allowGraph('[redirection_hosts]')
.allowGraph('[dead_hosts]')
.orderBy('nice_name', 'ASC');

if (access_data.permission_visibility !== 'all') {
Expand Down
29 changes: 27 additions & 2 deletions backend/models/certificate.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ class Certificate extends Model {
}

static get relationMappings () {
const ProxyHost = require('./proxy_host');
const User = require('./user');
const ProxyHost = require('./proxy_host');
const DeadHost = require('./dead_host');
const User = require('./user');
const RedirectionHost = require('./redirection_host');

return {
owner: {
relation: Model.HasOneRelation,
Expand All @@ -91,6 +94,28 @@ class Certificate extends Model {
modify: function (qb) {
qb.where('proxy_host.is_deleted', 0);
}
},
dead_hosts: {
relation: Model.HasManyRelation,
modelClass: DeadHost,
join: {
from: 'certificate.id',
to: 'dead_host.certificate_id'
},
modify: function (qb) {
qb.where('dead_host.is_deleted', 0);
}
},
redirection_hosts: {
relation: Model.HasManyRelation,
modelClass: RedirectionHost,
join: {
from: 'certificate.id',
to: 'redirection_host.certificate_id'
},
modify: function (qb) {
qb.where('redirection_host.is_deleted', 0);
}
}
};
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/js/app/nginx/certificates/list/item.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<%- formatDbDate(expires_on, 'Do MMMM YYYY, h:mm a') %>
</td>
<td>
<% if (proxy_hosts.length > 0) { %>
<% if (active_domain_names().length > 0) { %>
<span class="status-icon bg-success"></span> <%- i18n('certificates', 'in-use') %>
<% } else { %>
<span class="status-icon bg-danger"></span> <%- i18n('certificates', 'inactive') %>
Expand All @@ -55,10 +55,10 @@
<div class="dropdown-divider"></div>
<% } %>
<a href="#" class="delete dropdown-item"><i class="dropdown-icon fe fe-trash-2"></i> <%- i18n('str', 'delete') %></a>
<% if (proxy_hosts.length > 0) { %>
<% if (active_domain_names().length > 0) { %>
<div class="dropdown-divider"></div>
<span class="dropdown-header"><%- i18n('certificates', 'active-domain_names') %></span>
<% proxy_hosts.forEach(function(host) { %>
<% active_domain_names().forEach(function(host) { %>
<a href="https://<%- host %>" class="dropdown-item" target="_blank"><%- host %></a>
<% }); %>
<% } %>
Expand Down
17 changes: 9 additions & 8 deletions frontend/js/app/nginx/certificates/list/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,21 @@ module.exports = Mn.View.extend({
return {
canManage: App.Cache.User.canManage('certificates'),
isExpired: function () {
console.log(this);
return moment(this.expires_on).isBefore(moment());
},
dns_providers: dns_providers,
proxy_hosts: this.getProxyHosts()
active_domain_names: function () {
const { proxy_hosts = [], redirect_hosts = [], dead_hosts = [] } = this;
console.log(proxy_hosts)
return [...proxy_hosts, ...redirect_hosts, ...dead_hosts].reduce((acc, host) => {
acc.push(...(host.domain_names || []));
return acc;
}, []);
}
};
},

getProxyHosts: function () {
const hosts = this.model.attributes.proxy_hosts || [];
return hosts.reduce((acc, host) => {
acc.push(...(host.domain_names || []));
return acc;
}, []);
},

initialize: function () {
this.listenTo(this.model, 'change', this.render);
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/app/nginx/certificates/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = Mn.View.extend({
e.preventDefault();
let query = this.ui.query.val();

this.fetch(['owner','proxy_hosts'], query)
this.fetch(['owner','proxy_hosts', 'dead_hosts', 'redirection_hosts'], query)
.then(response => this.showData(response))
.catch(err => {
this.showError(err);
Expand All @@ -89,7 +89,7 @@ module.exports = Mn.View.extend({
onRender: function () {
let view = this;

view.fetch(['owner','proxy_hosts'])
view.fetch(['owner','proxy_hosts', 'dead_hosts', 'redirection_hosts'])
.then(response => {
if (!view.isDestroyed()) {
if (response && response.length) {
Expand Down