Copyright (c) 2004-2008 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
sfSslRequirement plugin (for symfony 1.0)
The sfSslRequirement is a symfony plugin that provides SSL encryption support for your module actions.
It gives you 2 new security settings: require_ssl and allow_ssl.
The plugin also adds 2 new sfAction methods: ->sslRequired() and ->sslAllowed().
Logic
Only execute once per request and SF_ENVIRONMENT in one of the environments configured in app_disable_sslfilter
* if not posting
* if secured
* then check if its allowed else redirect from https to http
* else if secured required redirect from http to https
Installation
Install the plugin
symfony plugin-install http://plugins.symfony-project.com/sfSslRequirementPlugin
Activate the filter in your filters.yml
sfSslRequirement:
class: sfSslRequirementFilter
Clear your cache
symfony cc
Secure your application
To force SSL on an action:
Add the following snippet to the module security.yml:
sslAction:
require_ssl: true
You're done. Now, if you try to access the sslAction with HTTP, you will be automatically redirected to HTTPS.
- The
sslAction listed here is an example. Substitute with your actual action name.