<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to unsecure admin generated modules in Symfony</title>
	<atom:link href="http://www.digitalbase.eu/blog/how-to-unsecure-admin-generated-modules/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.digitalbase.eu/blog/how-to-unsecure-admin-generated-modules/</link>
	<description>A blog about webdesign, PHP, development and IT</description>
	<lastBuildDate>Wed, 15 Dec 2010 12:09:22 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Tiago Carvalho</title>
		<link>http://www.digitalbase.eu/blog/how-to-unsecure-admin-generated-modules/comment-page-1/#comment-258</link>
		<dc:creator>Tiago Carvalho</dc:creator>
		<pubDate>Mon, 10 May 2010 15:25:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalbase.eu/blog/?p=245#comment-258</guid>
		<description>Thank you! This post helped me a lot.</description>
		<content:encoded><![CDATA[<p>Thank you! This post helped me a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Winzter143</title>
		<link>http://www.digitalbase.eu/blog/how-to-unsecure-admin-generated-modules/comment-page-1/#comment-241</link>
		<dc:creator>Winzter143</dc:creator>
		<pubDate>Thu, 07 Jan 2010 04:38:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalbase.eu/blog/?p=245#comment-241</guid>
		<description>H! to all,

I reading the symfony docs but i cant get what $credential parameter is, in the hasCredential function.  Is the $credential parameter is an Object, String or what?


Im newbie to this task..

Thank a lot for your reply.</description>
		<content:encoded><![CDATA[<p>H! to all,</p>
<p>I reading the symfony docs but i cant get what $credential parameter is, in the hasCredential function.  Is the $credential parameter is an Object, String or what?</p>
<p>Im newbie to this task..</p>
<p>Thank a lot for your reply.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jukea</title>
		<link>http://www.digitalbase.eu/blog/how-to-unsecure-admin-generated-modules/comment-page-1/#comment-229</link>
		<dc:creator>jukea</dc:creator>
		<pubDate>Wed, 21 Oct 2009 17:34:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalbase.eu/blog/?p=245#comment-229</guid>
		<description>hey look, I filed a ticket around the same time you notices that, and it has been fixed in february

http://trac.symfony-project.org/ticket/5582</description>
		<content:encoded><![CDATA[<p>hey look, I filed a ticket around the same time you notices that, and it has been fixed in february</p>
<p><a href="http://trac.symfony-project.org/ticket/5582" rel="nofollow">http://trac.symfony-project.org/ticket/5582</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sebastian</title>
		<link>http://www.digitalbase.eu/blog/how-to-unsecure-admin-generated-modules/comment-page-1/#comment-204</link>
		<dc:creator>Sebastian</dc:creator>
		<pubDate>Mon, 22 Jun 2009 18:41:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalbase.eu/blog/?p=245#comment-204</guid>
		<description>Hello to all!!!

I am new as developer in symfony.

I do not have a lot of experience but i think the sfGuardPlugin has an error in the hasCredential method. to solve this error I think the best way is to redefine this method like this:

class myUser extends sfGuardSecurityUser
{
  public function hasCredential($credential, $useAnd = true)
  {
    if (count($credential) == 0)
      return true;
    else
      return parent::hasCredential($credential,$useAnd);
  }
}

the error is that sfGuardSecurityUser do not verify if $credentia is empty.

Regards!

Sebastian</description>
		<content:encoded><![CDATA[<p>Hello to all!!!</p>
<p>I am new as developer in symfony.</p>
<p>I do not have a lot of experience but i think the sfGuardPlugin has an error in the hasCredential method. to solve this error I think the best way is to redefine this method like this:</p>
<p>class myUser extends sfGuardSecurityUser<br />
{<br />
  public function hasCredential($credential, $useAnd = true)<br />
  {<br />
    if (count($credential) == 0)<br />
      return true;<br />
    else<br />
      return parent::hasCredential($credential,$useAnd);<br />
  }<br />
}</p>
<p>the error is that sfGuardSecurityUser do not verify if $credentia is empty.</p>
<p>Regards!</p>
<p>Sebastian</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jrh</title>
		<link>http://www.digitalbase.eu/blog/how-to-unsecure-admin-generated-modules/comment-page-1/#comment-185</link>
		<dc:creator>jrh</dc:creator>
		<pubDate>Thu, 30 Apr 2009 21:03:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalbase.eu/blog/?p=245#comment-185</guid>
		<description>return sfBasicSecurityUser::hasCredential($credential, $useAnd = true); is wrong

the correct answer is 

return sfBasicSecurityUser::hasCredential($credential, $useAnd);</description>
		<content:encoded><![CDATA[<p>return sfBasicSecurityUser::hasCredential($credential, $useAnd = true); is wrong</p>
<p>the correct answer is </p>
<p>return sfBasicSecurityUser::hasCredential($credential, $useAnd);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jrh</title>
		<link>http://www.digitalbase.eu/blog/how-to-unsecure-admin-generated-modules/comment-page-1/#comment-155</link>
		<dc:creator>jrh</dc:creator>
		<pubDate>Mon, 23 Mar 2009 22:21:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalbase.eu/blog/?p=245#comment-155</guid>
		<description>getGuardUser() instanceof sfGuardUser  &amp;&amp; $this-&gt;getGuardUser()-&gt;getIsSuperAdmin())
    {      
      return true;
    }
    
    return sfBasicSecurityUser::hasCredential($credential, $useAnd = true);    
  }
}</description>
		<content:encoded><![CDATA[<p>getGuardUser() instanceof sfGuardUser  &amp;&amp; $this-&gt;getGuardUser()-&gt;getIsSuperAdmin())<br />
    {<br />
      return true;<br />
    }</p>
<p>    return sfBasicSecurityUser::hasCredential($credential, $useAnd = true);<br />
  }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tito</title>
		<link>http://www.digitalbase.eu/blog/how-to-unsecure-admin-generated-modules/comment-page-1/#comment-153</link>
		<dc:creator>Tito</dc:creator>
		<pubDate>Tue, 17 Mar 2009 11:42:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalbase.eu/blog/?p=245#comment-153</guid>
		<description>in my case, what i&#039;ve done it is to redefine the method hasCredentials in the myUser class to this:

class myUser extends sfGuardSecurityUser
{
  public function hasCredential($credentials, $useAnd = true)
  {
    if ($this-&gt;getGuardUser() &amp;&amp; $this-&gt;getGuardUser()-&gt;getIsSuperAdmin())
    {
      return true;
    }
  	// método redefinido para o original da sfBasicSecurityUser
  	if (!is_array($credentials))
    {
      return in_array($credentials, $this-&gt;credentials);
    }

    // now we assume that $credentials is an array
    $test = false;

    foreach ($credentials as $credential)
    {
      // recursively check the credential with a switched AND/OR mode
      $test = $this-&gt;hasCredential($credential, $useAnd ? false : true);

      if ($useAnd)
      {
        $test = $test ? false : true;
      }

      if ($test) // either passed one in OR mode or failed one in AND mode
      {
        break; // the matter is settled
      }
    }

    if ($useAnd) // in AND mode we succeed if $test is false
    {
      $test = $test ? false : true;
    }

    return $test;
  }
}

the problem with the method hasCredentials from the sfGuardPlugin is that it forces you to have an object sfGuardUser, which only happens when you login.</description>
		<content:encoded><![CDATA[<p>in my case, what i&#8217;ve done it is to redefine the method hasCredentials in the myUser class to this:</p>
<p>class myUser extends sfGuardSecurityUser<br />
{<br />
  public function hasCredential($credentials, $useAnd = true)<br />
  {<br />
    if ($this-&gt;getGuardUser() &amp;&amp; $this-&gt;getGuardUser()-&gt;getIsSuperAdmin())<br />
    {<br />
      return true;<br />
    }<br />
  	// método redefinido para o original da sfBasicSecurityUser<br />
  	if (!is_array($credentials))<br />
    {<br />
      return in_array($credentials, $this-&gt;credentials);<br />
    }</p>
<p>    // now we assume that $credentials is an array<br />
    $test = false;</p>
<p>    foreach ($credentials as $credential)<br />
    {<br />
      // recursively check the credential with a switched AND/OR mode<br />
      $test = $this-&gt;hasCredential($credential, $useAnd ? false : true);</p>
<p>      if ($useAnd)<br />
      {<br />
        $test = $test ? false : true;<br />
      }</p>
<p>      if ($test) // either passed one in OR mode or failed one in AND mode<br />
      {<br />
        break; // the matter is settled<br />
      }<br />
    }</p>
<p>    if ($useAnd) // in AND mode we succeed if $test is false<br />
    {<br />
      $test = $test ? false : true;<br />
    }</p>
<p>    return $test;<br />
  }<br />
}</p>
<p>the problem with the method hasCredentials from the sfGuardPlugin is that it forces you to have an object sfGuardUser, which only happens when you login.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luciano</title>
		<link>http://www.digitalbase.eu/blog/how-to-unsecure-admin-generated-modules/comment-page-1/#comment-128</link>
		<dc:creator>Luciano</dc:creator>
		<pubDate>Tue, 27 Jan 2009 19:47:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalbase.eu/blog/?p=245#comment-128</guid>
		<description>Answers... but not to all :(
1)Yes I did use the propel:generate-admin.
2)I didn&#039;t know you were using sfGuardPlugin.
3)Without sfGuardPlugin hasCredential() returns true, but with sfGuardPlugin it returns false, mmm why is that?? Simple beacuse hasCredential() checks differents things in sfGuardSecurityUser and in sfBasicSecurityUser.
The thing is that when you extend sfGuardSecurityUser, hasCredential() checks if there is a sfGuardUser walking around, and as we don&#039;t want one of those (this is the whole point) it just returns false. I think perhaps there is something wrong, because  the framework seems to not be taking into account that if you say in a module:
all:
is_secure: off
you clearly want the framework to not check for any credential at all.
I really don&#039;t know, in the meantime people we&#039;ll have to use your fix.
Keep working and all the best to you.</description>
		<content:encoded><![CDATA[<p>Answers&#8230; but not to all <img src='http://www.digitalbase.eu/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /><br />
1)Yes I did use the propel:generate-admin.<br />
2)I didn&#8217;t know you were using sfGuardPlugin.<br />
3)Without sfGuardPlugin hasCredential() returns true, but with sfGuardPlugin it returns false, mmm why is that?? Simple beacuse hasCredential() checks differents things in sfGuardSecurityUser and in sfBasicSecurityUser.<br />
The thing is that when you extend sfGuardSecurityUser, hasCredential() checks if there is a sfGuardUser walking around, and as we don&#8217;t want one of those (this is the whole point) it just returns false. I think perhaps there is something wrong, because  the framework seems to not be taking into account that if you say in a module:<br />
all:<br />
is_secure: off<br />
you clearly want the framework to not check for any credential at all.<br />
I really don&#8217;t know, in the meantime people we&#8217;ll have to use your fix.<br />
Keep working and all the best to you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bart Vanderstukken</title>
		<link>http://www.digitalbase.eu/blog/how-to-unsecure-admin-generated-modules/comment-page-1/#comment-127</link>
		<dc:creator>Bart Vanderstukken</dc:creator>
		<pubDate>Tue, 27 Jan 2009 15:19:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalbase.eu/blog/?p=245#comment-127</guid>
		<description>Hmmm, that&#039;s strange.
Few questions:
1) Did you use propel:generate-admin? I guess you did...
I&#039;m asking because the method you&#039;re describing is the default symfony behaviour (as you would expect). But that&#039;s not what&#039;s happening here... :s
2) You&#039;re probably not using sfGuardPlugin in your sandbox. THAT could be the problem! :)
3) hasCredential(array()) is probably returning true in your case, instead of false?
That&#039;s what the preExecute action is returning anyway (if no credentials defined in generator.yml)...

I&#039;ll try to find out if the sfGuardPlugin is indeed the problem...

PS: I&#039;m using symfony release_1_2_2</description>
		<content:encoded><![CDATA[<p>Hmmm, that&#8217;s strange.<br />
Few questions:<br />
1) Did you use propel:generate-admin? I guess you did&#8230;<br />
I&#8217;m asking because the method you&#8217;re describing is the default symfony behaviour (as you would expect). But that&#8217;s not what&#8217;s happening here&#8230; :s<br />
2) You&#8217;re probably not using sfGuardPlugin in your sandbox. THAT could be the problem! <img src='http://www.digitalbase.eu/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
3) hasCredential(array()) is probably returning true in your case, instead of false?<br />
That&#8217;s what the preExecute action is returning anyway (if no credentials defined in generator.yml)&#8230;</p>
<p>I&#8217;ll try to find out if the sfGuardPlugin is indeed the problem&#8230;</p>
<p>PS: I&#8217;m using symfony release_1_2_2</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luciano</title>
		<link>http://www.digitalbase.eu/blog/how-to-unsecure-admin-generated-modules/comment-page-1/#comment-126</link>
		<dc:creator>Luciano</dc:creator>
		<pubDate>Tue, 27 Jan 2009 14:02:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.digitalbase.eu/blog/?p=245#comment-126</guid>
		<description>I&#039;ve just followed these steps to reproduce your issue using sf_sandbox 1.2.2:
-I created a new propel admin module.
-I secured the app, modifying 
/sf_sandbox_1_2/apps/frontend/config/security.yml with these values:
  default:
    is_secure: on
-I tested it in the browser, i was asked to login (so far so good)
-I created /sf_sandbox_1_2/apps/frontend/modules/{module_name}/config/security.yml with this content:
  all:
    is_secure: off
and then tested it again in the browser... and voilà I was no longer asked to log in, I didn&#039;t touch anything in config.yml nor in actions.class.php of my module.
Could it be something fixed after you downloaded your symfony?</description>
		<content:encoded><![CDATA[<p>I&#8217;ve just followed these steps to reproduce your issue using sf_sandbox 1.2.2:<br />
-I created a new propel admin module.<br />
-I secured the app, modifying<br />
/sf_sandbox_1_2/apps/frontend/config/security.yml with these values:<br />
  default:<br />
    is_secure: on<br />
-I tested it in the browser, i was asked to login (so far so good)<br />
-I created /sf_sandbox_1_2/apps/frontend/modules/{module_name}/config/security.yml with this content:<br />
  all:<br />
    is_secure: off<br />
and then tested it again in the browser&#8230; and voilà I was no longer asked to log in, I didn&#8217;t touch anything in config.yml nor in actions.class.php of my module.<br />
Could it be something fixed after you downloaded your symfony?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

