Skip to content

Commit b909cb3

Browse files
authored
Merge pull request #119 from NicolasCARPi/nico-sensitive-attr
Add SensitiveParameter to sensitive arguments
2 parents ecef270 + e08b0a5 commit b909cb3

File tree

7 files changed

+24
-11
lines changed

7 files changed

+24
-11
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+
## Other changes
12+
13+
* The new PHP attribute [SensitiveParameter](https://www.php.net/manual/en/class.sensitiveparameter.php) 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

2323
Optionally, you may need:

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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use RobThree\Auth\Providers\Time\ITimeProvider;
1515
use RobThree\Auth\Providers\Time\LocalMachineTimeProvider;
1616
use RobThree\Auth\Providers\Time\NTPTimeProvider;
17+
use SensitiveParameter;
1718

1819
// Based on / inspired by: https://github.com/PHPGangsta/GoogleAuthenticator
1920
// Algorithms, digits, period etc. explained: https://github.com/google/google-authenticator/wiki/Key-Uri-Format
@@ -66,7 +67,7 @@ public function createSecret(int $bits = 80): string
6667
/**
6768
* Calculate the code with given secret and point in time
6869
*/
69-
public function getCode(string $secret, ?int $time = null): string
70+
public function getCode(#[SensitiveParameter] string $secret, ?int $time = null): string
7071
{
7172
$secretkey = $this->base32Decode($secret);
7273

@@ -104,7 +105,7 @@ public function verifyCode(string $secret, string $code, int $discrepancy = 1, ?
104105
/**
105106
* Get data-uri of QRCode
106107
*/
107-
public function getQRCodeImageAsDataUri(string $label, string $secret, int $size = 200): string
108+
public function getQRCodeImageAsDataUri(string $label, #[SensitiveParameter] string $secret, int $size = 200): string
108109
{
109110
if ($size <= 0) {
110111
throw new TwoFactorAuthException('Size must be > 0');
@@ -150,7 +151,7 @@ public function ensureCorrectTime(?array $timeproviders = null, int $leniency =
150151
/**
151152
* Builds a string to be encoded in a QR code
152153
*/
153-
public function getQRText(string $label, string $secret): string
154+
public function getQRText(string $label, #[SensitiveParameter] string $secret): string
154155
{
155156
return 'otpauth://totp/' . rawurlencode($label)
156157
. '?secret=' . rawurlencode($secret)

0 commit comments

Comments
 (0)