Skip to content

Commit

Permalink
Merge pull request #45 from oneflow/chore/use-sha256
Browse files Browse the repository at this point in the history
Set SHA256 as default cypher
  • Loading branch information
juanjoseruiz authored Mar 28, 2023
2 parents 39960d9 + 715990d commit 2cf7834
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion samples/retry-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

//SETUP THE SDK
$client = new OneflowSDK(
'http://localhost:3000/api',
'https://localhost:3000/api',
'API_TOKEN_HERE',
'API_SECRET_HERE',
(object)['retries' => 2, 'retryDelay' => $retryDelay, 'retryCondition' => $retryCondition]
Expand Down
3 changes: 2 additions & 1 deletion src/OneflowSDK.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ public function request($method, $path, $jsonData=null, $optional_headers = null
}

$params['http']['header'][] = "x-oneflow-date: $timestamp";
$params['http']['header'][] = "x-oneflow-algorithm: SHA256";
$params['http']['header'][] = $this->authHeader.": ".$this->token($method, $fullPath, $timestamp);

foreach ($optional_headers as $name => $value) {
Expand Down Expand Up @@ -431,7 +432,7 @@ protected function post_file_s3($uploadUrl, $localPath) {
*/
private function token($method, $path, $timestamp){
$stringToSign = strtoupper($method) . ' ' . $path . ' ' . $timestamp;
return $this->key . ':' . hash_hmac('sha1', $stringToSign, $this->secret);
return $this->key . ':' . hash_hmac('sha256', $stringToSign, $this->secret);
}

/**
Expand Down

0 comments on commit 2cf7834

Please sign in to comment.