-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(TwoFactorBundle): Added TwoFactor bundle to login to Roadiz with…
… TOTP application
- Loading branch information
1 parent
2cea745
commit 0953b00
Showing
30 changed files
with
931 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,26 @@ | ||
# See the configuration reference at https://symfony.com/bundles/SchebTwoFactorBundle/6.x/configuration.html | ||
scheb_two_factor: | ||
security_tokens: | ||
- Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken | ||
- Symfony\Component\Security\Http\Authenticator\Token\PostAuthenticationToken | ||
|
||
google: | ||
enabled: true | ||
server_name: "%env(string:APP_NAMESPACE)%" | ||
issuer: "%env(string:APP_TITLE)%" | ||
totp: | ||
enabled: true # If TOTP authentication should be enabled, default false | ||
server_name: "%env(string:APP_NAMESPACE)%" | ||
issuer: "%env(string:APP_TITLE)%" | ||
|
||
# Trusted device feature | ||
trusted_device: | ||
enabled: true # If the trusted device feature should be enabled | ||
lifetime: 5184000 # Lifetime of the trusted device cookie | ||
extend_lifetime: true | ||
key: "%env(string:APP_SECRET)%" | ||
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" | ||
backup_codes: | ||
enabled: true # If the backup code feature should be enabled |
This file contains 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 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 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,7 @@ | ||
2fa_login: | ||
path: /2fa | ||
defaults: | ||
_controller: "scheb_two_factor.form_controller::form" | ||
|
||
2fa_login_check: | ||
path: /2fa_check |
This file contains 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 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 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,58 @@ | ||
# Roadiz Font bundle | ||
|
||
![Run test status](https://github.com/roadiz/two-factor-bundle/actions/workflows/run-test.yml/badge.svg?branch=develop) | ||
|
||
Installation | ||
============ | ||
|
||
Make sure Composer is installed globally, as explained in the | ||
[installation chapter](https://getcomposer.org/doc/00-intro.md) | ||
of the Composer documentation. | ||
|
||
Applications that use Symfony Flex | ||
---------------------------------- | ||
|
||
Open a command console, enter your project directory and execute: | ||
|
||
```console | ||
$ composer require roadiz/two-factor-bundle | ||
``` | ||
|
||
Applications that don't use Symfony Flex | ||
---------------------------------------- | ||
|
||
### Step 1: Download the Bundle | ||
|
||
Open a command console, enter your project directory and execute the | ||
following command to download the latest stable version of this bundle: | ||
|
||
```console | ||
$ composer require roadiz/two-factor-bundle | ||
``` | ||
|
||
### Step 2: Enable the Bundle | ||
|
||
Then, enable the bundle by adding it to the list of registered bundles | ||
in the `config/bundles.php` file of your project: | ||
|
||
```php | ||
// config/bundles.php | ||
|
||
return [ | ||
// ... | ||
\RZ\Roadiz\TwoFactor\RoadizTwoFactor::class => ['all' => true], | ||
]; | ||
``` | ||
|
||
## Configuration | ||
|
||
- Copy and merge `@RoadizTwoFactor/config/packages/*` files into your project `config/packages` folder | ||
```yaml | ||
# config/routes.yaml | ||
roadiz_two_bundle: | ||
resource: "@RoadizTwoFactor/config/routing.yaml" | ||
``` | ||
## Contributing | ||
Report [issues](https://github.com/roadiz/core-bundle-dev-app/issues) and send [Pull Requests](https://github.com/roadiz/core-bundle-dev-app/pulls) in the [main Roadiz repository](https://github.com/roadiz/core-bundle-dev-app) |
This file contains 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,69 @@ | ||
{ | ||
"name": "roadiz/two-factor-bundle", | ||
"license": "MIT", | ||
"keywords": [ | ||
"cms", | ||
"backoffice", | ||
"rezo zero" | ||
], | ||
"authors": [ | ||
{ | ||
"name": "Ambroise Maupate", | ||
"email": "ambroise@roadiz.io", | ||
"homepage": "https://www.roadiz.io", | ||
"role": "Lead developer" | ||
} | ||
], | ||
"type": "symfony-bundle", | ||
"require": { | ||
"php": ">=8.0", | ||
"doctrine/orm": "^2.14.1", | ||
"endroid/qr-code": "^4.0", | ||
"roadiz/core-bundle": "^2.1", | ||
"roadiz/rozier-bundle": "^2.1", | ||
"scheb/2fa-backup-code": "^6.8", | ||
"scheb/2fa-bundle": "^6.8", | ||
"scheb/2fa-totp": "^6.8", | ||
"scheb/2fa-google-authenticator": "^6.8", | ||
"scheb/2fa-trusted-device": "^6.8", | ||
"sensio/framework-extra-bundle": "^6.1", | ||
"symfony/framework-bundle": "5.4.*" | ||
}, | ||
"require-dev": { | ||
"php-coveralls/php-coveralls": "^2.4", | ||
"phpstan/phpstan": "^1.5.3", | ||
"phpstan/phpstan-doctrine": "^1.3", | ||
"phpunit/phpunit": "^9.5", | ||
"squizlabs/php_codesniffer": "^3.5", | ||
"symfony/stopwatch": "5.4.*" | ||
}, | ||
"config": { | ||
"optimize-autoloader": true, | ||
"preferred-install": { | ||
"*": "dist" | ||
}, | ||
"sort-packages": true, | ||
"allow-plugins": { | ||
"symfony/flex": false, | ||
"symfony/runtime": false, | ||
"php-http/discovery": false | ||
} | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"RZ\\Roadiz\\TwoFactorBundle\\": "src/" | ||
} | ||
}, | ||
"scripts": { | ||
"auto-scripts": { | ||
"cache:clear": "symfony-cmd", | ||
"assets:install %PUBLIC_DIR%": "symfony-cmd" | ||
} | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-main": "2.1.x-dev", | ||
"dev-develop": "2.2.x-dev" | ||
} | ||
} | ||
} |
This file contains 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,11 @@ | ||
|
||
2fa_admin_two_factor: | ||
path: /rz-admin/two-factor | ||
defaults: | ||
_controller: RZ\Roadiz\TwoFactorBundle\Controller\TwoFactorAdminController::twoFactorAdminAction | ||
|
||
|
||
2fa_qr_code_totp: | ||
path: /rz-admin/two-factor/qr/totp | ||
defaults: | ||
_controller: RZ\Roadiz\TwoFactorBundle\Controller\QrCodeController::totpQrCodeAction |
This file contains 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,26 @@ | ||
--- | ||
services: | ||
# default configuration for services in *this* file | ||
_defaults: | ||
autowire: true # Automatically injects dependencies in your services. | ||
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. | ||
bind: {} | ||
|
||
RZ\Roadiz\TwoFactorBundle\: | ||
resource: '../src/' | ||
exclude: | ||
- '../src/DependencyInjection/' | ||
- '../src/Entity/' | ||
- '../src/Traits/' | ||
- '../src/Kernel.php' | ||
- '../src/Tests/' | ||
- '../src/Event/' | ||
|
||
RZ\Roadiz\TwoFactorBundle\Controller\: | ||
resource: '../src/Controller' | ||
tags: [ 'controller.service_arguments' ] | ||
|
||
roadiz_two_factor.security.totp.provider: | ||
class: RZ\Roadiz\TwoFactorBundle\Security\Provider\AuthenticatorTwoFactorProvider | ||
tags: | ||
- { name: scheb_two_factor.provider, alias: 'roadiz_totp' } |
36 changes: 36 additions & 0 deletions
36
lib/RoadizTwoFactorBundle/migrations/Version20230413154052.php
This file contains 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,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RZ\Roadiz\TwoFactorBundle\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20230413154052 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Added TwoFactorUser entity'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->addSql('CREATE TABLE two_factor_users (user_id INT NOT NULL, secret VARCHAR(255) DEFAULT NULL, backup_codes JSON DEFAULT NULL, trusted_version INT DEFAULT 1 NOT NULL, algorithm VARCHAR(6) DEFAULT NULL, period SMALLINT DEFAULT NULL, digits SMALLINT DEFAULT NULL, UNIQUE INDEX UNIQ_12ED8E9FA76ED395 (user_id), PRIMARY KEY(user_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); | ||
$this->addSql('ALTER TABLE two_factor_users ADD CONSTRAINT FK_12ED8E9FA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE'); | ||
$this->addSql('DROP TABLE untitled_folder'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->addSql('CREATE TABLE untitled_folder (untitled_id INT NOT NULL, folder_id INT NOT NULL, INDEX IDX_257063F7162CB942 (folder_id), INDEX IDX_257063F752B0ED85 (untitled_id), PRIMARY KEY(untitled_id, folder_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); | ||
$this->addSql('ALTER TABLE untitled_folder ADD CONSTRAINT FK_257063F7162CB942 FOREIGN KEY (folder_id) REFERENCES folders (id) ON UPDATE NO ACTION ON DELETE CASCADE'); | ||
$this->addSql('ALTER TABLE untitled_folder ADD CONSTRAINT FK_257063F752B0ED85 FOREIGN KEY (untitled_id) REFERENCES nodes_sources (id) ON UPDATE NO ACTION ON DELETE CASCADE'); | ||
$this->addSql('DROP TABLE two_factor_users'); | ||
} | ||
} |
Oops, something went wrong.