mirror of
https://github.com/jc21/nginx-proxy-manager.git
synced 2024-08-30 18:22:48 +00:00
Access lists
This commit is contained in:
parent
13f08df46c
commit
7d9e716c7c
@ -128,7 +128,7 @@ const internalAccessList = {
|
|||||||
.then(row => {
|
.then(row => {
|
||||||
if (row) {
|
if (row) {
|
||||||
if (typeof row.items !== 'undefined' && row.items) {
|
if (typeof row.items !== 'undefined' && row.items) {
|
||||||
row.items = internalAccessList.maskItems(row.items);
|
row = internalAccessList.maskItems(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _.omit(row, omissions());
|
return _.omit(row, omissions());
|
||||||
@ -180,11 +180,14 @@ const internalAccessList = {
|
|||||||
.then(access_data => {
|
.then(access_data => {
|
||||||
let query = accessListModel
|
let query = accessListModel
|
||||||
.query()
|
.query()
|
||||||
.where('is_deleted', 0)
|
.select('access_list.*', accessListModel.raw('COUNT(proxy_hosts.id) as proxy_host_count'), accessListModel.raw('COUNT(items.id) as item_count'))
|
||||||
.groupBy('id')
|
.leftJoinRelation('proxy_hosts')
|
||||||
.omit(['is_deleted'])
|
.leftJoinRelation('items')
|
||||||
|
.where('access_list.is_deleted', 0)
|
||||||
|
.groupBy('access_list.id')
|
||||||
|
.omit(['access_list.is_deleted'])
|
||||||
.allowEager('[owner,items]')
|
.allowEager('[owner,items]')
|
||||||
.orderBy('name', 'ASC');
|
.orderBy('access_list.name', 'ASC');
|
||||||
|
|
||||||
if (access_data.permission_visibility !== 'all') {
|
if (access_data.permission_visibility !== 'all') {
|
||||||
query.andWhere('owner_user_id', access.token.get('attrs').id);
|
query.andWhere('owner_user_id', access.token.get('attrs').id);
|
||||||
@ -207,7 +210,7 @@ const internalAccessList = {
|
|||||||
if (rows) {
|
if (rows) {
|
||||||
rows.map(function (row, idx) {
|
rows.map(function (row, idx) {
|
||||||
if (typeof row.items !== 'undefined' && row.items) {
|
if (typeof row.items !== 'undefined' && row.items) {
|
||||||
rows[idx].items = internalAccessList.maskItems(row.items);
|
rows[idx] = internalAccessList.maskItems(row);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@ class AccessList extends Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static get relationMappings () {
|
static get relationMappings () {
|
||||||
|
const ProxyHost = require('./proxy_host');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
owner: {
|
owner: {
|
||||||
relation: Model.HasOneRelation,
|
relation: Model.HasOneRelation,
|
||||||
@ -56,6 +58,18 @@ class AccessList extends Model {
|
|||||||
modify: function (qb) {
|
modify: function (qb) {
|
||||||
qb.omit(['id', 'created_on', 'modified_on']);
|
qb.omit(['id', 'created_on', 'modified_on']);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
proxy_hosts: {
|
||||||
|
relation: Model.HasManyRelation,
|
||||||
|
modelClass: ProxyHost,
|
||||||
|
join: {
|
||||||
|
from: 'access_list.id',
|
||||||
|
to: 'proxy_host.access_list_id'
|
||||||
|
},
|
||||||
|
modify: function (qb) {
|
||||||
|
qb.where('proxy_host.is_deleted', 0);
|
||||||
|
qb.omit(['id', 'created_on', 'modified_on', 'is_deleted', 'meta']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -5,25 +5,17 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>
|
<div>
|
||||||
<% domain_names.map(function(host) {
|
<%- name %>
|
||||||
%>
|
|
||||||
<span class="tag"><%- host %></span>
|
|
||||||
<%
|
|
||||||
});
|
|
||||||
%>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="small text-muted">
|
<div class="small text-muted">
|
||||||
<%- i18n('str', 'created-on', {date: formatDbDate(created_on, 'Do MMMM YYYY')}) %>
|
<%- i18n('str', 'created-on', {date: formatDbDate(created_on, 'Do MMMM YYYY')}) %>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="text-monospace"><%- forward_ip %>:<%- forward_port %></div>
|
<%- i18n('access-lists', 'item-count', {count: item_count}) %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div><%- ssl_enabled && ssl_provider ? i18n('ssl', ssl_provider) : i18n('ssl', 'none') %></div>
|
<%- i18n('access-lists', 'proxy-host-count', {count: proxy_host_count}) %>
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div><%- access_list_id ? access_list.name : i18n('str', 'public') %></div>
|
|
||||||
</td>
|
</td>
|
||||||
<% if (canManage) { %>
|
<% if (canManage) { %>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@ -31,10 +23,9 @@
|
|||||||
<a href="#" data-toggle="dropdown" class="icon"><i class="fe fe-more-vertical"></i></a>
|
<a href="#" data-toggle="dropdown" class="icon"><i class="fe fe-more-vertical"></i></a>
|
||||||
<div class="dropdown-menu dropdown-menu-right">
|
<div class="dropdown-menu dropdown-menu-right">
|
||||||
<a href="#" class="edit dropdown-item"><i class="dropdown-icon fe fe-edit"></i> <%- i18n('str', 'edit') %></a>
|
<a href="#" class="edit dropdown-item"><i class="dropdown-icon fe fe-edit"></i> <%- i18n('str', 'edit') %></a>
|
||||||
<a href="#" class="logs dropdown-item"><i class="dropdown-icon fe fe-book"></i> <%- i18n('str', 'logs') %></a>
|
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<a href="#" class="delete dropdown-item"><i class="dropdown-icon fe fe-trash-2"></i> <%- i18n('str', 'delete') %></a>
|
<a href="#" class="delete dropdown-item"><i class="dropdown-icon fe fe-trash-2"></i> <%- i18n('str', 'delete') %></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
@ -16,17 +16,17 @@ module.exports = Mn.View.extend({
|
|||||||
events: {
|
events: {
|
||||||
'click @ui.edit': function (e) {
|
'click @ui.edit': function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
App.Controller.showNginxProxyForm(this.model);
|
App.Controller.showNginxAccessListForm(this.model);
|
||||||
},
|
},
|
||||||
|
|
||||||
'click @ui.delete': function (e) {
|
'click @ui.delete': function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
App.Controller.showNginxProxyDeleteConfirm(this.model);
|
App.Controller.showNginxAccessListDeleteConfirm(this.model);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
templateContext: {
|
templateContext: {
|
||||||
canManage: App.Cache.User.canManage('proxy_hosts')
|
canManage: App.Cache.User.canManage('access_lists')
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<th width="30"> </th>
|
<th width="30"> </th>
|
||||||
<th><%- i18n('str', 'source') %></th>
|
<th><%- i18n('str', 'name') %></th>
|
||||||
<th><%- i18n('str', 'destination') %></th>
|
<th><%- i18n('users', 'title') %></th>
|
||||||
<th><%- i18n('str', 'ssl') %></th>
|
<th><%- i18n('proxy-hosts', 'title') %></th>
|
||||||
<th><%- i18n('str', 'access') %></th>
|
|
||||||
<% if (canManage) { %>
|
<% if (canManage) { %>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
@ -42,7 +42,7 @@ module.exports = Mn.View.extend({
|
|||||||
onRender: function () {
|
onRender: function () {
|
||||||
let view = this;
|
let view = this;
|
||||||
|
|
||||||
App.Api.Nginx.AccessLists.getAll(['owner'])
|
App.Api.Nginx.AccessLists.getAll(['owner', 'items'])
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!view.isDestroyed()) {
|
if (!view.isDestroyed()) {
|
||||||
if (response && response.length) {
|
if (response && response.length) {
|
||||||
|
@ -16,4 +16,4 @@
|
|||||||
<!-- Footer View -->
|
<!-- Footer View -->
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<div class="modal fade" id="modal-dialog" tabindex="-1" role="dialog" aria-hidden="true"></div>
|
<div class="modal fade" id="modal-dialog" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false"></div>
|
||||||
|
@ -155,7 +155,9 @@
|
|||||||
"delete-confirm": "Are you sure you want to delete this access list? Any hosts using it will need to be updated later.",
|
"delete-confirm": "Are you sure you want to delete this access list? Any hosts using it will need to be updated later.",
|
||||||
"public": "Publicly Accessible",
|
"public": "Publicly Accessible",
|
||||||
"help-title": "What is an Access List?",
|
"help-title": "What is an Access List?",
|
||||||
"help-content": "Access Lists provide authentication for the Proxy Hosts via Basic HTTP Authentication.\nYou can configure multiple usernames and passwords for a single Access List and then apply that to a Proxy Host.\nThis is most useful for forwarded web services that do not have authentication mechanisms built in."
|
"help-content": "Access Lists provide authentication for the Proxy Hosts via Basic HTTP Authentication.\nYou can configure multiple usernames and passwords for a single Access List and then apply that to a Proxy Host.\nThis is most useful for forwarded web services that do not have authentication mechanisms built in.",
|
||||||
|
"item-count": "{count} {count, select, 1{User} other{Users}}",
|
||||||
|
"proxy-host-count": "{count} {count, select, 1{Proxy Host} other{Proxy Hosts}}"
|
||||||
},
|
},
|
||||||
"users": {
|
"users": {
|
||||||
"title": "Users",
|
"title": "Users",
|
||||||
|
Loading…
Reference in New Issue
Block a user