diff --git a/composer.json b/composer.json index 0677c1d6..6c8e654f 100644 --- a/composer.json +++ b/composer.json @@ -69,7 +69,8 @@ "twig/inky-extra": "^3.0", "twig/intl-extra": "^3.0", "twig/markdown-extra": "^3.0", - "webmozart/assert": "^1.4" + "webmozart/assert": "^1.4", + "r/u2f-two-factor-bundle": "dev-scheb/2fa-support" }, "require-dev": { "dama/doctrine-test-bundle": "^7.0", @@ -141,5 +142,11 @@ "allow-contrib": false, "require": "5.4.*" } - } + }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/jbtronics/u2f-two-factor-bundle.git" + } + ] } diff --git a/composer.lock b/composer.lock index aca969d3..430d25ac 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5c3b75839d72914eca2152da433507d8", + "content-hash": "186080614c26d1b307fd99823f281e22", "packages": [ { "name": "beberlei/assert", @@ -4760,6 +4760,72 @@ }, "time": "2017-10-23T01:57:42+00:00" }, + { + "name": "r/u2f-two-factor-bundle", + "version": "dev-scheb/2fa-support", + "source": { + "type": "git", + "url": "https://github.com/jbtronics/u2f-two-factor-bundle.git", + "reference": "3ba2d95de56a8ded97c841bbfac159f4350dbfdf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jbtronics/u2f-two-factor-bundle/zipball/3ba2d95de56a8ded97c841bbfac159f4350dbfdf", + "reference": "3ba2d95de56a8ded97c841bbfac159f4350dbfdf", + "shasum": "" + }, + "require": { + "doctrine/collections": "^1.6", + "doctrine/common": "*", + "ext-json": "*", + "php": "^7.1.3|^8.0", + "scheb/2fa-bundle": "^5.0.0|^6.0.0", + "symfony/event-dispatcher-contracts": "^2.0", + "symfony/framework-bundle": "^5.0|^6.0", + "symfony/templating": "^5.0|^6.0", + "yubico/u2flib-server": "^1.0.0" + }, + "conflict": { + "godzillante/u2f-two-factor-bundle": "*", + "tubssz/u2f-two-factor-bundle": "*" + }, + "require-dev": { + "phpstan/phpstan": "^1.8.2" + }, + "type": "symfony-bundle", + "autoload": { + "psr-4": { + "R\\U2FTwoFactorBundle\\": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Uliczka", + "email": "nils.uliczka@darookee.net" + }, + { + "name": "Francesco De Francesco", + "email": "francesco.defrancesco@gmail.com" + } + ], + "description": "Use U2F-Keys as 2FA for Symfony2, using scheb/two-factor-bundle", + "homepage": "https://github.com/darookee/u2f-two-factor-bundle", + "keywords": [ + "authentication", + "fido", + "symfony2", + "two-factor", + "two-step", + "yubikey" + ], + "support": { + "source": "https://github.com/jbtronics/u2f-two-factor-bundle/tree/scheb/2fa-support" + }, + "time": "2022-08-13T22:31:11+00:00" + }, { "name": "s9e/regexp-builder", "version": "1.4.6", @@ -9955,6 +10021,74 @@ ], "time": "2022-07-24T16:15:25+00:00" }, + { + "name": "symfony/templating", + "version": "v5.4.11", + "source": { + "type": "git", + "url": "https://github.com/symfony/templating.git", + "reference": "3933eaad08c7f83672c53f635d7c3988252a658a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/templating/zipball/3933eaad08c7f83672c53f635d7c3988252a658a", + "reference": "3933eaad08c7f83672c53f635d7c3988252a658a", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8" + }, + "require-dev": { + "psr/log": "^1|^2|^3" + }, + "suggest": { + "psr/log-implementation": "For using debug logging in loaders" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Templating\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides all the tools needed to build any kind of template system", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/templating/tree/v5.4.11" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-06-27T16:58:25+00:00" + }, { "name": "symfony/translation", "version": "v5.4.11", @@ -11936,6 +12070,48 @@ "source": "https://github.com/webmozarts/assert/tree/1.11.0" }, "time": "2022-06-03T18:03:27+00:00" + }, + { + "name": "yubico/u2flib-server", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/Yubico/php-u2flib-server.git", + "reference": "55d813acf68212ad2cadecde07551600d6971939" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Yubico/php-u2flib-server/zipball/55d813acf68212ad2cadecde07551600d6971939", + "reference": "55d813acf68212ad2cadecde07551600d6971939", + "shasum": "" + }, + "require": { + "ext-openssl": "*", + "paragonie/random_compat": ">= 1", + "php": ">=5.6" + }, + "require-dev": { + "phpunit/phpunit": "~5.7", + "vimeo/psalm": "^0|^1|^2" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "description": "Library for U2F implementation", + "homepage": "https://developers.yubico.com/php-u2flib-server", + "support": { + "issues": "https://github.com/Yubico/php-u2flib-server/issues", + "source": "https://github.com/Yubico/php-u2flib-server/tree/1.0.2" + }, + "abandoned": true, + "time": "2018-09-07T08:16:44+00:00" } ], "packages-dev": [ @@ -14449,6 +14625,7 @@ "minimum-stability": "stable", "stability-flags": { "florianv/swap-bundle": 20, + "r/u2f-two-factor-bundle": 20, "roave/security-advisories": 20 }, "prefer-stable": false, diff --git a/config/bundles.php b/config/bundles.php index 29a988c6..f08122e3 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -24,4 +24,5 @@ return [ Nelmio\SecurityBundle\NelmioSecurityBundle::class => ['all' => true], Symfony\UX\Turbo\TurboBundle::class => ['all' => true], Scheb\TwoFactorBundle\SchebTwoFactorBundle::class => ['all' => true], + R\U2FTwoFactorBundle\RU2FTwoFactorBundle::class => ['all' => true], ]; diff --git a/config/packages/r_u2f_two_factor.yaml b/config/packages/r_u2f_two_factor.yaml index 9aa2cd2e..d3b962b2 100644 --- a/config/packages/r_u2f_two_factor.yaml +++ b/config/packages/r_u2f_two_factor.yaml @@ -1,4 +1,4 @@ -#ru2_f_two_factor: -# formTemplate: "/security/U2F/u2f_login.html.twig" -# registerTemplate: "/security/U2F/u2f_register.html.twig" -# authCodeParameter: _auth_code \ No newline at end of file +ru2_f_two_factor: + formTemplate: "/security/U2F/u2f_login.html.twig" + registerTemplate: "/security/U2F/u2f_register.html.twig" + authCodeParameter: _auth_code \ No newline at end of file diff --git a/config/packages/scheb_2fa.yaml b/config/packages/scheb_2fa.yaml index 41aaee25..9ba0ed41 100644 --- a/config/packages/scheb_2fa.yaml +++ b/config/packages/scheb_2fa.yaml @@ -2,14 +2,23 @@ scheb_two_factor: google: - enabled: true + enabled: true # If Google Authenticator should be enabled, default false + server_name: '%partdb.title%' # Server name used in QR code + issuer: 'Part-DB' # Issuer name used in QR code + digits: 6 # Number of digits in authentication code + window: 1 # How many codes before/after the current one would be accepted as valid template: security/2fa_form.html.twig backup_codes: - enabled: true + enabled: true # If the backup code feature should be enabled trusted_device: - enabled: true + enabled: true # If the trusted device feature should be enabled + lifetime: 5184000 # Lifetime of the trusted device token + extend_lifetime: false # Automatically extend lifetime of the trusted cookie on re-login + cookie_name: trusted_device # Name of the trusted device cookie + cookie_secure: false # Set the 'Secure' (HTTPS Only) flag on the trusted device cookie + cookie_same_site: "lax" # The same-site option of the cookie, can be "lax" or "strict" security_tokens: - Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken diff --git a/config/routes/scheb_2fa.yaml b/config/routes/scheb_2fa.yaml index 17f89595..c0b47b5e 100644 --- a/config/routes/scheb_2fa.yaml +++ b/config/routes/scheb_2fa.yaml @@ -5,3 +5,7 @@ 2fa_login_check: path: /{_locale}/2fa_check + +r_u2f_register: + resource: "@RU2FTwoFactorBundle/Resources/config/routing.yml" + prefix: /{_locale}/user \ No newline at end of file diff --git a/src/Entity/UserSystem/U2FKey.php b/src/Entity/UserSystem/U2FKey.php index f3e7662c..000c062b 100644 --- a/src/Entity/UserSystem/U2FKey.php +++ b/src/Entity/UserSystem/U2FKey.php @@ -56,7 +56,7 @@ use u2flib_server\Registration; * }) * @ORM\HasLifecycleCallbacks() */ -class U2FKey /*implements TwoFactorKeyInterface*/ +class U2FKey implements TwoFactorKeyInterface { use TimestampTrait; @@ -112,13 +112,13 @@ class U2FKey /*implements TwoFactorKeyInterface*/ **/ protected $user; - /*public function fromRegistrationData(Registration $data): void + public function fromRegistrationData(Registration $data): void { $this->keyHandle = $data->keyHandle; $this->publicKey = $data->publicKey; $this->certificate = $data->certificate; $this->counter = $data->counter; - }*/ + } public function getKeyHandle() { diff --git a/src/Entity/UserSystem/User.php b/src/Entity/UserSystem/User.php index 43c7570e..3db3ff38 100644 --- a/src/Entity/UserSystem/User.php +++ b/src/Entity/UserSystem/User.php @@ -65,8 +65,8 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Exception; use function in_array; -//use R\U2FTwoFactorBundle\Model\U2F\TwoFactorInterface as U2FTwoFactorInterface; -//use R\U2FTwoFactorBundle\Model\U2F\TwoFactorKeyInterface; +use R\U2FTwoFactorBundle\Model\U2F\TwoFactorInterface as U2FTwoFactorInterface; +use R\U2FTwoFactorBundle\Model\U2F\TwoFactorKeyInterface; use Scheb\TwoFactorBundle\Model\BackupCodeInterface; use Scheb\TwoFactorBundle\Model\Google\TwoFactorInterface; use Scheb\TwoFactorBundle\Model\PreferredProviderInterface; @@ -84,7 +84,7 @@ use Symfony\Component\Validator\Constraints as Assert; * @ORM\EntityListeners({"App\EntityListeners\TreeCacheInvalidationListener"}) * @UniqueEntity("name", message="validator.user.username_already_used") */ -class User extends AttachmentContainingDBElement implements UserInterface, HasPermissionsInterface, TwoFactorInterface, BackupCodeInterface, TrustedDeviceInterface, /*U2FTwoFactorInterface,*/ PreferredProviderInterface, PasswordAuthenticatedUserInterface +class User extends AttachmentContainingDBElement implements UserInterface, HasPermissionsInterface, TwoFactorInterface, BackupCodeInterface, TrustedDeviceInterface, U2FTwoFactorInterface, PreferredProviderInterface, PasswordAuthenticatedUserInterface { //use MasterAttachmentTrait; diff --git a/symfony.lock b/symfony.lock index 9cc75984..c1517266 100644 --- a/symfony.lock +++ b/symfony.lock @@ -354,6 +354,9 @@ "psr/simple-cache": { "version": "1.0.1" }, + "r/u2f-two-factor-bundle": { + "version": "dev-scheb/2fa-support" + }, "roave/security-advisories": { "version": "dev-master" }, diff --git a/templates/Users/_2fa_settings.html.twig b/templates/Users/_2fa_settings.html.twig index bef391c9..b6c1b114 100644 --- a/templates/Users/_2fa_settings.html.twig +++ b/templates/Users/_2fa_settings.html.twig @@ -143,7 +143,7 @@
{% trans %}tfa_u2f.no_keys_registered{% endtrans %}
{% endif %} - {# {% trans %}tfa_u2f.add_new_key{% endtrans %}#} + {% trans %}tfa_u2f.add_new_key{% endtrans %}