mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 03:39:55 +00:00
Merge pull request #457 from Jopyth/patch-limited-access
Patch limited access
This commit is contained in:
commit
501c89ae3a
@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Method to overwrite the module's header. [See documentation.](https://github.com/MichMich/MagicMirror/tree/develop/modules#getheader)
|
- Method to overwrite the module's header. [See documentation.](https://github.com/MichMich/MagicMirror/tree/develop/modules#getheader)
|
||||||
|
- Option to limit access to certain IP addresses based on the value of `ipWhitelist` in the `config.js`, default is access from localhost only (Issue [#456](https://github.com/MichMich/MagicMirror/issues/456))
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
- Modified translations for Frysk.
|
- Modified translations for Frysk.
|
||||||
|
@ -77,6 +77,8 @@ The following properties can be configured:
|
|||||||
| **Option** | **Description** |
|
| **Option** | **Description** |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `port` | The port on which the MagicMirror² server will run on. The default value is `8080`. |
|
| `port` | The port on which the MagicMirror² server will run on. The default value is `8080`. |
|
||||||
|
| `ipWhitelist` | The list of IPs from which you are allowed to access the MagicMirror². The default value is `["127.0.0.1", "::ffff:127.0.0.1"]`.It is possible to specify IPs with subnet masks (`["127.0.0.1", "127.0.0.1/24"]`) or define ip ranges (`["127.0.0.1", ["192.168.0.1", "192.168.0.100"]]`).
|
||||||
|
|
|
||||||
| `kioskmode` | This allows MagicMirror² to run in Kiosk Mode. It protects from other programs popping on top of your screen. The default value is `false`|
|
| `kioskmode` | This allows MagicMirror² to run in Kiosk Mode. It protects from other programs popping on top of your screen. The default value is `false`|
|
||||||
| `language` | The language of the interface. (Note: Not all elements will be localized.) Possible values are `en`, `nl`, `ru`, `fr`, etc., but the default value is `en`. |
|
| `language` | The language of the interface. (Note: Not all elements will be localized.) Possible values are `en`, `nl`, `ru`, `fr`, etc., but the default value is `en`. |
|
||||||
| `timeFormat` | The form of time notation that will be used. Possible values are `12` or `24`. The default is `24`. |
|
| `timeFormat` | The form of time notation that will be used. Possible values are `12` or `24`. The default is `24`. |
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
port: 8080,
|
port: 8080,
|
||||||
|
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1"],
|
||||||
|
|
||||||
language: 'en',
|
language: 'en',
|
||||||
timeFormat: 24,
|
timeFormat: 24,
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
var defaults = {
|
var defaults = {
|
||||||
port: 8080,
|
port: 8080,
|
||||||
kioskmode: false,
|
kioskmode: false,
|
||||||
|
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1"],
|
||||||
|
|
||||||
language: "en",
|
language: "en",
|
||||||
timeFormat: 24,
|
timeFormat: 24,
|
||||||
|
12
js/server.js
12
js/server.js
@ -10,11 +10,23 @@ var app = require("express")();
|
|||||||
var server = require("http").Server(app);
|
var server = require("http").Server(app);
|
||||||
var io = require("socket.io")(server);
|
var io = require("socket.io")(server);
|
||||||
var path = require("path");
|
var path = require("path");
|
||||||
|
var ipfilter = require("express-ipfilter").IpFilter;
|
||||||
|
|
||||||
var Server = function(config, callback) {
|
var Server = function(config, callback) {
|
||||||
console.log("Starting server op port " + config.port + " ... ");
|
console.log("Starting server op port " + config.port + " ... ");
|
||||||
|
|
||||||
server.listen(config.port);
|
server.listen(config.port);
|
||||||
|
|
||||||
|
app.use(function(req, res, next) {
|
||||||
|
var result = ipfilter(config.ipWhitelist, {mode: "allow", log: false})(req, res, function(err) {
|
||||||
|
if (err === undefined) {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
console.log(err.message);
|
||||||
|
res.status(403).send("This device is not allowed to access your mirror. <br> Please check your config.js or config.js.sample to change this.");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
app.use("/js", express.static(__dirname));
|
app.use("/js", express.static(__dirname));
|
||||||
app.use("/config", express.static(path.resolve(__dirname + "/../config")));
|
app.use("/config", express.static(path.resolve(__dirname + "/../config")));
|
||||||
app.use("/css", express.static(path.resolve(__dirname + "/../css")));
|
app.use("/css", express.static(path.resolve(__dirname + "/../css")));
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"electron-prebuilt": "^0.37.2",
|
"electron-prebuilt": "^0.37.2",
|
||||||
"express": "^4.14.0",
|
"express": "^4.14.0",
|
||||||
|
"express-ipfilter": "latest",
|
||||||
"feedme": "latest",
|
"feedme": "latest",
|
||||||
"iconv-lite": "latest",
|
"iconv-lite": "latest",
|
||||||
"moment": "latest",
|
"moment": "latest",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user