mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 04:02:12 +00:00
Merge pull request #2458 from codac/patch-2
This is supposed to make self signed certs work with the calendar module
This commit is contained in:
commit
2e2e157017
@ -20,6 +20,7 @@ _This release is scheduled to be released on 2021-04-01._
|
|||||||
- Respect parameter ColoredSymbolOnly also for custom events
|
- Respect parameter ColoredSymbolOnly also for custom events
|
||||||
- Added a new parameter to hide time portion on relative times
|
- Added a new parameter to hide time portion on relative times
|
||||||
- Added locale to sample config file
|
- Added locale to sample config file
|
||||||
|
- Added support for self-signed certificates for the default calendar module (#466)
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
|
|
||||||
|
@ -58,7 +58,8 @@ Module.register("calendar", {
|
|||||||
excludedEvents: [],
|
excludedEvents: [],
|
||||||
sliceMultiDayEvents: false,
|
sliceMultiDayEvents: false,
|
||||||
broadcastPastEvents: false,
|
broadcastPastEvents: false,
|
||||||
nextDaysRelative: false
|
nextDaysRelative: false,
|
||||||
|
selfSignedCert: false
|
||||||
},
|
},
|
||||||
|
|
||||||
requiresVersion: "2.1.0",
|
requiresVersion: "2.1.0",
|
||||||
@ -101,7 +102,8 @@ Module.register("calendar", {
|
|||||||
var calendarConfig = {
|
var calendarConfig = {
|
||||||
maximumEntries: calendar.maximumEntries,
|
maximumEntries: calendar.maximumEntries,
|
||||||
maximumNumberOfDays: calendar.maximumNumberOfDays,
|
maximumNumberOfDays: calendar.maximumNumberOfDays,
|
||||||
broadcastPastEvents: calendar.broadcastPastEvents
|
broadcastPastEvents: calendar.broadcastPastEvents,
|
||||||
|
selfSignedCert: calendar.selfSignedCert
|
||||||
};
|
};
|
||||||
if (calendar.symbolClass === "undefined" || calendar.symbolClass === null) {
|
if (calendar.symbolClass === "undefined" || calendar.symbolClass === null) {
|
||||||
calendarConfig.symbolClass = "";
|
calendarConfig.symbolClass = "";
|
||||||
@ -606,7 +608,8 @@ Module.register("calendar", {
|
|||||||
titleClass: calendarConfig.titleClass,
|
titleClass: calendarConfig.titleClass,
|
||||||
timeClass: calendarConfig.timeClass,
|
timeClass: calendarConfig.timeClass,
|
||||||
auth: auth,
|
auth: auth,
|
||||||
broadcastPastEvents: calendarConfig.broadcastPastEvents || this.config.broadcastPastEvents
|
broadcastPastEvents: calendarConfig.broadcastPastEvents || this.config.broadcastPastEvents,
|
||||||
|
selfSignedCert: calendarConfig.selfSignedCert || this.config.selfSignedCert
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -25,9 +25,10 @@ const moment = require("moment");
|
|||||||
* @param {number} maximumNumberOfDays The maximum number of days an event should be in the future.
|
* @param {number} maximumNumberOfDays The maximum number of days an event should be in the future.
|
||||||
* @param {object} auth The object containing options for authentication against the calendar.
|
* @param {object} auth The object containing options for authentication against the calendar.
|
||||||
* @param {boolean} includePastEvents If true events from the past maximumNumberOfDays will be fetched too
|
* @param {boolean} includePastEvents If true events from the past maximumNumberOfDays will be fetched too
|
||||||
|
* @param {boolean} selfSignedCert If true, the server certificate is not verified against the list of supplied CAs.
|
||||||
* @class
|
* @class
|
||||||
*/
|
*/
|
||||||
const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, includePastEvents) {
|
const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, includePastEvents, selfSignedCert) {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
let reloadTimer = null;
|
let reloadTimer = null;
|
||||||
@ -51,6 +52,13 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
gzip: true
|
gzip: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (selfSignedCert) {
|
||||||
|
var agentOptions = {
|
||||||
|
rejectUnauthorized: false
|
||||||
|
};
|
||||||
|
opts.agentOptions = agentOptions;
|
||||||
|
}
|
||||||
|
|
||||||
if (auth) {
|
if (auth) {
|
||||||
if (auth.method === "bearer") {
|
if (auth.method === "bearer") {
|
||||||
opts.auth = {
|
opts.auth = {
|
||||||
|
@ -19,7 +19,7 @@ module.exports = NodeHelper.create({
|
|||||||
// Override socketNotificationReceived method.
|
// Override socketNotificationReceived method.
|
||||||
socketNotificationReceived: function (notification, payload) {
|
socketNotificationReceived: function (notification, payload) {
|
||||||
if (notification === "ADD_CALENDAR") {
|
if (notification === "ADD_CALENDAR") {
|
||||||
this.createFetcher(payload.url, payload.fetchInterval, payload.excludedEvents, payload.maximumEntries, payload.maximumNumberOfDays, payload.auth, payload.broadcastPastEvents, payload.id);
|
this.createFetcher(payload.url, payload.fetchInterval, payload.excludedEvents, payload.maximumEntries, payload.maximumNumberOfDays, payload.auth, payload.broadcastPastEvents, payload.selfSignedCert, payload.id);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -34,9 +34,10 @@ module.exports = NodeHelper.create({
|
|||||||
* @param {number} maximumNumberOfDays The maximum number of days an event should be in the future.
|
* @param {number} maximumNumberOfDays The maximum number of days an event should be in the future.
|
||||||
* @param {object} auth The object containing options for authentication against the calendar.
|
* @param {object} auth The object containing options for authentication against the calendar.
|
||||||
* @param {boolean} broadcastPastEvents If true events from the past maximumNumberOfDays will be included in event broadcasts
|
* @param {boolean} broadcastPastEvents If true events from the past maximumNumberOfDays will be included in event broadcasts
|
||||||
|
* @param {boolean} selfSignedCert If true, the server certificate is not verified against the list of supplied CAs.
|
||||||
* @param {string} identifier ID of the module
|
* @param {string} identifier ID of the module
|
||||||
*/
|
*/
|
||||||
createFetcher: function (url, fetchInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, broadcastPastEvents, identifier) {
|
createFetcher: function (url, fetchInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, broadcastPastEvents, selfSignedCert, identifier) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (!validUrl.isUri(url)) {
|
if (!validUrl.isUri(url)) {
|
||||||
@ -47,7 +48,7 @@ module.exports = NodeHelper.create({
|
|||||||
var fetcher;
|
var fetcher;
|
||||||
if (typeof self.fetchers[identifier + url] === "undefined") {
|
if (typeof self.fetchers[identifier + url] === "undefined") {
|
||||||
Log.log("Create new calendar fetcher for url: " + url + " - Interval: " + fetchInterval);
|
Log.log("Create new calendar fetcher for url: " + url + " - Interval: " + fetchInterval);
|
||||||
fetcher = new CalendarFetcher(url, fetchInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, broadcastPastEvents);
|
fetcher = new CalendarFetcher(url, fetchInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth, broadcastPastEvents, selfSignedCert);
|
||||||
|
|
||||||
fetcher.onReceive(function (fetcher) {
|
fetcher.onReceive(function (fetcher) {
|
||||||
self.sendSocketNotification("CALENDAR_EVENTS", {
|
self.sendSocketNotification("CALENDAR_EVENTS", {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user