mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
feat: Add IP whitelist API and configuration support
This commit is contained in:
34
Common/Server/API/IPWhitelistAPI.ts
Normal file
34
Common/Server/API/IPWhitelistAPI.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import Express, {
|
||||
ExpressRequest,
|
||||
ExpressResponse,
|
||||
ExpressRouter,
|
||||
} from "../Utils/Express";
|
||||
import Response from "../Utils/Response";
|
||||
import { IpWhitelist } from "../EnvironmentConfig";
|
||||
|
||||
export default class IPWhitelistAPI {
|
||||
public static init(): ExpressRouter {
|
||||
const router: ExpressRouter = Express.getRouter();
|
||||
|
||||
router.get(
|
||||
"/ip-whitelist",
|
||||
(req: ExpressRequest, res: ExpressResponse) => {
|
||||
const ipList: Array<string> = IpWhitelist
|
||||
? IpWhitelist.split(",")
|
||||
.map((ip: string) => {
|
||||
return ip.trim();
|
||||
})
|
||||
.filter((ip: string) => {
|
||||
return ip.length > 0;
|
||||
})
|
||||
: [];
|
||||
|
||||
Response.sendJsonObjectResponse(req, res, {
|
||||
ipWhitelist: ipList,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
return router;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import Express, { ExpressApplication } from "../Utils/Express";
|
||||
import StatusAPI, { StatusAPIOptions } from "./StatusAPI";
|
||||
import IPWhitelistAPI from "./IPWhitelistAPI";
|
||||
import version from "./VersionAPI";
|
||||
|
||||
const app: ExpressApplication = Express.getExpressApp();
|
||||
@@ -14,6 +15,7 @@ type InitFunction = (data: InitOptions) => void;
|
||||
const init: InitFunction = (data: InitOptions): void => {
|
||||
app.use([`/${data.appName}`, "/"], version);
|
||||
app.use([`/${data.appName}`, "/"], StatusAPI.init(data.statusOptions));
|
||||
app.use([`/${data.appName}`, "/"], IPWhitelistAPI.init());
|
||||
};
|
||||
|
||||
export default init;
|
||||
|
||||
@@ -397,6 +397,8 @@ export const DocsClientUrl: URL = new URL(
|
||||
new Route(DocsRoute.toString()),
|
||||
);
|
||||
|
||||
export const IpWhitelist: string = process.env["IP_WHITELIST"] || "";
|
||||
|
||||
export const DisableTelemetry: boolean =
|
||||
process.env["DISABLE_TELEMETRY"] === "true";
|
||||
|
||||
|
||||
@@ -121,6 +121,8 @@ Usage:
|
||||
value: {{ $.Values.home.ports.http | squote }}
|
||||
- name: WORKER_PORT
|
||||
value: {{ $.Values.worker.ports.http | squote }}
|
||||
- name: IP_WHITELIST
|
||||
value: {{ default "" $.Values.ipWhitelist | quote }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
|
||||
@@ -41,6 +41,10 @@
|
||||
"encryptionSecret": {
|
||||
"type": ["string", "null"]
|
||||
},
|
||||
"ipWhitelist": {
|
||||
"type": ["string", "null"],
|
||||
"description": "Comma-separated list of probe egress IP addresses for firewall whitelisting. Returned via the /ip-whitelist API endpoint."
|
||||
},
|
||||
"externalSecrets": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -35,6 +35,12 @@ oneuptimeSecret:
|
||||
registerProbeKey:
|
||||
encryptionSecret:
|
||||
|
||||
# Comma-separated list of egress IP addresses that probes use for monitoring checks.
|
||||
# Customers can use this to whitelist probe traffic in their firewalls.
|
||||
# This is returned as a JSON array via the /ip-whitelist API endpoint.
|
||||
# Example: "203.0.113.1,203.0.113.2,198.51.100.10"
|
||||
ipWhitelist:
|
||||
|
||||
# External Secrets
|
||||
# You need to leave blank oneuptimeSecret and encryptionSecret to use this section
|
||||
externalSecrets:
|
||||
|
||||
Reference in New Issue
Block a user