Friday, January 3, 2014

Is admin_ prefix a security or just convenient?

I understand a user can not directly access mysite.com/users/admin_index

Instead they go to mysite.com/admin/users/index

But, is there any automatic security checking? Because anyone can type in mysite.com/admin/users/index 

Is it still up to the UsersController to filter out unauthorized users? such as have an IsAuthorized setting, or the function admin_index still needs to check the user's privileges and reject the request if the user doesn't have admin privs?

In which case I don't see the advantage of using the admin_ prefix. Seems like a big security problem if every controller function needs to check the user's privileges. Is there a better way I'm missing?

Can IsAuthorized somehow say only admin users are allowed to run admin functions?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Error: Class 'SimplePasswordHasher' not found

I had exactly the same issue when I did the tutorial, but it had to do with caching/refreshing because suddenly it worked.
In your case: you do mean the 'User' model; it should not be 'Users'.
I only have 'App::uses('SimplePasswordHasher', 'Controller/Component/Auth');' and it works just fine.

Op vrijdag 3 januari 2014 06:49:28 UTC+1 schreef Justin Atack:
Hi All,

I hope you can point me in the right direction.


I'm using CakePHP 2.4.3 and have followed the guide to the letter of the law. It mostly works correctly. If I try to access a controller/action it redirects as it should to the users/login action... so that's seems fine.

The issue is when I try to add a new user at users/add. It throws this error: Error: Class 'SimplePasswordHasher' not found

I have made sure that the following is pasted in the top of the Users model: App::uses('AppModel', 'Model', 'SimplePasswordHasher', 'Controller/Component/Auth');

I then thought that perhaps this "SimplePasswordHasher" class was a new thing part of 2.4.4 so I set up another test project to test it and went through the entire Auth tutorial again with exactly the same results.

Where am I going wrong? It there some code missing? 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

Thursday, January 2, 2014

Error: Class 'SimplePasswordHasher' not found

Hi All,

I hope you can point me in the right direction.

I'm following the guide at: http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html

I'm using CakePHP 2.4.3 and have followed the guide to the letter of the law. It mostly works correctly. If I try to access a controller/action it redirects as it should to the users/login action... so that's seems fine.

The issue is when I try to add a new user at users/add. It throws this error: Error: Class 'SimplePasswordHasher' not found

I have made sure that the following is pasted in the top of the Users model: App::uses('AppModel', 'Model', 'SimplePasswordHasher', 'Controller/Component/Auth');

I then thought that perhaps this "SimplePasswordHasher" class was a new thing part of 2.4.4 so I set up another test project to test it and went through the entire Auth tutorial again with exactly the same results.

Where am I going wrong? It there some code missing? 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Generate XML using controller and force it to sent as download

It can be done with regular PHP, so it can be done with CakePHP.

The MediaView is a view class uses specifically for downloading files, and media, rather than viewing in the browser.  However, this usually requires that the file is locally available on the disk, and this isn't happening in your case.

However, looking at the MediaView and related processing, we can see that you need the Content-Disposition header entry, to force an attachment, with a particular file name.

So, using a cheats method, include the following in your layout:

<?php header('Content-Disposition: attachment; filename="myxml.xml"'); ?>

Though you may want to using something a bit more CakePHP friendly than the raw header() command.

It's been a while since I've done development in CakePHP 1.3, however in CakePHP 2.4, you can specify $this->response->download($filename); to write that header.

Regards
Reuben Helms

On Thursday, 2 January 2014 21:43:03 UTC+10, Willem wrote:
Still haven't figured this out. Is this at all possible with CakePHP? I can't imagine it would not be possible.

thanks




On Thursday, December 19, 2013 5:16:50 PM UTC+1, Willem wrote:
Hi,

Goal: I have a button on a page. When user clicks it should generate a XML file and make it download (instead of opening in browser window).
Cake version: 1.3

So I create a HTML link like this:

<?php echo $html->link( __('Generate XML file', true), array('action'=>'generateXMLFile','ext'=>'xml')
array('class'=>'button','target'=>'_blank') ); ?>

Which outputs a simple HTML link. 

I have added in Routes:

      Router::parseExtensions('json','xml');

My action: 

function generateXMLFile(){
// Configure::write('debug',0);
// Only XML Requests
if(!$this->RequestHandler->isXml()){
die();

                   }
}


My view:

<response>
<posts>
<Post>
<id>test 234</id>
</Post>
</posts>
</response>

My Layout:

<?php header('Content-type: text/xml');?>
<?php echo $this->Xml->header(); ?>
<?php echo $content_for_layout; ?>


Now when I click the link the XML is sent as output to the screen. Clicking with right mousebutton ->save as.. makes it possible to save the file as XML. 
Headers are correctly set as text/xml

How can i prevent this from outputting to the screen but output it to a file/stream for download ?

thanks 


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Generate XML using controller and force it to sent as download

Still haven't figured this out. Is this at all possible with CakePHP? I can't imagine it would not be possible.

thanks




On Thursday, December 19, 2013 5:16:50 PM UTC+1, Willem wrote:
Hi,

Goal: I have a button on a page. When user clicks it should generate a XML file and make it download (instead of opening in browser window).
Cake version: 1.3

So I create a HTML link like this:

<?php echo $html->link( __('Generate XML file', true), array('action'=>'generateXMLFile','ext'=>'xml')
array('class'=>'button','target'=>'_blank') ); ?>

Which outputs a simple HTML link. 

I have added in Routes:

      Router::parseExtensions('json','xml');

My action: 

function generateXMLFile(){
// Configure::write('debug',0);
// Only XML Requests
if(!$this->RequestHandler->isXml()){
die();

                   }
}


My view:

<response>
<posts>
<Post>
<id>test 234</id>
</Post>
</posts>
</response>

My Layout:

<?php header('Content-type: text/xml');?>
<?php echo $this->Xml->header(); ?>
<?php echo $content_for_layout; ?>


Now when I click the link the XML is sent as output to the screen. Clicking with right mousebutton ->save as.. makes it possible to save the file as XML. 
Headers are correctly set as text/xml

How can i prevent this from outputting to the screen but output it to a file/stream for download ?

thanks 


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

Wednesday, January 1, 2014

Re: Help / Source code for Simple Authentication tutorial


 This error appears at every syntax or logic errors with the Auth component. To fix it, simply track the errors (it can be a semi-colon !)

 Squix

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Ajax update of JpGraph in CakePHP

Beautiful, no need to use ajax with this simple, yet elegant solution. Maybe? Hell yeah!





On Saturday, January 12, 2008 4:44:33 AM UTC-5, majna wrote:
<span id="myimage"><img id="some_id" src="/cake/mycontroller/graph" />
</sapn>

maybe?

On Jan 12, 12:24 am, xerazur <thomas.gubelm...@gmail.com> wrote:
> Hi everyone,
>
> I am currently working on a kind of reporting tool that generates a
> JpGraph chart. This works perfect, but now I want to update the chart
> with an ajax request started from a select element to filter the
> displayed content.
>
> I attached the ajax observer with the following line of code in my
> view report.thtml:
>
> $options = array('url' => 'graph','update' => 'myimage');
> echo $ajax->observeField('selecttag',$options);
>
> <img id="myimage" src="/cake/mycontroller/graph" />
>
> When I now update the select tag, just nothing happens. Updating other
> content than the image with the select tag works perfect , so
> controller and the ajax update procedure should work.
>
> I use CakePHP 1.1.x, JpGraph is called with the normal $graph-
>
> >Stroke() method.
>
> Anyone an idea about a solution for this problem? Thanks!
>
> Tom

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.