|
|
@ -6,7 +6,7 @@ const { log, UP, DOWN, PENDING, MAINTENANCE, flipStatus, TimeLogger, MAX_INTERVA
|
|
|
|
SQL_DATETIME_FORMAT
|
|
|
|
SQL_DATETIME_FORMAT
|
|
|
|
} = require("../../src/util");
|
|
|
|
} = require("../../src/util");
|
|
|
|
const { tcping, ping, dnsResolve, checkCertificate, checkStatusCode, getTotalClientInRoom, setting, mssqlQuery, postgresQuery, mysqlQuery, mqttAsync, setSetting, httpNtlm, radius, grpcQuery,
|
|
|
|
const { tcping, ping, dnsResolve, checkCertificate, checkStatusCode, getTotalClientInRoom, setting, mssqlQuery, postgresQuery, mysqlQuery, mqttAsync, setSetting, httpNtlm, radius, grpcQuery,
|
|
|
|
redisPingAsync, mongodbPing, kafkaProducerAsync
|
|
|
|
redisPingAsync, mongodbPing, kafkaProducerAsync, getOidcTokenClientCredentials,
|
|
|
|
} = require("../util-server");
|
|
|
|
} = require("../util-server");
|
|
|
|
const { R } = require("redbean-node");
|
|
|
|
const { R } = require("redbean-node");
|
|
|
|
const { BeanModel } = require("redbean-node/dist/bean-model");
|
|
|
|
const { BeanModel } = require("redbean-node/dist/bean-model");
|
|
|
@ -154,6 +154,11 @@ class Monitor extends BeanModel {
|
|
|
|
grpcMetadata: this.grpcMetadata,
|
|
|
|
grpcMetadata: this.grpcMetadata,
|
|
|
|
basic_auth_user: this.basic_auth_user,
|
|
|
|
basic_auth_user: this.basic_auth_user,
|
|
|
|
basic_auth_pass: this.basic_auth_pass,
|
|
|
|
basic_auth_pass: this.basic_auth_pass,
|
|
|
|
|
|
|
|
oauth_client_id: this.oauth_client_id,
|
|
|
|
|
|
|
|
oauth_client_secret: this.oauth_client_secret,
|
|
|
|
|
|
|
|
oauth_token_url: this.oauth_token_url,
|
|
|
|
|
|
|
|
oauth_scopes: this.oauth_scopes,
|
|
|
|
|
|
|
|
oauth_auth_method: this.oauth_auth_method,
|
|
|
|
pushToken: this.pushToken,
|
|
|
|
pushToken: this.pushToken,
|
|
|
|
databaseConnectionString: this.databaseConnectionString,
|
|
|
|
databaseConnectionString: this.databaseConnectionString,
|
|
|
|
radiusUsername: this.radiusUsername,
|
|
|
|
radiusUsername: this.radiusUsername,
|
|
|
@ -374,6 +379,24 @@ class Monitor extends BeanModel {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// OIDC: Basic client credential flow.
|
|
|
|
|
|
|
|
// Additional grants might be implemented in the future
|
|
|
|
|
|
|
|
let oauth2AuthHeader = {};
|
|
|
|
|
|
|
|
if (this.auth_method === "oauth2-cc") {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (this.oauthAccessToken === undefined || new Date(this.oauthAccessToken.expires_at * 1000) <= new Date()) {
|
|
|
|
|
|
|
|
log.debug("monitor", `[${this.name}] The oauth access-token undefined or expired. Requesting a new one`);
|
|
|
|
|
|
|
|
this.oauthAccessToken = await getOidcTokenClientCredentials(this.oauth_token_url, this.oauth_client_id, this.oauth_client_secret, this.oauth_scopes, this.oauth_auth_method);
|
|
|
|
|
|
|
|
log.debug("monitor", `[${this.name}] Obtained oauth access-token. Expires at ${new Date(this.oauthAccessToken.expires_at * 1000)}`);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
oauth2AuthHeader = {
|
|
|
|
|
|
|
|
"Authorization": this.oauthAccessToken.token_type + " " + this.oauthAccessToken.access_token,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
throw new Error("The oauth config is invalid. " + e.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const httpsAgentOptions = {
|
|
|
|
const httpsAgentOptions = {
|
|
|
|
maxCachedSessions: 0, // Use Custom agent to disable session reuse (https://github.com/nodejs/node/issues/3940)
|
|
|
|
maxCachedSessions: 0, // Use Custom agent to disable session reuse (https://github.com/nodejs/node/issues/3940)
|
|
|
|
rejectUnauthorized: !this.getIgnoreTls(),
|
|
|
|
rejectUnauthorized: !this.getIgnoreTls(),
|
|
|
@ -408,6 +431,7 @@ class Monitor extends BeanModel {
|
|
|
|
"User-Agent": "Uptime-Kuma/" + version,
|
|
|
|
"User-Agent": "Uptime-Kuma/" + version,
|
|
|
|
...(contentType ? { "Content-Type": contentType } : {}),
|
|
|
|
...(contentType ? { "Content-Type": contentType } : {}),
|
|
|
|
...(basicAuthHeader),
|
|
|
|
...(basicAuthHeader),
|
|
|
|
|
|
|
|
...(oauth2AuthHeader),
|
|
|
|
...(this.headers ? JSON.parse(this.headers) : {})
|
|
|
|
...(this.headers ? JSON.parse(this.headers) : {})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
maxRedirects: this.maxredirects,
|
|
|
|
maxRedirects: this.maxredirects,
|
|
|
|