for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* strategy for validating auth through the ip address.
*/
namespace Graviton\SecurityBundle\Authentication\Strategies;
use Symfony\Component\HttpFoundation\IpUtils;
use Symfony\Component\HttpFoundation\Request;
* Class SameSubnetStrategy
*
* @author List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @link http://swisscom.ch
class SameSubnetStrategy extends AbstractHttpStrategy
{
/** @var String */
protected $subnet;
* @param String $subnet Subnet to be checked (e.g. 10.2.0.0/24)
public function __construct($subnet)
$this->subnet= $subnet;
}
* Applies the defined strategy on the provided request.
* @param Request $request request to handle
* @return string
public function apply(Request $request)
if (IpUtils::checkIp($request->getClientIp(), $this->subnet)) {
return 'graviton_subnet_user';
throw new \InvalidArgumentException('Provided request information are not valid.');
* Decider to stop other strategies running after from being considered.
* @return boolean
public function stopPropagation() {
return false;