Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions backend/internal/access-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const internalAccessList = {
await accessListClientModel.query().insert({
access_list_id: row.id,
address: client.address,
note: client.note || null,
directive: client.directive,
});
}
Expand Down Expand Up @@ -159,6 +160,7 @@ const internalAccessList = {
await accessListClientModel.query().insert({
access_list_id: data.id,
address: client.address,
note: client.note || null,
directive: client.directive,
});
}
Expand Down
9 changes: 8 additions & 1 deletion backend/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,20 @@ const getRenderEngine = () => {
});

/**
* nginxAccessRule expects the object given to have 2 properties:
* nginxAccessRule expects the object given to have 3 properties:
*
* directive string
* address string
* note string
*/
renderEngine.registerFilter("nginxAccessRule", (v) => {
if (typeof v.directive !== "undefined" && typeof v.address !== "undefined" && v.directive && v.address) {
const note = typeof v.note === "string" ? v.note.trim() : "";
if (note) {
// prevent newline / comment-breaking characters
const safe = note.replace(/[\r\n#;]/g, " ").trim();
return `${v.directive} ${v.address}; # ${safe}`;
}
return `${v.directive} ${v.address};`;
}
return "";
Expand Down
36 changes: 36 additions & 0 deletions backend/migrations/20260220111310_access_list_client_note.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { migrate as logger } from "../logger.js";

const migrateName = "access_list_client_note";

/**
* Migrate
*
* @see http://knexjs.org/#Schema
*
* @param {Object} knex
* @returns {Promise}
*/
const up = (knex) => {
logger.info(`[${migrateName}] Migrating Up...`);

return knex.schema
.table("access_list_client", (access_list) => {
access_list.string("note", 200).nullable();
})
.then(() => {
logger.info(`[${migrateName}] access_list_client Table altered`);
});
};

/**
* Undo Migrate
*
* @param {Object} knex
* @returns {Promise}
*/
const down = (_knex) => {
logger.warn(`[${migrateName}] You can't migrate down this one.`);
return Promise.resolve(true);
};

export { up, down };
15 changes: 13 additions & 2 deletions backend/schema/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@
],
"example": "192.168.0.11"
},
"note": {
"description": "Note",
"type": "string",
"example": "Home",
"maxLength": 200
},
"access_items": {
"type": "array",
"items": {
Expand Down Expand Up @@ -191,19 +197,24 @@
"address": {
"$ref": "#/properties/address"
},
"note": {
"$ref": "#/properties/note"
},
"directive": {
"$ref": "#/properties/directive"
}
},
"example": {
"directive": "allow",
"address": "192.168.0.0/24"
"address": "192.168.0.0/24",
"note": "Home"
}
},
"example": [
{
"directive": "allow",
"address": "192.168.0.0/24"
"address": "192.168.0.0/24",
"note": "Home"
}
]
},
Expand Down
3 changes: 2 additions & 1 deletion backend/schema/paths/nginx/access-lists/listID/put.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"clients": [
{
"directive": "allow",
"address": "192.168.0.0/24"
"address": "192.168.0.0/24",
"note": "note"
}
]
}
Expand Down
4 changes: 3 additions & 1 deletion backend/schema/paths/nginx/access-lists/post.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"clients": [
{
"directive": "allow",
"address": "192.168.0.0/24"
"address": "192.168.0.0/24",
"note": "note"
}
]
}
Expand Down Expand Up @@ -118,6 +119,7 @@
"modified_on": "2024-10-08T22:15:40.000Z",
"access_list_id": 1,
"address": "127.0.0.1",
"note": "note",
"directive": "allow",
"meta": {}
}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/api/backend/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export type AccessListClient = {
modifiedOn?: string;
accessListId?: number;
address: string;
note?: string;
directive: "allow" | "deny";
meta?: Record<string, any>;
};
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/components/Form/AccessClientFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ export function AccessClientFields({ initialValues, name = "clients" }: Props) {
onChange={(e) => handleChange(idx, "address", e.target.value)}
placeholder={intl.formatMessage({ id: "access-list.rule-source.placeholder" })}
/>
<input
name={`clients[${idx}].note`}
type="text"
maxLength={200}
className="form-control"
autoComplete="off"
value={client.note ?? ""}
onChange={(e) => handleChange(idx, "note", e.target.value)}
placeholder={intl.formatMessage({ id: "access-list.rule-source.placeholder-note" })}
/>
</div>
</div>
<div className="col-1">
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 или 192.168.1.0/24 или 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "Напр. „Дом“ или „Офис“"
},
"access-list.satisfy-any": {
"defaultMessage": "Удовлетворяване на което и да е"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 nebo 192.168.1.0/24 nebo 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "Např. „Domov“ nebo „Kancelář“"
},
"access-list.satisfy-any": {
"defaultMessage": "Splnit kterékoliv"
},
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/locale/src/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
"access-list.public.subtitle": {
"defaultMessage": "Keine Authentifizierung erforderlich"
},
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 oder 192.168.1.0/24 oder 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "Z. B. „Zuhause“ oder „Büro“"
},
"access-list.satisfy-any": {
"defaultMessage": "Satisfy Any"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 or 192.168.1.0/24 or 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "E.g. \"Home\" or \"Office\""
},
"access-list.satisfy-any": {
"defaultMessage": "Satisfy Any"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 o 192.168.1.0/24 o 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "P. ej., «Casa» u «Oficina»"
},
"access-list.satisfy-any": {
"defaultMessage": "Satisfacer Cualquiera"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 ou 192.168.1.0/24 ou 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "Par ex. « Domicile » ou « Bureau »"
},
"access-list.satisfy-any": {
"defaultMessage": "Valide n'importe quelle règle"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/ga.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 nó 192.168.1.0/24 nó 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "M.sh. \"Baile\" nó \"Oifig\""
},
"access-list.satisfy-any": {
"defaultMessage": "Sásaigh Aon"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 vagy 192.168.1.0/24 vagy 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "Pl. „Otthon” vagy „Iroda”"
},
"access-list.satisfy-any": {
"defaultMessage": "Bármely teljesítése"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 atau 192.168.1.0/24 atau 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "Mis. \"Rumah\" atau \"Kantor\""
},
"access-list.satisfy-any": {
"defaultMessage": "Penuhi Salah Satu"
},
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/locale/src/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
"access-list.public.subtitle": {
"defaultMessage": "Nessuna autenticazione base richiesta"
},
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 o 192.168.1.0/24 o 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "Es. \"Casa\" o \"Ufficio\""
},
"access-list.satisfy-any": {
"defaultMessage": "Soddisfa Qualsiasi"
},
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/locale/src/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
"access-list.public.subtitle": {
"defaultMessage": "ベーシック認証を使用しません"
},
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 または 192.168.1.0/24 または 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "例:「自宅」や「オフィス」"
},
"access-list.satisfy-any": {
"defaultMessage": "いずれかを満たす"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 / 192.168.1.0/24 / IPv6"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "예: \"집\" 또는 \"사무실\""
},
"access-list.satisfy-any": {
"defaultMessage": "조건 중 하나라도 충족"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 of 192.168.1.0/24 of 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "Bijv. \"Thuis\" of \"Kantoor\""
},
"access-list.satisfy-any": {
"defaultMessage": "Voldoe aan elke"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/no.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 eller 192.168.1.0/24 eller 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "F.eks. \"Hjem\" eller \"Kontor\""
},
"access-list.satisfy-any": {
"defaultMessage": "Oppfyll en av kravene"
},
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/locale/src/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
"access-list.public.subtitle": {
"defaultMessage": "Nie wymaga uwierzytelnienia podstawowego"
},
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 lub 192.168.1.0/24 lub 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "Np. „Dom” lub „Biuro”"
},
"access-list.satisfy-any": {
"defaultMessage": "Spełnij dowolny warunek"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 ou 192.168.1.0/24 ou 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "Por ex., \"Casa\" ou \"Escritório\""
},
"access-list.satisfy-any": {
"defaultMessage": "Satisfazer Qualquer"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 или 192.168.1.0/24 или 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "Напр. «Дом» или «Офис»"
},
"access-list.satisfy-any": {
"defaultMessage": "Любое совпадение"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 alebo 192.168.1.0/24 alebo 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "Napr. „Domov“ alebo „Kancelária“"
},
"access-list.satisfy-any": {
"defaultMessage": "Splniť ktorékoľvek"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 veya 192.168.1.0/24 veya 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "Örn. \"Ev\" veya \"Ofis\""
},
"access-list.satisfy-any": {
"defaultMessage": "Herhangi Birini Karşıla"
},
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/locale/src/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
"access-list.public.subtitle": {
"defaultMessage": "Không cần xác thực cơ bản"
},
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 hoặc 192.168.1.0/24 hoặc 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "Ví dụ: \"Nhà\" hoặc \"Văn phòng\""
},
"access-list.satisfy-any": {
"defaultMessage": "Thỏa mãn điều kiện bất kỳ"
},
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/locale/src/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
"access-list.public.subtitle": {
"defaultMessage": "无需基本认证"
},
"access-list.rule-source.placeholder": {
"defaultMessage": "192.168.1.100 或 192.168.1.0/24 或 2001:0db8::/32"
},
"access-list.rule-source.placeholder-note": {
"defaultMessage": "例如:“家庭”或“办公室”"
},
"access-list.satisfy-any": {
"defaultMessage": "满足任意条件"
},
Expand Down
Loading