Skip to content

Commit

Permalink
access cannot contains spaces
Browse files Browse the repository at this point in the history
I think, you should specify in your implementation that access key cannot contains spaces; See first explode in class function

    /**
     * @param $headerContent
     * @param $algoPrefix
     * @return array
     * @throws EscherException
     */
    public static function parseAuthHeader($headerContent, $algoPrefix)
    {
        $parts = explode(' ', $headerContent);
        if (count($parts) !== 4) {
            throw new EscherException('Could not parse authorization header: ' . $headerContent);
        }
        return array(
            'Algorithm'     => self::match(self::algoPattern($algoPrefix),    $parts[0]),
            'Credentials'   => self::match('Credential=([A-Za-z0-9\/\-_]+),', $parts[1]),
            'SignedHeaders' => self::match('SignedHeaders=([A-Za-z\-;]+),',   $parts[2]),
            'Signature'     => self::match('Signature=([0-9a-f]+)',           $parts[3]),
        );
    }
  • Loading branch information
FallDi committed Jul 16, 2015
1 parent aadc7a0 commit 7351ba4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Let's say you want to send a signed POST request to http://example.com/ using th
$yourHeaders = array('Content-Type' => 'application/json');

$headersWithAuthInfo = Escher::create('example/credential/scope')
->signRequest('YOUR ACCESS KEY ID', 'YOUR SECRET', $method, $url, $requestBody, $yourHeaders);
->signRequest('YOUR_ACCESS_KEY_ID', 'YOUR SECRET', $method, $url, $requestBody, $yourHeaders);

$client = new GuzzleHttp\Client();
$response = $client->post($url, array(
Expand All @@ -36,7 +36,7 @@ In some cases you may want to send authenticated requests from a context where y
You can however generate a presigned URL, where the authentication information is added to the query string.

$presignedUrl = Escher::create('example/credential/scope')
->presignUrl('YOUR ACCESS KEY ID', 'YOUR SECRET', 'http://example.com');
->presignUrl('YOUR_ACCESS_KEY_ID', 'YOUR SECRET', 'http://example.com');


Validating a request
Expand All @@ -47,8 +47,8 @@ Escher accepts any kind of object as a key database that implements the ArrayAcc

try {
$keyDB = new ArrayObject(array(
'ACCESS KEY OF CLIENT 1' => 'SECRET OF CLIENT 1',
'ACCESS KEY OF CLIENT 42' => 'SECRET OF CLIENT 42',
'ACCESS_KEY_OF_CLIENT_1' => 'SECRET OF CLIENT 1',
'ACCESS_KEY_OF_CLIENT_42' => 'SECRET OF CLIENT 42',
));
Escher::create('example/credential/scope')->validateRequest($keyDB);
} catch (EscherException $ex) {
Expand Down

0 comments on commit 7351ba4

Please sign in to comment.