<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>cleiver.com &#187; acl</title>
	<atom:link href="http://blog.cleiver.com/tag/acl/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.cleiver.com</link>
	<description>blog</description>
	<lastBuildDate>Wed, 18 Nov 2009 00:37:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>phpGACL</title>
		<link>http://blog.cleiver.com/2008/09/23/phpgacl/</link>
		<comments>http://blog.cleiver.com/2008/09/23/phpgacl/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 18:53:18 +0000</pubDate>
		<dc:creator>Cleiver</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[acl]]></category>
		<category><![CDATA[dicas]]></category>

		<guid isPermaLink="false">http://blog.cleiver.com/?p=90</guid>
		<description><![CDATA[Um dia depois de eu atualizar o blog, o Rafael me mandou um link pro phpGACL, uma ferramente GenÃ©rica de controle de acessos em PHP. Sendo genÃ©rica, nÃ£o importa se vocÃª utiliza alguma framework ou se desenvolve PHP na unha, Ã© sÃ³ incluir a classe e utilizar.
Ao contrÃ¡rio da ACL do Cake, ela Ã© muito [...]]]></description>
			<content:encoded><![CDATA[<p>Um dia depois de eu <a title="utilizando ACL no CakePHP" href="http://blog.cleiver.com/2008/09/18/utilizando-o-acl-no-cakephp/" target="_blank">atualizar</a> o blog, o <a title="rafael Dx7" href="http://www.dx7lab.com" target="_blank">Rafael</a> me mandou um link pro <a title="phpGACL" href="http://phpgacl.sourceforge.net/" target="_blank">phpGACL</a>, uma ferramente <strong>G</strong>enÃ©rica de controle de acessos em PHP. Sendo genÃ©rica, nÃ£o importa se vocÃª utiliza alguma framework ou se desenvolve PHP na unha, Ã© sÃ³ incluir a classe e utilizar.</p>
<p>Ao contrÃ¡rio da ACL do <a title="CakePHP Framework" href="http://cakephp.org/" target="_blank">Cake</a>, ela Ã© muito melhor documentada e bem mais complexa, mas nem por isso menos simples. Vem com instalador, suporta praticamente todos os bancos de dados (foi desenvolvido utilizando o ADOdb) e ainda possui uma interface de administraÃ§Ã£o.</p>
<p>No pacote vem um manual explicando o conceito da ACL (aqui eles utilizam os personagens de Star Wars) e a documentaÃ§Ã£o da API das classes para referÃªncia.</p>
<p><a title="phpGACL plugin" href="http://dev.sypad.com/installing-phpgacl-plugin-cakephp" target="_blank">Nesse link</a> tem um tutorial de instalaÃ§Ã£o de um pacote para integrar o <a title="phpGACL" href="http://phpgacl.sourceforge.net/" target="_blank">phpGACL</a> no <a title="CakePHP Framework" href="http://cakephp.org/" target="_blank">CakePHP</a>. Particularmente nÃ£o fui com a cara desse plugin/componente (talvez pelo fato de ser argentino :P) e preferi fazer a integraÃ§Ã£o na mÃ£o e criei meu prÃ³prio componente.</p>


<p>Nenhum post relacionado.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.cleiver.com/2008/09/23/phpgacl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Utilizando o ACL no CakePHP</title>
		<link>http://blog.cleiver.com/2008/09/18/utilizando-o-acl-no-cakephp/</link>
		<comments>http://blog.cleiver.com/2008/09/18/utilizando-o-acl-no-cakephp/#comments</comments>
		<pubDate>Thu, 18 Sep 2008 14:43:22 +0000</pubDate>
		<dc:creator>Cleiver</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[acl]]></category>
		<category><![CDATA[dicas]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.cleiver.com/?p=84</guid>
		<description><![CDATA[Estamos comeÃ§ando um novo projeto aqui na empresa e para ele decidimos usar o CakePHP como framework de desenvolvimento. Desde semana passada estou estudando a utilizaÃ§Ã£o do ACL para controle de acesso Ã s pÃ¡ginas do sistema, mas como muitos devem saber, o book do site do Cake nÃ£o Ã© tÃ£o explicativo quanto deveria. :P
Quer [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cakephp.org" target="_blank"><img class="size-full wp-image-85" title="CakePHP" src="http://blog.cleiver.com/wp-content/uploads/2008/09/cake-logo.png" alt="CakePHP" width="180" height="180" align="left" /></a>Estamos comeÃ§ando um novo projeto aqui na empresa e para ele decidimos usar o <a title="CakePHP Framework" href="http://cakephp.org" target="_blank">CakePHP</a> como framework de desenvolvimento. Desde semana passada estou estudando a utilizaÃ§Ã£o do ACL para controle de acesso Ã s pÃ¡ginas do sistema, mas como muitos devem saber, o <a title="Cook Book" href="http://book.cakephp.org/" target="_blank">book</a> do site do Cake nÃ£o Ã© tÃ£o explicativo quanto deveria. :P</p>
<p>Quer dizer, o <a title="The Lord of the Rings baking a cake! :P" href="http://book.cakephp.org/view/465/Understanding-How-ACL-Works" target="_blank">exemplo do conceito sendo explicado utilizando os personagens d&#8217;O Senhor dos AnÃ©is</a> Ã© sensacional! Mas sÃ³ serve pra isso mesmo, explicar o conceito. Por que na prÃ¡tica, a coisa Ã© um pouco mais complexa.</p>
<p>Pra tentar entender o funcionamento, criei o <a title="Exemplo simples de blog com CakePHP" href="http://book.cakephp.org/view/219/Blog" target="_blank">blog de exemplo</a> do prÃ³prio &#8220;<a title="Cook Book :P" href="http://book.cakephp.org/" target="_blank">Livro de Receitas</a>&#8221; do CakePHP. PorÃ©m ele Ã© simples demais e nem tem usuÃ¡rios. EntÃ£o criei uma tabela para armazenar somente um login e senha de acesso. Nada muito difÃ­cil para quem jÃ¡ mexeu com o  Cake pelo menos uma vez.</p>
<p>AÃ­ vem outro problema: por padrÃ£o, o ACL vem pronto pra trabalhar com CRUD, e dificilmente teremos um sistema que sÃ³ utilize os mÃ©todos do CRUD. O que fazer entÃ£o? Depois de dias lendo documentaÃ§Ã£o sobre o assunto, chegou atÃ© mim um texto (perdi o link, desculpem. :/) que dizia, resumidamente, que era sÃ³ associar os actions como ACOs normalmente, e na hora de salvar no banco, dar acesso total nos</p>
<p>EntÃ£o, supondo que esteja tudo pronto, vamos resolver o grande problema que encontrei nos blogs que li: Os mÃ©todos de criaÃ§Ã£o dos AROs e dos ACOs, bem como seus relacionamentos, <span style="text-decoration: underline;"><em><strong>nÃ£o devem ficar espalhados pela aplicaÃ§Ã£o</strong></em></span>. Crie um arquivo PHP separado para executar somente quando vocÃª precisar popular o banco de dados com as informaÃ§Ãµes de acesso.</p>
<p>EntÃ£o vamos comeÃ§ar criando um pequeno script que cria os AROs do nosso &#8220;sistema&#8221;:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$aro</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> aro<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$groups</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
   <span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'alias'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Admins'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
   <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'alias'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Authors'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
   <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'alias'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Spammers'</span> <span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$groups</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$group</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$aro</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$aro</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$group</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Esse script vai gerar grupos de usuÃ¡rios do sistema. temos os administradores, os autores do blog e spammers, que sÃ£o usuÃ¡rios que nÃ£o terÃ£o acesso a nada.</p>
<p>Agora vamos criar alguns usuÃ¡rios:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$aro</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> aro<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$users</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
   <span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'alias'</span> <span style="color: #339933;">=&gt;</span> Pedro<span style="color: #339933;">,</span> <span style="color: #0000ff;">'parent_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'model'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'User'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'foreign_key'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
   <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'alias'</span> <span style="color: #339933;">=&gt;</span> Rafael<span style="color: #339933;">,</span> <span style="color: #0000ff;">'parent_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'model'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'User'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'foreign_key'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">2</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
   <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'alias'</span> <span style="color: #339933;">=&gt;</span> Adriana<span style="color: #339933;">,</span> <span style="color: #0000ff;">'parent_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">3</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'model'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'User'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'foreign_key'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">3</span> <span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$users</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$user</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$aro</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$aro</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$user</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Acima estou criando 3 usuÃ¡rios apenas, um para cada grupo. O campo <strong>parent_id</strong> aponta para o grupo que o usuÃ¡rio faz parte. O campo <strong>model</strong>, como o prÃ³prio nome diz, especifica um modelo. No caso, ele guarda o nome do modelo que o id armazenado em <strong>foreign_key</strong> pertence. EntÃ£o no exemplo acima, o id do Pedro na tabela User Ã© 1.</p>
<p>Agora vamos criar algumas ACOs:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$aco</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> aco<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$group</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'alias'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Post'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$aco</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$aco</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$group</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$actions</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
   <span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'alias'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'index'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'parent_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
   <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'alias'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'view'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'parent_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
   <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'alias'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'add'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'parent_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
   <span style="color: #cc66cc;">3</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'alias'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'delete'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'parent_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
   <span style="color: #cc66cc;">4</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'alias'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'edit'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'parent_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$actions</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$action</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$aco</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$aco</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$action</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>O processo para criaÃ§Ã£o Ã© exatamente o mesmo do utilizado no ARO. Aqui, primeiro criei um grupo com o nome do prÃ³prio controller, assim fica mais fÃ¡cil organizar. Depois, criei uma ACO para cada action do controller e as relacionei com o grupo criado anteriormente.</p>
<p>Se vocÃª nÃ£o definir nenhum tipo de permissÃ£o de acesso, por padrÃ£o, Ã© tudo negado. EntÃ£o vamos definir algumas permissÃµes:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Acl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">allow</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Admins'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'Post'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'*'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Acl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">allow</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Authors'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'Post'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'*'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Acl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">deny</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Authors'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'Post/delete'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'*'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Acl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">deny</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Spammers'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'Post'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'*'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Na primeira linha, dei acesso total Ã  todas as actions do controller Post para os usuÃ¡rios que fizerem parte do grupo Admins. Na segunda linha, dei acesso total tambÃ©m aos autores do blog, mas na terceira eu tirei a permissÃ£o deles de deletar algum post, ou seja, eles podem tudo, menos deletar o texto que escreveram. Assim Ã© mais fÃ¡cil do que ficar fazendo um allow para cada action do controller. Na quarta linha tirei a permissÃ£o de acesso Ã  todas as actions do controller para quem for do grupo spammers.</p>
<p>Para verificar quem tem acesso ou nÃ£o, dentro do seu controller, no mÃ©todo beforeFilter por exemplo, basta fazer o seguinte:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Acl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">check</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Authors'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'Post/delete'</span> <span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>No nosso caso vai retornar FALSE.</p>
<p>Basicamente Ã© isso. Tem outras coisas interessantes para se trabalhar junto com o ACL, como o <a title="ACL Behavior" href="http://lemoncake.wordpress.com/2007/07/15/using-aclbehavior-in-cakephp-12/" target="_blank">ACLBehavior</a> e o <a title="ACL Management Plugin" href="http://jeff.loiselles.com/wordpress/?p=28" target="_blank">ACL Management Plugin</a>. Uma boa leitura que pode ajudar um bocado Ã© esse <a href="http://aranworld.com/article/161/cakephp-acl-tutorial-what-is-it" target="_blank">tutorial</a> de utilizaÃ§Ã£o que um cara fez pro caso dele, tem atÃ© um sitezinho de exemplo.</p>


<p>Nenhum post relacionado.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.cleiver.com/2008/09/18/utilizando-o-acl-no-cakephp/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
