summaryrefslogtreecommitdiffstats
path: root/lib/private/Security/CSRF/CsrfToken.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-03-05 15:01:02 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2018-03-05 15:01:02 +0100
commit2c8402aa170d445c549f0409325730e780eb4764 (patch)
tree7b752977ca39ff152f7ad48f5f4939984b4bf5b5 /lib/private/Security/CSRF/CsrfToken.php
parentc85c64c787057afac7000c0c24a7b791f4788c55 (diff)
downloadnextcloud-server-2c8402aa170d445c549f0409325730e780eb4764.tar.gz
nextcloud-server-2c8402aa170d445c549f0409325730e780eb4764.zip
Make \OC\Security\CSRF strict
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Security/CSRF/CsrfToken.php')
-rw-r--r--lib/private/Security/CSRF/CsrfToken.php11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/private/Security/CSRF/CsrfToken.php b/lib/private/Security/CSRF/CsrfToken.php
index d9e27ff80e3..643e58e1d53 100644
--- a/lib/private/Security/CSRF/CsrfToken.php
+++ b/lib/private/Security/CSRF/CsrfToken.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -40,7 +41,7 @@ class CsrfToken {
/**
* @param string $value Value of the token. Can be encrypted or not encrypted.
*/
- public function __construct($value) {
+ public function __construct(string $value) {
$this->value = $value;
}
@@ -50,9 +51,9 @@ class CsrfToken {
*
* @return string
*/
- public function getEncryptedValue() {
+ public function getEncryptedValue(): string {
if($this->encryptedValue === '') {
- $sharedSecret = random_bytes(strlen($this->value));
+ $sharedSecret = random_bytes(\strlen($this->value));
$this->encryptedValue = base64_encode($this->value ^ $sharedSecret) . ':' . base64_encode($sharedSecret);
}
@@ -65,9 +66,9 @@ class CsrfToken {
*
* @return string
*/
- public function getDecryptedValue() {
+ public function getDecryptedValue(): string {
$token = explode(':', $this->value);
- if (count($token) !== 2) {
+ if (\count($token) !== 2) {
return '';
}
$obfuscatedToken = $token[0];