-
Notifications
You must be signed in to change notification settings - Fork 68
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
DOC Update secure coding documentation to reflect best practices #696
DOC Update secure coding documentation to reflect best practices #696
Conversation
`_config.php` used to be very common for configuration, but more and more we're preferring YAML configuration. I've never seen a project use the php API for this, since it doesn't allow as much configuration as the YAML API does.
### Using SSL in database connections | ||
|
||
In some circumstances, like connecting to a database on a remote host for example, you may wish to enable SSL encryption to ensure the protection of sensitive information and database access credentials. | ||
You can configure that by setting the following environment variables: | ||
|
||
| Name | Description | | ||
| ---- | ----------- | | ||
| `SS_DATABASE_SSL_KEY` | Absolute path to SSL key file (optional - but if set, `SS_DATABASE_SSL_CERT` must also be set) | | ||
| `SS_DATABASE_SSL_CERT` | Absolute path to SSL certificate file (optional - but if set, `SS_DATABASE_SSL_KEY` must also be set) | | ||
| `SS_DATABASE_SSL_CA` | Absolute path to SSL Certificate Authority bundle file (optional) | | ||
| `SS_DATABASE_SSL_CIPHER` | Custom SSL cipher for database connections (optional) | |
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.
Makes sense to move this to be adjacent to the other bit of docs talking about TLS.
| `SS_DATABASE_SSL_CA` | Absolute path to SSL Certificate Authority bundle file (optional) | | ||
| `SS_DATABASE_SSL_CIPHER` | Custom SSL cipher for database connections (optional) | | ||
|
||
## Secure sessions and cookies |
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.
Makes sense to separate this into its own section - secure cookies and TLS are sort-of related but I don't think enough so to join them together like that.
|
||
if (!Director::isDev()) { | ||
Director::forceSSL(); |
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.
This API does exist but it's a lot less powerful than configuring via YAML because
- there are a lot of options on
CanonicalURLMiddleware
that can't be set via director (even the rest of this old docs has to instantiate a singleton of the middleware to set something) - you ideally want everything configuring this in the same place - so if you have to set some of it in YAML and then some here, that's hard to notice and may cause problems
- I'd expect basically every project that configures
CanonicalURLMiddleware
uses YAML, following CWP's example.
Basically there's no good reason to be setting this in _config.php
Two commits here - if you squash, make sure the commit message is broad enough to encompass both of them.
Commit 1: Update best practice for setting
CanonicalURLMiddleware.ForceSSL
Commit 2: Backport of #692 minus the bit about the warning. The beta has been delayed and it's possible the blog post will be live before we swap over the source of documentation.
Issue