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

Enable secure cookies #6868

Merged
merged 22 commits into from
Jun 26, 2017
Merged

Enable secure cookies #6868

merged 22 commits into from
Jun 26, 2017

Conversation

rzig
Copy link
Contributor

@rzig rzig commented Jun 20, 2017

This will enable secure cookies automatically over HTTPS and has a line in config.default.php that can be uncommented to enable secure session cookies.

Would you like me to add any documentation on the line in config.default.php?

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926

fixes: #6866

@CLAassistant
Copy link

CLAassistant commented Jun 20, 2017

CLA assistant check
All committers have signed the CLA.

@LibreNMS-CI
Copy link

Auto-Deploy finished, Test PR at http://6868.ci.librenms.org or https://6868.ci.librenms.org

@@ -49,3 +49,6 @@ $config['enable_billing'] = 1;

# Enable the in-built services support (Nagios plugins)
$config['show_services'] = 1;

# Uncomment the following line if you're using HTTPS and want secure session cookies
# ini_set('session.cookie_secure', 1);
Copy link
Member

@murrant murrant Jun 20, 2017

Choose a reason for hiding this comment

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

Don't put code in this file, only config definitions.
You can move this to init.php

Also, any reason not to do this by default? Does it break setups that don't have http?

rzig added 2 commits June 20, 2017 13:29
Commented out because having this enabled will prevent the server from sending cookies over HTTPS.
@LibreNMS-CI
Copy link

Auto-Deploy finished, Test PR at http://6868.ci.librenms.org or https://6868.ci.librenms.org

1 similar comment
@LibreNMS-CI
Copy link

Auto-Deploy finished, Test PR at http://6868.ci.librenms.org or https://6868.ci.librenms.org

@rzig
Copy link
Contributor Author

rzig commented Jun 20, 2017

@murrant, the Travis CI build failed, but I don't think it is as a result of my code as the lines I added were commented out and the error related to a syslog test that appears to be a result of the previous merge.

setcookie('sess_id', $sess_id, $expiration, '/', null, false, true);
setcookie('token', $token_id, $expiration, '/', null, false, true);
setcookie('auth', $auth, $expiration, '/', null, false, true);
// Params: name, value, expire, path, domain, secure, httponly
Copy link
Member

Choose a reason for hiding this comment

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

you can get rid of all of these comments.

// Params: name, value, expire, path, domain, secure, httponly
// We set the secure param to $_SERVER["HTTPS"], which will return true
// and make it a secure cookie if HTTPS is being used
setcookie('sess_id', $sess_id, $expiration, '/', null, $_SERVER["HTTPS"], true);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not really sure we should just be basing it on if the user is connecting over https or not as surely that's what we have now.

Would it not be better to have the user set in config.php if the connection should be secure and use that variable here?

Copy link
Contributor Author

@rzig rzig Jun 20, 2017

Choose a reason for hiding this comment

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

I'll set an option in config.php.

@@ -90,6 +90,9 @@
require $install_dir . '/includes/definitions.inc.php';
include $install_dir . '/config.php';

# Uncomment the following line if you're using HTTPS and want secure session cookies
Copy link
Member

Choose a reason for hiding this comment

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

Please use // instead of # just to be consistent.

We should use the same config variable we would use in setcookie() to also run this ini_set() which would be better placed in includes/process_config.inc.php

@LibreNMS-CI
Copy link

Auto-Deploy finished, Test PR at http://6868.ci.librenms.org or https://6868.ci.librenms.org

@LibreNMS-CI
Copy link

Auto-Deploy finished, Test PR at http://6868.ci.librenms.org or https://6868.ci.librenms.org

@LibreNMS-CI
Copy link

Auto-Deploy finished, Test PR at http://6868.ci.librenms.org or https://6868.ci.librenms.org

1 similar comment
@LibreNMS-CI
Copy link

Auto-Deploy finished, Test PR at http://6868.ci.librenms.org or https://6868.ci.librenms.org

@LibreNMS-CI
Copy link

Auto-Deploy finished, Test PR at http://6868.ci.librenms.org or https://6868.ci.librenms.org

2 similar comments
@LibreNMS-CI
Copy link

Auto-Deploy finished, Test PR at http://6868.ci.librenms.org or https://6868.ci.librenms.org

@LibreNMS-CI
Copy link

Auto-Deploy finished, Test PR at http://6868.ci.librenms.org or https://6868.ci.librenms.org

@murrant
Copy link
Member

murrant commented Jun 21, 2017

I've pushed a fix for the travis failures, you'll have to merge it to fix your build failure.

@rzig rzig mentioned this pull request Jun 22, 2017
@rzig
Copy link
Contributor Author

rzig commented Jun 22, 2017

DO NOT DELETE THIS TEXT

Please note

Please read this information carefully. You can run ./scripts/pre-commit.php to check your code before submitting.

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926

Forgot to include this earlier, sorry.

@@ -49,3 +49,6 @@ $config['enable_billing'] = 1;

# Enable the in-built services support (Nagios plugins)
$config['show_services'] = 1;

# Whether to use secure cookies. Should be true if you're using HTTPS
$config['secure_cookies'] = false;
Copy link
Member

Choose a reason for hiding this comment

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

Lets move this to includes/defaults.inc.php and then this looks good to go.

Thanks for discussing in depth :)

@rzig
Copy link
Contributor Author

rzig commented Jun 23, 2017

There's a bit of an issue. When I try and apply the patch it says error: patch failed: includes/process_config.inc.php:36. I'm thinking it has something to do with whitespace, but I don't see anything out of the ordinary. Any ideas?

@rzig
Copy link
Contributor Author

rzig commented Jun 23, 2017

The git issue is fixed - it still complains about whitespace, but it applies the patches.

@scrutinizer-notifier
Copy link

The inspection completed: No new issues

@laf
Copy link
Member

laf commented Jun 23, 2017

LGTM

@laf laf merged commit 1ba6381 into librenms:master Jun 26, 2017
@lock
Copy link

lock bot commented May 17, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed.

@lock lock bot locked as resolved and limited conversation to collaborators May 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Secure cookies not enabled
6 participants