Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 1... Línea 1...
1
<?php
1
<?php
2
namespace Aws\Signature;
2
namespace Aws\Signature;
Línea 3... Línea 3...
3
 
3
 
-
 
4
use Aws\Credentials\CredentialsInterface;
-
 
5
use AWS\CRT\Auth\SignatureType;
-
 
6
use AWS\CRT\Auth\SigningAlgorithm;
4
use Aws\Credentials\CredentialsInterface;
7
use AWS\CRT\Auth\SigningConfigAWS;
Línea 5... Línea 8...
5
use Psr\Http\Message\RequestInterface;
8
use Psr\Http\Message\RequestInterface;
6
 
9
 
7
/**
10
/**
Línea 40... Línea 43...
40
        $signingService = $signingService ?: 's3';
43
        $signingService = $signingService ?: 's3';
41
        return $this->signWithV4a($credentials, $request, $signingService);
44
        return $this->signWithV4a($credentials, $request, $signingService);
42
    }
45
    }
Línea 43... Línea 46...
43
 
46
 
-
 
47
    /**
-
 
48
     * @param CredentialsInterface $credentials
-
 
49
     * @param RequestInterface $request
-
 
50
     * @param $signingService
-
 
51
     * @param SigningConfigAWS|null $signingConfig
-
 
52
     * @return RequestInterface
-
 
53
     *
-
 
54
     * Instantiates a separate sigv4a signing config.  All services except S3
-
 
55
     * use double encoding.  All services except S3 require path normalization.
-
 
56
     */
-
 
57
    protected function signWithV4a(
-
 
58
        CredentialsInterface $credentials,
-
 
59
        RequestInterface $request,
-
 
60
        $signingService,
-
 
61
        ?SigningConfigAWS $signingConfig = null
-
 
62
    ){
-
 
63
        $this->verifyCRTLoaded();
-
 
64
        $credentials_provider = $this->createCRTStaticCredentialsProvider($credentials);
-
 
65
        $signingConfig = new SigningConfigAWS([
-
 
66
            'algorithm' => SigningAlgorithm::SIGv4_ASYMMETRIC,
-
 
67
            'signature_type' => SignatureType::HTTP_REQUEST_HEADERS,
-
 
68
            'credentials_provider' => $credentials_provider,
-
 
69
            'signed_body_value' => $this->getPayload($request),
-
 
70
            'region' => $this->region,
-
 
71
            'should_normalize_uri_path' => false,
-
 
72
            'use_double_uri_encode' => false,
-
 
73
            'service' => $signingService,
-
 
74
            'date' => time(),
-
 
75
        ]);
-
 
76
 
-
 
77
        return parent::signWithV4a($credentials, $request, $signingService, $signingConfig);
-
 
78
    }
-
 
79
 
44
    /**
80
    /**
45
     * Always add a x-amz-content-sha-256 for data integrity.
81
     * Always add a x-amz-content-sha-256 for data integrity.
46
     *
82
     *
47
     * {@inheritdoc}
83
     * {@inheritdoc}
48
     */
84
     */
Línea 56... Línea 92...
56
            $request = $request->withHeader(
92
            $request = $request->withHeader(
57
                'X-Amz-Content-Sha256',
93
                'X-Amz-Content-Sha256',
58
                $this->getPresignedPayload($request)
94
                $this->getPresignedPayload($request)
59
            );
95
            );
60
        }
96
        }
-
 
97
 
61
        if (strpos($request->getUri()->getHost(), "accesspoint.s3-global")) {
98
        if (strpos($request->getUri()->getHost(), "accesspoint.s3-global")) {
62
            $request = $request->withHeader("x-amz-region-set", "*");
99
            $request = $request->withHeader("x-amz-region-set", "*");
63
        }
100
        }
Línea 64... Línea 101...
64
 
101