-
-
Notifications
You must be signed in to change notification settings - Fork 17
Refactor Fortify two-factor dependencies #413
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5c0c270
docs: add Fortify OTPHP and chillerlan plan
binaryfire bbd954a
build: update Fortify two-factor dependencies
binaryfire e225306
feat: replace Fortify TOTP engine with OTPHP
binaryfire 00ad4ef
test: expand Fortify TOTP provider coverage
binaryfire b822660
test: cover Fortify TOTP coroutine safety
binaryfire 02c468e
test: update Fortify two-factor HTTP flows for OTPHP
binaryfire a9deecd
feat: render Fortify QR codes with chillerlan
binaryfire 144bd0c
test: cover Fortify QR renderer and update docs
binaryfire 517a733
fix: harden Fortify TOTP replay cache
binaryfire f84751a
test: make Fortify replay cache window explicit
binaryfire 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
920 changes: 920 additions & 0 deletions
920
docs/plans/2026-07-03-fortify-otphp-chillerlan-refactor.md
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,56 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Hypervel\Fortify; | ||
|
|
||
| use chillerlan\QRCode\Common\EccLevel; | ||
| use chillerlan\QRCode\Output\QRMarkupSVG; | ||
| use chillerlan\QRCode\QRCode; | ||
| use chillerlan\QRCode\QROptions; | ||
| use RuntimeException; | ||
|
|
||
| class TwoFactorQrCodeRenderer | ||
| { | ||
| private const string DARK = '#2d3748'; | ||
|
|
||
| private const string LIGHT = '#fff'; | ||
|
|
||
| /** | ||
| * Render the QR code URL as SVG. | ||
| */ | ||
| public function svg(string $url): string | ||
| { | ||
| $svg = (new QRCode(new QROptions([ | ||
| 'addQuietzone' => false, | ||
| 'drawLightModules' => true, | ||
| 'eccLevel' => EccLevel::L, | ||
| 'moduleValues' => $this->moduleValues(), | ||
| 'outputBase64' => false, | ||
| 'outputInterface' => TwoFactorQrCodeSvgOutput::class, | ||
| 'svgUseFillAttributes' => true, | ||
| ])))->render($url); | ||
|
|
||
| if (! is_string($svg)) { | ||
| throw new RuntimeException('Two-factor QR code renderer did not return SVG output.'); | ||
| } | ||
|
|
||
| return trim($svg); | ||
| } | ||
|
|
||
| /** | ||
| * Get the QR module color values. | ||
| * | ||
| * @return array<int, string> | ||
| */ | ||
| private function moduleValues(): array | ||
| { | ||
| $values = []; | ||
|
|
||
| foreach (QRMarkupSVG::DEFAULT_MODULE_VALUES as $module => $isDark) { | ||
| $values[$module] = $isDark ? self::DARK : self::LIGHT; | ||
| } | ||
|
|
||
| return $values; | ||
| } | ||
| } |
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,32 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Hypervel\Fortify; | ||
|
|
||
| use chillerlan\QRCode\Output\QRMarkupSVG; | ||
| use chillerlan\QRCode\QROptions; | ||
|
|
||
| use function sprintf; | ||
|
|
||
| class TwoFactorQrCodeSvgOutput extends QRMarkupSVG | ||
| { | ||
| private const int SIZE = 192; | ||
|
|
||
| /** | ||
| * Return the SVG header. | ||
| */ | ||
| protected function header(): string | ||
| { | ||
| /** @var QROptions $options */ | ||
| $options = $this->options; | ||
|
|
||
| return sprintf( | ||
| '<svg xmlns="http://www.w3.org/2000/svg" width="%d" height="%d" viewBox="%s">%s', | ||
| self::SIZE, | ||
| self::SIZE, | ||
| $this->getViewBox(), | ||
| $options->eol, | ||
| ); | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.