Skip to content

Commit 76f420e

Browse files
committed
add SensitiveParameter to sensitive arguments
This change adds the PHP attribute SensitiveParameter to the secret holding variables. See: https://www.php.net/manual/en/class.sensitiveparameter This feature is only available in PHP 8.2, so the minimum php version required has been updated. Github Actions now use PHP 8.2 and 8.3 for the tests. The checkout action has been updated to v4, too. Fix issue #118
1 parent ab93dd4 commit 76f420e

File tree

8 files changed

+24
-12
lines changed

8 files changed

+24
-12
lines changed

.github/workflows/test-bacon.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010

1111
strategy:
1212
matrix:
13-
php-version: ['8.1', '8.2']
13+
php-version: ['8.2', '8.3']
1414

1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717

1818
- uses: shivammathur/setup-php@v2
1919
with:

.github/workflows/test-endroid.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ jobs:
1010

1111
strategy:
1212
matrix:
13-
php-version: ['8.1', '8.2']
13+
php-version: ['8.2', '8.3']
1414
endroid-version: ["^3","^4","^5"]
1515

1616
steps:
17-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
1818

1919
- uses: shivammathur/setup-php@v2
2020
with:

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010

1111
strategy:
1212
matrix:
13-
php-version: ['8.1', '8.2']
13+
php-version: ['8.2', '8.3']
1414

1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717

1818
- uses: shivammathur/setup-php@v2
1919
with:

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# RobThree\TwoFactorAuth changelog
22

3+
# Version 3.x
4+
5+
## Breaking changes
6+
7+
### PHP Version
8+
9+
Version 3.x requires at least PHP 8.2.
10+
11+
### Add SensitiveParameter
12+
13+
The new attribute SensitiveParameter was added to the code, to prevent accidental leak of secrets in stack traces.
14+
315
# Version 2.x
416

517
## Breaking changes

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ You can make use of the included [Endroid](https://robthree.github.io/TwoFactorA
1717

1818
## Requirements
1919

20-
* Requires PHP version >=8.1
20+
* Requires PHP version >=8.2
2121
* [cURL](http://php.net/manual/en/book.curl.php) when using the provided `QRServerProvider` (default), `ImageChartsQRCodeProvider` or `QRicketProvider` but you can also provide your own QR-code provider.
2222
* [random_bytes()](http://php.net/manual/en/function.random-bytes.php), [OpenSSL](http://php.net/manual/en/book.openssl.php) or [Hash](http://php.net/manual/en/book.hash.php) depending on which built-in RNG you use (TwoFactorAuth will try to 'autodetect' and use the best available); however: feel free to provide your own (CS)RNG.
2323

TwoFactorAuth.phpproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<PHPDevHostName>localhost</PHPDevHostName>
1616
<IISProjectUrl>http://localhost:41315/</IISProjectUrl>
1717
<Runtime>PHP</Runtime>
18-
<RuntimeVersion>8.1</RuntimeVersion>
18+
<RuntimeVersion>8.2</RuntimeVersion>
1919
</PropertyGroup>
2020
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
2121
<IncludeDebugInformation>true</IncludeDebugInformation>

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"source": "https://github.com/RobThree/TwoFactorAuth"
2828
},
2929
"require": {
30-
"php": ">=8.1.0"
30+
"php": ">=8.2.0"
3131
},
3232
"require-dev": {
3333
"phpunit/phpunit": "^9",

lib/TwoFactorAuth.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function createSecret(int $bits = 80, bool $requirecryptosecure = true):
6969
/**
7070
* Calculate the code with given secret and point in time
7171
*/
72-
public function getCode(string $secret, ?int $time = null): string
72+
public function getCode(#[\SensitiveParameter] string $secret, ?int $time = null): string
7373
{
7474
$secretkey = $this->base32Decode($secret);
7575

@@ -107,7 +107,7 @@ public function verifyCode(string $secret, string $code, int $discrepancy = 1, ?
107107
/**
108108
* Get data-uri of QRCode
109109
*/
110-
public function getQRCodeImageAsDataUri(string $label, string $secret, int $size = 200): string
110+
public function getQRCodeImageAsDataUri(string $label, #[\SensitiveParameter] string $secret, int $size = 200): string
111111
{
112112
if ($size <= 0) {
113113
throw new TwoFactorAuthException('Size must be > 0');
@@ -153,7 +153,7 @@ public function ensureCorrectTime(?array $timeproviders = null, int $leniency =
153153
/**
154154
* Builds a string to be encoded in a QR code
155155
*/
156-
public function getQRText(string $label, string $secret): string
156+
public function getQRText(string $label, #[\SensitiveParameter] string $secret): string
157157
{
158158
return 'otpauth://totp/' . rawurlencode($label)
159159
. '?secret=' . rawurlencode($secret)

0 commit comments

Comments
 (0)