aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/ApplicationUtils.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-10-01 11:02:48 +0200
committerArthurHoaro <arthur@hoa.ro>2017-10-01 11:10:37 +0200
commitbfe4f536bbfe03f38e0c801bfbd26587a2b64a7f (patch)
tree5d5341cb7c72e32b655eca243cc1c33824199b33 /application/ApplicationUtils.php
parenta59bbf50d7530d7e82a91896a210b9da49cb1568 (diff)
downloadShaarli-bfe4f536bbfe03f38e0c801bfbd26587a2b64a7f.tar.gz
Shaarli-bfe4f536bbfe03f38e0c801bfbd26587a2b64a7f.tar.zst
Shaarli-bfe4f536bbfe03f38e0c801bfbd26587a2b64a7f.zip
Add a version hash for asset loading to prevent browser's cache issue
The hash is generated using the same salt as the one used for credentials (1 salt per instance) in order to avoid exposing the instance version. Fixes #965
Diffstat (limited to 'application/ApplicationUtils.php')
-rw-r--r--application/ApplicationUtils.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/application/ApplicationUtils.php b/application/ApplicationUtils.php
index 85dcbeeb..20fec376 100644
--- a/application/ApplicationUtils.php
+++ b/application/ApplicationUtils.php
@@ -220,4 +220,19 @@ class ApplicationUtils
220 220
221 return $errors; 221 return $errors;
222 } 222 }
223
224 /**
225 * Returns a salted hash representing the current Shaarli version.
226 *
227 * Useful for assets browser cache.
228 *
229 * @param string $currentVersion of Shaarli
230 * @param string $salt User personal salt, also used for the authentication
231 *
232 * @return string version hash
233 */
234 public static function getVersionHash($currentVersion, $salt)
235 {
236 return hash_hmac('sha256', $currentVersion, $salt);
237 }
223} 238}