Merge hotfixes for v3.4.2 into dev

This commit is contained in:
Bubka 2023-01-25 13:37:25 +01:00
commit 05eafe51ac
5 changed files with 20 additions and 9 deletions

View File

@ -66,12 +66,13 @@ private function isGoogleAuth(string $migrationPayload) : bool
*/
private function isPlainText(string $migrationPayload) : bool
{
// - Plain text : one or more otpauth URIs (otpauth://[t|h]otp/...), one per line
// - Plain text : one or more otpauth URIs (otpauth://(hotp|totp|steam)/...), one per line
return Validator::make(
preg_split('~\R~', $migrationPayload, -1, PREG_SPLIT_NO_EMPTY),
[
'*' => 'regex:/^otpauth:\/\/[h,t]otp\//i',
// The regex rule must be embraced with brackets when it cointains a pipe
'*' => ['regex:/^otpauth:\/\/(?:steam|totp|hotp)\//i'],
]
)->passes();
}

View File

@ -394,8 +394,9 @@ public function fillWithURI(string $uri, bool $isSteamTotp = false, bool $skipIc
{
// First we instanciate the OTP generator
try {
$this->generator = Factory::loadFromProvisioningUri($uri);
} catch (\Assert\AssertionFailedException | \Assert\InvalidArgumentException | \Exception | \Throwable $ex) {
$this->generator = Factory::loadFromProvisioningUri($isSteamTotp ? str_replace('otpauth://steam', 'otpauth://totp', $uri) : $uri);
}
catch (\Assert\AssertionFailedException|\Assert\InvalidArgumentException|\Exception|\Throwable $ex) {
throw ValidationException::withMessages([
'uri' => __('validation.custom.uri.regex', ['attribute' => 'uri']),
]);
@ -459,6 +460,7 @@ public function equals(self $other) : bool
private function enforceAsSteam() : void
{
$this->otp_type = self::STEAM_TOTP;
$this->service = 'Steam';
$this->digits = 5;
$this->algorithm = self::SHA1;
$this->period = 30;

View File

@ -21,7 +21,7 @@ public function migrate(mixed $migrationPayload) : Collection
{
$otpauthURIs = preg_split('~\R~', $migrationPayload);
$otpauthURIs = Arr::where($otpauthURIs, function ($value, $key) {
return Str::startsWith($value, ['otpauth://totp/', 'otpauth://hotp/']);
return Str::startsWith($value, ['otpauth://totp/', 'otpauth://hotp/', 'otpauth://steam/']);
});
if (count($otpauthURIs) < 1) {
@ -31,9 +31,11 @@ public function migrate(mixed $migrationPayload) : Collection
foreach ($otpauthURIs as $key => $uri) {
try {
$twofaccounts[$key] = new TwoFAccount;
$twofaccounts[$key]->fillWithURI($uri);
} catch (\Exception $exception) {
$twofaccounts[$key] = new TwoFAccount;
$twofaccounts[$key]->fillWithURI($uri, str_starts_with($uri, 'otpauth://steam/'));
}
catch (\Exception $exception) {
Log::error(sprintf('Cannot instanciate a TwoFAccount object with OTP parameters from imported item #%s', $key));
Log::debug($exception->getMessage());

View File

@ -1,5 +1,11 @@
# Change log
## [3.4.2] - 2023-01-25
### Fixed
- [issue #160](https://github.com/Bubka/2FAuth/issues/160) Steam otpauth URI from Aegis are rejected by the Import feature
## [3.4.1] - 2022-11-25
### Fixed

View File

@ -9,7 +9,7 @@
|
*/
'version' => '3.4.1',
'version' => '3.4.2',
'repository' => 'https://github.com/Bubka/2FAuth',
'latestReleaseUrl' => 'https://api.github.com/repos/Bubka/2FAuth/releases/latest',