mercredi 30 septembre 2015

AWS & PHP - Tokenising URLs

I try to protect my url with the token system, I followed this tutorial https://www.youtube.com/watch?v=8s2vvKqybms but I don't know why my URLS doesn't change, I have the original URL instead of the signed URL (so I have an denied access).

My start.php:

<?php

use Aws\S3\S3Client;
use Aws\Credentials\CredentialProvider;

require 'vendor/autoload.php';

$config = require('config.php');

// S3

$s3 = S3Client::factory([
    'key' => $config['s3']['key'],
    'secret' => $config['s3']['secret'],
    'region'  => 'us-west-2',
    'version' => 'latest',
    'credentials' => CredentialProvider::ini('default', '/home/-/.aws/creditentials')
]);

Config.php :

<?php

return [
    's3' => [
        'key' => '-',
        'secret' => '-',
        'bucket' => '-',
    ]
];

And my token.php:

<?php


require 'app/start.php';

$object = 'uploads/movieinfo.tbz2';

$url = $s3->getObjectUrl($config['s3']['bucket'], $object, '5 minutes');

?>

<!DOCTYPE html>
<html>
<head>
    <title>Token</title>
</head>
<body>
    <a href="<?php echo $url; ?>">Download</a>
</body>
</html>

I deleted all permissions on the file, it have the padlock. Do you know what's wrong ?

Thank you




Aucun commentaire:

Enregistrer un commentaire