diff --git a/backend/internal/access-list.js b/backend/internal/access-list.js index 0f62c734..20c8617a 100644 --- a/backend/internal/access-list.js +++ b/backend/internal/access-list.js @@ -30,6 +30,7 @@ const internalAccessList = { .omit(omissions()) .insertAndFetch({ name: data.name, + satify_any: data.satify_any, owner_user_id: access.token.getUserId(1) }); }) @@ -125,7 +126,8 @@ const internalAccessList = { .query() .where({id: data.id}) .patch({ - name: data.name + name: data.name, + satify_any: data.satify_any, }); } }) @@ -478,10 +480,12 @@ const internalAccessList = { return new Promise((resolve, reject) => { let htpasswd_file = internalAccessList.getFilename(list); + let nginx_file = internalAccessList.getFilename(list) + '.conf'; // 1. remove any existing access file try { fs.unlinkSync(htpasswd_file); + fs.unlinkSync(nginx_file); } catch (err) { // do nothing } diff --git a/backend/migrations/20200410143839_access_list_client.js b/backend/migrations/20200410143839_access_list_client.js index 2432d773..3511e35b 100644 --- a/backend/migrations/20200410143839_access_list_client.js +++ b/backend/migrations/20200410143839_access_list_client.js @@ -26,6 +26,13 @@ exports.up = function (knex/*, Promise*/) { }) .then(function () { logger.info('[' + migrate_name + '] access_list_client Table created'); + + return knex.schema.table('access_list', function (access_list) { + access_list.integer('satify_any').notNull().defaultTo(0); + }); + }) + .then(() => { + logger.info('[' + migrate_name + '] access_list Table altered'); }); }; diff --git a/backend/schema/endpoints/access-lists.json b/backend/schema/endpoints/access-lists.json index f2ff254d..18bbf2ae 100644 --- a/backend/schema/endpoints/access-lists.json +++ b/backend/schema/endpoints/access-lists.json @@ -27,6 +27,9 @@ "type": "string", "format": "ipv4" }, + "satify_any": { + "type": "boolean" + }, "meta": { "type": "object" } @@ -86,9 +89,12 @@ "name": { "$ref": "#/definitions/name" }, + "satify_any": { + "$ref": "#/definitions/satify_any" + }, "items": { "type": "array", - "minItems": 1, + "minItems": 0, "items": { "type": "object", "additionalProperties": false, @@ -148,9 +154,12 @@ "name": { "$ref": "#/definitions/name" }, + "satify_any": { + "$ref": "#/definitions/satify_any" + }, "items": { "type": "array", - "minItems": 1, + "minItems": 0, "items": { "type": "object", "additionalProperties": false, diff --git a/frontend/js/app/nginx/access/form.ejs b/frontend/js/app/nginx/access/form.ejs index 9c976b07..40fe8542 100644 --- a/frontend/js/app/nginx/access/form.ejs +++ b/frontend/js/app/nginx/access/form.ejs @@ -21,6 +21,16 @@ + +
+
+ +
+
diff --git a/frontend/js/app/nginx/access/form.js b/frontend/js/app/nginx/access/form.js index c932e86b..fdfbb65d 100644 --- a/frontend/js/app/nginx/access/form.js +++ b/frontend/js/app/nginx/access/form.js @@ -65,17 +65,20 @@ module.exports = Mn.View.extend({ } }); - if (!items_data.length) { - alert('You must specify at least 1 Username and Password combination'); + if (!items_data.length && !clients_data.length) { + alert('You must specify at least 1 Authorization or Access rule'); return; } let data = { - name: form_data.name, - items: items_data, - clients: clients_data + name: form_data.name, + satify_any: !!form_data.satify_any, + items: items_data, + clients: clients_data }; + console.log(data); + let method = App.Api.Nginx.AccessLists.create; let is_new = true; diff --git a/frontend/js/app/nginx/access/list/item.ejs b/frontend/js/app/nginx/access/list/item.ejs index d713259d..2979f508 100644 --- a/frontend/js/app/nginx/access/list/item.ejs +++ b/frontend/js/app/nginx/access/list/item.ejs @@ -17,6 +17,13 @@ <%- i18n('access-lists', 'client-count', {count: clients.length || 0}) %> + + <% if (satify_any) { %> + <%- i18n('str', 'any') %> + <%} else { %> + <%- i18n('str', 'all') %> + <% } %> + <%- i18n('access-lists', 'proxy-host-count', {count: proxy_host_count}) %> diff --git a/frontend/js/app/nginx/access/list/main.ejs b/frontend/js/app/nginx/access/list/main.ejs index 1c3b10d4..7988e0c2 100644 --- a/frontend/js/app/nginx/access/list/main.ejs +++ b/frontend/js/app/nginx/access/list/main.ejs @@ -3,6 +3,7 @@ <%- i18n('str', 'name') %> <%- i18n('access-lists', 'authorization') %> <%- i18n('access-lists', 'access') %> + <%- i18n('access-lists', 'satisfy') %> <%- i18n('proxy-hosts', 'title') %> <% if (canManage) { %>   diff --git a/frontend/js/i18n/messages.json b/frontend/js/i18n/messages.json index ffab7e8b..162357d7 100644 --- a/frontend/js/i18n/messages.json +++ b/frontend/js/i18n/messages.json @@ -33,7 +33,9 @@ "unknown": "Unknown", "expires": "Expires", "value": "Value", - "please-wait": "Please wait..." + "please-wait": "Please wait...", + "all": "All", + "any": "Any" }, "login": { "title": "Login to your account" @@ -191,7 +193,9 @@ "delete-has-hosts": "This Access List is associated with {count} Proxy Hosts. They will become publicly available upon deletion.", "details": "Details", "authorization": "Authorization", - "access": "Access" + "access": "Access", + "satisfy": "Satisfy", + "satisfy-any": "Satify Any" }, "users": { "title": "Users",