-
Notifications
You must be signed in to change notification settings - Fork 250
feat(FOUR-28542): Authenticator app option still available even the user has already configured it. #9058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rodriquelca
wants to merge
1
commit into
develop
Choose a base branch
from
feature/FOUR-28542
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat(FOUR-28542): Authenticator app option still available even the user has already configured it. #9058
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
database/migrations/2026_09_14_000000_add_auth_app_configured_at_to_users_table.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <?php | ||
|
|
||
| use Illuminate\Database\Migrations\Migration; | ||
| use Illuminate\Database\Schema\Blueprint; | ||
| use Illuminate\Support\Facades\Schema; | ||
|
|
||
| return new class extends Migration | ||
| { | ||
| public function up(): void | ||
| { | ||
| Schema::table('users', function (Blueprint $table) { | ||
| $table->timestamp('auth_app_configured_at')->nullable()->after('preferences_2fa'); | ||
| }); | ||
| } | ||
|
|
||
| public function down(): void | ||
| { | ||
| Schema::table('users', function (Blueprint $table) { | ||
| $table->dropColumn('auth_app_configured_at'); | ||
| }); | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Tests\Feature\Api; | ||
|
|
||
| use ProcessMaker\Models\User; | ||
| use Tests\Feature\Shared\RequestHelper; | ||
| use Tests\TestCase; | ||
|
|
||
| class ResetAuthAppTest extends TestCase | ||
| { | ||
| use RequestHelper; | ||
|
|
||
| public function test_admin_can_reset_authenticator_app_for_a_user(): void | ||
| { | ||
| $targetUser = User::factory()->create([ | ||
| 'auth_app_configured_at' => now(), | ||
| ]); | ||
|
|
||
| $response = $this->apiCall('PUT', route('api.users.reset_auth_app', $targetUser)); | ||
|
|
||
| $response->assertStatus(200); | ||
| $this->assertNull($targetUser->fresh()->auth_app_configured_at); | ||
| } | ||
|
|
||
| public function test_reset_returns_error_when_authenticator_is_not_configured(): void | ||
| { | ||
| $targetUser = User::factory()->create([ | ||
| 'auth_app_configured_at' => null, | ||
| ]); | ||
|
|
||
| $response = $this->apiCall('PUT', route('api.users.reset_auth_app', $targetUser)); | ||
|
|
||
| $response->assertStatus(422); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Tests\Feature\Auth; | ||
|
|
||
| use OTPHP\TOTP; | ||
| use ParagonIE\ConstantTime\Base32; | ||
| use ProcessMaker\Models\User; | ||
| use ProcessMaker\TwoFactorAuthentication; | ||
| use Tests\Feature\Shared\RequestHelper; | ||
| use Tests\TestCase; | ||
|
|
||
| class TwoFactorAuthAppTest extends TestCase | ||
| { | ||
| use RequestHelper { | ||
| setUp as requestHelperSetUp; | ||
| } | ||
|
|
||
| protected function setUp(): void | ||
| { | ||
| $this->requestHelperSetUp(); | ||
|
|
||
| config([ | ||
| 'password-policies.2fa_enabled' => true, | ||
| 'password-policies.2fa_method' => [TwoFactorAuthentication::AUTH_APP], | ||
| ]); | ||
| } | ||
|
|
||
| public function test_otp_shows_authenticator_link_before_setup(): void | ||
| { | ||
| $this->user->update(['auth_app_configured_at' => null]); | ||
|
|
||
| $response = $this->webGet(route('2fa')); | ||
|
|
||
| $response->assertStatus(200); | ||
| $response->assertSee('Authenticator app', false); | ||
| } | ||
|
|
||
| public function test_otp_hides_authenticator_link_after_setup(): void | ||
| { | ||
| $this->user->update(['auth_app_configured_at' => now()]); | ||
|
|
||
| $response = $this->webGet(route('2fa')); | ||
|
|
||
| $response->assertStatus(200); | ||
| $response->assertDontSee('>Authenticator app<', false); | ||
| } | ||
|
|
||
| public function test_auth_app_qr_is_blocked_after_setup(): void | ||
| { | ||
| $this->user->update(['auth_app_configured_at' => now()]); | ||
|
|
||
| $response = $this->webGet(route('2fa.auth_app_qr')); | ||
|
|
||
| $response->assertRedirect(route('2fa')); | ||
| } | ||
|
|
||
| public function test_valid_auth_app_code_marks_user_as_configured(): void | ||
| { | ||
| $this->user->update(['auth_app_configured_at' => null]); | ||
|
|
||
| $code = $this->generateAuthAppCode($this->user); | ||
|
|
||
| $response = $this->webCall('POST', route('2fa.validate'), ['code' => $code]); | ||
|
|
||
| $response->assertRedirect(route('login')); | ||
| $this->assertNotNull($this->user->fresh()->auth_app_configured_at); | ||
| } | ||
|
|
||
| private function generateAuthAppCode(User $user): string | ||
| { | ||
| $secret = trim(Base32::encodeUpper($user->uuid . '_' . $user->username), '='); | ||
| $otp = TOTP::createFromSecret($secret); | ||
| $otp->setIssuer('ProcessMaker'); | ||
| $otp->setLabel($user->username); | ||
|
|
||
| return $otp->now(); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Username change locks authenticator users
High Severity
userCanSetUpAuthApphides QR setup onceauth_app_configured_atis set, but the TOTP secret is derived fromusername. A username change invalidates existing codes and leavesauth_app_configured_atset, so users with only Authenticator App cannot re-enroll. Self-service profile updates allow username changes, and reset is admin-only, so those users cannot recover on their own.Additional Locations (2)
ProcessMaker/Http/Controllers/Auth/TwoFactorAuthController.php#L93-L96ProcessMaker/Models/User.php#L554-L558Reviewed by Cursor Bugbot for commit 72809c4. Configure here.