Skip to content
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

Closed
wants to merge 4 commits into from
Closed

Conversation

madmod
Copy link

@madmod madmod commented Aug 1, 2017

Allow disabling frameguard so that MM can be embedded in iframes by setting "frameguard" in config.js to false. 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 the helmetOptions parameter.

MichMich and others added 3 commits July 1, 2017 20:32
This adds the configuration key `"frameguard"` to allow for removing the `X-Frame-Options` header so that it can be embedded in iframes.
Copy link
Contributor

@roramirez roramirez left a 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.

@madmod
Copy link
Author

madmod commented Aug 1, 2017

@roramirez Good point. I have changed it to be helmetOptions, allowing any kind of helmet configuration.

@madmod madmod changed the title Allow disabling frameguard Add helmetOptions to config Aug 1, 2017
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));
Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@nhubbard nhubbard left a 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));
Copy link
Contributor

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
    });
}

Copy link
Contributor

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

Copy link

@cowboysdude cowboysdude Aug 6, 2017

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?

Copy link
Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Collaborator

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.

@MichMich
Copy link
Collaborator

Guys, what do I need to do with this PR? Will it be changed?

@nhubbard
Copy link
Contributor

@MichMich Since the debate was settled, I think we can merge it.

@roramirez
Copy link
Contributor

Still not ready to merge.

@MichMich
Copy link
Collaborator

@roramirez What needs to change before we can merge?

@roramirez
Copy link
Contributor

@MichMich Need add the changelog, README and not set values by default if the configuration isn't set.

@madmod Are you want to add these changes?

@MichMich
Copy link
Collaborator

I'm going to close this one due to inactivity. Feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants