@@ -51,7 +51,7 @@ location ^~ /files/ {
51
51
secure_link_hmac_secret my_secret_key;
52
52
53
53
# Message to be verified
54
- secure_link_hmac_message $uri$arg_ts$arg_e;
54
+ secure_link_hmac_message $uri| $arg_ts| $arg_e;
55
55
56
56
# Cryptographic hash function to be used
57
57
secure_link_hmac_algorithm sha256;
@@ -88,7 +88,7 @@ perl_set $secure_token '
88
88
my $timestamp = strftime("%Y-%m-%dT%H:%M:%S", localtime($now)) . $tz;
89
89
my $r = shift;
90
90
my $data = $r->uri;
91
- my $digest = hmac_sha256_base64($data . $timestamp . $expire, $key);
91
+ my $digest = hmac_sha256_base64($data . "|" . $timestamp . "|" . $expire, $key);
92
92
$digest =~ tr(+/)(-_);
93
93
$data = "st=" . $digest . "&ts=" . $timestamp . "&e=" . $expire;
94
94
return $data;
@@ -103,7 +103,7 @@ $secret = 'my_very_secret_key';
103
103
$expire = 60;
104
104
$algo = 'sha256';
105
105
$timestamp = date('c');
106
- $stringtosign = "/files/top_secret.pdf{$timestamp}{$expire}";
106
+ $stringtosign = "/files/top_secret.pdf| {$timestamp}| {$expire}";
107
107
$hashmac = base64_encode(hash_hmac($algo, $stringtosign, $secret, true));
108
108
$hashmac = strtr($hashmac, '+/', '-_'));
109
109
$hashmac = str_replace('=', '', $hashmac);
@@ -118,7 +118,7 @@ const crypto = require("crypto");
118
118
const secret = ' my_very_secret_key' ;
119
119
const expire = 60 ;
120
120
const unixTimestamp = Math .round (Date .now () / 1000. );
121
- const stringToSign = ` /files/top_secret.pdf${ unixTimestamp}${ expire} ` ;
121
+ const stringToSign = ` /files/top_secret.pdf| ${ unixTimestamp} | ${ expire} ` ;
122
122
const hashmac = crypto .createHmac (' sha256' , secret).update (stringToSign).digest (' base64' )
123
123
.replace (/ =/ g , ' ' )
124
124
.replace (/ \+ / g , ' -' )
@@ -134,7 +134,7 @@ The string to be signed is defined in `secure_link_hmac_message`, the `secure_li
134
134
location ^~ /backend_location/ {
135
135
set $expire 60;
136
136
137
- secure_link_hmac_message "$uri$time_iso8601$expire";
137
+ secure_link_hmac_message "$uri| $time_iso8601| $expire";
138
138
secure_link_hmac_secret "my_very_secret_key";
139
139
secure_link_hmac_algorithm sha256;
140
140
0 commit comments