-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add helmetOptions to config #978
Conversation
Release 2.1.2
This adds the configuration key `"frameguard"` to allow for removing the `X-Frame-Options` header so that it can be embedded in iframes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be better using a options like electronOptions for this case to using with helmet parameters.
@roramirez Good point. I have changed it to be |
js/server.js
Outdated
@@ -38,7 +38,7 @@ var Server = function(config, callback) { | |||
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(helmet({ frameguard: config.frameguard === false ? false : config.frameguard || true })); | |||
app.use(helmet(config.helmetOptions)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is missing Changelog, README documentation and if not set the helmetOption in the configuration file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can understand the changelog fix and docs, but why would we need to put this in the README?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean on this part of README https://github.com/MichMich/MagicMirror#configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick comment on the implementation of helmetOptions
.
@@ -38,7 +38,7 @@ var Server = function(config, callback) { | |||
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(helmet()); | |||
app.use(helmet(config.helmetOptions)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not go for straight config.helmetOptions
, but instead specify a helmet config with some sane defaults if the helmetOptions
key is empty.
Something like this:
if(config.helmetOptions) {
app.use(helmet(config.helmetOptions));
} else {
app.use(helmet({
dnsPrefetchControl: true,
frameguard: false,
hidePoweredBy: true,
hsts: false,
ieNoOpen: false,
noSniff: true,
xssFilter: true
});
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's look good for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm thinking right here couldn't a user just add this to their module to block their module from being put in an iframe even if MM has frameguard disabled?
var frameguard = require('frameguard')
app.use(frameguard({ action: 'deny' }))
I'm not thinking they would or even see why they would but I suppose they could ...
What would that do to MM if they do that an a user has frameguard disabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nhubbard helmet takes care of setting sane defaults for us, and I think allowing it to do so would be better since specifying the defaults in MM would be redundant. (Unless we want to override some of them by default in MM, but I don't think that is necessary.)
@cowboysdude The issue this PR solves is allowing MM to be shown in an iframe. My use for this feature is to show it on a Chromecast. It doesn't have any effect on MM modules using iframes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@madmod I think we should put the defaults I proposed in. It's not that I disagree with you; the defaults used by helmet include some items that don't apply to us, like HSTS and Key Pinning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well .. after thinking more calm this, we need keep the same behavior at today. If nothing setting for helmetOptions
we not should be add be default values.
If we set the defaults values there possibility to get more troubles, some external modules can not work anymore ... and us trying to solve, apply fixes here and there.
So... if somebody want to include the values by default need a policy or plan for this. First of all, add a warning or notice by log where it said it the exists of the new configuration option in an the future will be apply the default values ...if not this is an open windows to get more troubles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @roramirez. I thing the default situation should be no change to the current configuration.
Guys, what do I need to do with this PR? Will it be changed? |
@MichMich Since the debate was settled, I think we can merge it. |
Still not ready to merge. |
@roramirez What needs to change before we can merge? |
I'm going to close this one due to inactivity. Feel free to reopen. |
Allow disabling frameguard so that MM can be embedded in iframes by setting"frameguard"
inconfig.js
tofalse
. It also allows for advanced configuration of frameguard as explained in the helmet docs.Originally this was intended to only allow disabling frameguard, but at the suggestion of @roramirez I have modified it to allow setting any helmet options from
config.js
by specifying thehelmetOptions
parameter.