Skip to content

Commit 0f238a5

Browse files
committed
add satisfy configuration to the ui
1 parent 8d432bd commit 0f238a5

File tree

8 files changed

+55
-10
lines changed

8 files changed

+55
-10
lines changed

backend/internal/access-list.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const internalAccessList = {
3030
.omit(omissions())
3131
.insertAndFetch({
3232
name: data.name,
33+
satify_any: data.satify_any,
3334
owner_user_id: access.token.getUserId(1)
3435
});
3536
})
@@ -125,7 +126,8 @@ const internalAccessList = {
125126
.query()
126127
.where({id: data.id})
127128
.patch({
128-
name: data.name
129+
name: data.name,
130+
satify_any: data.satify_any,
129131
});
130132
}
131133
})
@@ -478,10 +480,12 @@ const internalAccessList = {
478480

479481
return new Promise((resolve, reject) => {
480482
let htpasswd_file = internalAccessList.getFilename(list);
483+
let nginx_file = internalAccessList.getFilename(list) + '.conf';
481484

482485
// 1. remove any existing access file
483486
try {
484487
fs.unlinkSync(htpasswd_file);
488+
fs.unlinkSync(nginx_file);
485489
} catch (err) {
486490
// do nothing
487491
}

backend/migrations/20200410143839_access_list_client.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ exports.up = function (knex/*, Promise*/) {
2626
})
2727
.then(function () {
2828
logger.info('[' + migrate_name + '] access_list_client Table created');
29+
30+
return knex.schema.table('access_list', function (access_list) {
31+
access_list.integer('satify_any').notNull().defaultTo(0);
32+
});
33+
})
34+
.then(() => {
35+
logger.info('[' + migrate_name + '] access_list Table altered');
2936
});
3037
};
3138

backend/schema/endpoints/access-lists.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
"type": "string",
2828
"format": "ipv4"
2929
},
30+
"satify_any": {
31+
"type": "boolean"
32+
},
3033
"meta": {
3134
"type": "object"
3235
}
@@ -86,9 +89,12 @@
8689
"name": {
8790
"$ref": "#/definitions/name"
8891
},
92+
"satify_any": {
93+
"$ref": "#/definitions/satify_any"
94+
},
8995
"items": {
9096
"type": "array",
91-
"minItems": 1,
97+
"minItems": 0,
9298
"items": {
9399
"type": "object",
94100
"additionalProperties": false,
@@ -148,9 +154,12 @@
148154
"name": {
149155
"$ref": "#/definitions/name"
150156
},
157+
"satify_any": {
158+
"$ref": "#/definitions/satify_any"
159+
},
151160
"items": {
152161
"type": "array",
153-
"minItems": 1,
162+
"minItems": 0,
154163
"items": {
155164
"type": "object",
156165
"additionalProperties": false,

frontend/js/app/nginx/access/form.ejs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@
2121
<input type="text" name="name" class="form-control" value="<%- name %>" required>
2222
</div>
2323
</div>
24+
25+
<div class="col-sm-6 col-md-6">
26+
<div class="form-group">
27+
<label class="custom-switch">
28+
<input type="checkbox" class="custom-switch-input" name="satify_any" value="1"<%- typeof satify_any !== 'undefined' && satify_any ? ' checked' : '' %>>
29+
<span class="custom-switch-indicator"></span>
30+
<span class="custom-switch-description"><%- i18n('access-lists', 'satisfy-any') %></span>
31+
</label>
32+
</div>
33+
</div>
2434
</div>
2535
</div>
2636

frontend/js/app/nginx/access/form.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,20 @@ module.exports = Mn.View.extend({
6565
}
6666
});
6767

68-
if (!items_data.length) {
69-
alert('You must specify at least 1 Username and Password combination');
68+
if (!items_data.length && !clients_data.length) {
69+
alert('You must specify at least 1 Authorization or Access rule');
7070
return;
7171
}
7272

7373
let data = {
74-
name: form_data.name,
75-
items: items_data,
76-
clients: clients_data
74+
name: form_data.name,
75+
satify_any: !!form_data.satify_any,
76+
items: items_data,
77+
clients: clients_data
7778
};
7879

80+
console.log(data);
81+
7982
let method = App.Api.Nginx.AccessLists.create;
8083
let is_new = true;
8184

frontend/js/app/nginx/access/list/item.ejs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
<td>
1818
<%- i18n('access-lists', 'client-count', {count: clients.length || 0}) %>
1919
</td>
20+
<td>
21+
<% if (satify_any) { %>
22+
<%- i18n('str', 'any') %>
23+
<%} else { %>
24+
<%- i18n('str', 'all') %>
25+
<% } %>
26+
</td>
2027
<td>
2128
<%- i18n('access-lists', 'proxy-host-count', {count: proxy_host_count}) %>
2229
</td>

frontend/js/app/nginx/access/list/main.ejs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<th><%- i18n('str', 'name') %></th>
44
<th><%- i18n('access-lists', 'authorization') %></th>
55
<th><%- i18n('access-lists', 'access') %></th>
6+
<th><%- i18n('access-lists', 'satisfy') %></th>
67
<th><%- i18n('proxy-hosts', 'title') %></th>
78
<% if (canManage) { %>
89
<th>&nbsp;</th>

frontend/js/i18n/messages.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
"unknown": "Unknown",
3434
"expires": "Expires",
3535
"value": "Value",
36-
"please-wait": "Please wait..."
36+
"please-wait": "Please wait...",
37+
"all": "All",
38+
"any": "Any"
3739
},
3840
"login": {
3941
"title": "Login to your account"
@@ -191,7 +193,9 @@
191193
"delete-has-hosts": "This Access List is associated with {count} Proxy Hosts. They will become publicly available upon deletion.",
192194
"details": "Details",
193195
"authorization": "Authorization",
194-
"access": "Access"
196+
"access": "Access",
197+
"satisfy": "Satisfy",
198+
"satisfy-any": "Satify Any"
195199
},
196200
"users": {
197201
"title": "Users",

0 commit comments

Comments
 (0)