Using sessions & tricking Basic Authentication
Boban posted this info about sessions, php and flash in the old forum.
I think I found explanation about sessions problem. This seems to be the Flash Cookie Bug described here:
http://swfupload.org/forum/generaldiscussion/383
There seems to be no solution yet. Flash is reading IE cookies besides it runs from Firefox or other non IE browser. I am not sure if Adobe released a fix for this.
Some more information about Flash upload cookies issue can be found here:
https://bugs.adobe.com/jira/browse/FP-1044
Steps to reproduce:
1. Start a packet capture tool to watch the traffic between browser and remote web server.
2. Start up your Flex application
3. Perform an action which results in Flash performing a request (POST) to a secured resource.
4. Dialogue box pops up, you enter your username + password.
5. Authentication is performed correctly (can also tell by watching packet capture).
6. Do a Filereference.upload within your Flash/Flex application (to a resource secured within the same security realm).
7. Request fails, authentication error.
8. Look at the packet capture.... Flash discarded all cookies and authentication information when doing the file upload.
Conclusion:
Unlike a browser file upload, Flash does not support authenticated file upload.
SOLUTION
In your PHP file which includes .fileUpload, put this:
Within your fileUpload parameters, add this one:
Then in upload.php you can get your session data this way:
BASIC AUTHENTICATION
I don't think you could use this to trick Basic Authentication because this is done with GET method and basic authentication is sent by request headers and checked by your Web server.
You can use two solutions.
1. Continue using Basic Authentication but put upload.php script outside of protected directory and use sessions security like I described above. So, all my multi upload files reside inside protected directory, except upload.php which resides outside of it, but it is protected by sessions.
2. Another way is to authenticate user in PHP and use sessions in all scripts.
I think I found explanation about sessions problem. This seems to be the Flash Cookie Bug described here:
http://swfupload.org/forum/generaldiscussion/383
There seems to be no solution yet. Flash is reading IE cookies besides it runs from Firefox or other non IE browser. I am not sure if Adobe released a fix for this.
Some more information about Flash upload cookies issue can be found here:
https://bugs.adobe.com/jira/browse/FP-1044
Steps to reproduce:
1. Start a packet capture tool to watch the traffic between browser and remote web server.
2. Start up your Flex application
3. Perform an action which results in Flash performing a request (POST) to a secured resource.
4. Dialogue box pops up, you enter your username + password.
5. Authentication is performed correctly (can also tell by watching packet capture).
6. Do a Filereference.upload within your Flash/Flex application (to a resource secured within the same security realm).
7. Request fails, authentication error.
8. Look at the packet capture.... Flash discarded all cookies and authentication information when doing the file upload.
Conclusion:
Unlike a browser file upload, Flash does not support authenticated file upload.
Isn't it time to fix this one. It's been there since Flash 8 when you introduced the feature and this is a major showstopper for usage on sites that require login. The URLStream class doesn't seem to have any of these issues it retains cookies, basic authentication information and works over SSL.
SOLUTION
In your PHP file which includes .fileUpload, put this:
- Code: Select all
session_start();
$_SESSION['mydata'] = 'whatever';
Within your fileUpload parameters, add this one:
- Code: Select all
'scriptData': {'session_name': '<?= session_id(); ?>'}
Then in upload.php you can get your session data this way:
- Code: Select all
session_id($_GET['session_name']);
session_start();
if ($_SESSION['mydata'] != 'whatever') {
header("HTTP/1.0 404 Not Found");
exit;
}
BASIC AUTHENTICATION
I don't think you could use this to trick Basic Authentication because this is done with GET method and basic authentication is sent by request headers and checked by your Web server.
You can use two solutions.
1. Continue using Basic Authentication but put upload.php script outside of protected directory and use sessions security like I described above. So, all my multi upload files reside inside protected directory, except upload.php which resides outside of it, but it is protected by sessions.
2. Another way is to authenticate user in PHP and use sessions in all scripts.