views:

36

answers:

1

How do I check if the action I am calling was secured in security.yml?

security.yml

myAction:
  is_secure: false

filter.yml

myFilter:
  class: myFilter

Now inside myFilter i want to check if the action was secured or not.

class myFilter extends sfFilter
{
  public function execute($filterChain)
  {
    if ($this->getContext()->is_secure === false) {
      $filterChain->execute();
    }
    // ...
  }
}
+1  A: 

Hello. Here is my research:

greg@liche :) ~/source/symfony/1.4 > ack "public function isSecure" --type="php"
lib/request/sfWebRequest.class.php
545:  public function isSecure()

lib/action/sfAction.class.php
407:  public function isSecure()

test/unit/helper/AssetHelperTest.php
29:  public function isSecure()

test/unit/helper/UrlHelperTest.php
30:  public function isSecure()
greg@liche :( ~/source/symfony/1.4 > ack "public function getAction\(" --type="php"
lib/controller/sfController.class.php
258:  public function getAction($moduleName, $actionName)
greg@liche :) ~/source/symfony/1.4 > ack "public function getController\(" --type="php"
lib/util/sfContext.class.php
243:   public function getController(

)

Which means that $this->getContext()->getController()->getAction()->isSecure() should do it.

greg0ire
I did find out in the meantime: $this->context->getController()->getActionStack() ->getLastEntry()->getActionInstance() ->getSecurityValue('is_secure');
tilman