Skip to content

Commit 25c6b8d

Browse files
committed
Merge branch 'b-7.4.x-generate-exceptions-OXDEV-9992' into b-7.4.x
2 parents fe5e177 + b76cc70 commit 25c6b8d

158 files changed

Lines changed: 5312 additions & 21 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
### Added
1010
- Extracted reusable Twig code into captcha.html.twig and password.html.twig
11+
- Facebook login OAuth-provider
12+
- Google login OAuth-provider
1113

1214
### Changed
1315
- Show multiple errors on invalid password

assets/out/src/css/providers.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.sign-in-providers {
2+
padding: 10px 0;
3+
}
4+
5+
.card-body {
6+
.sign-in-providers {
7+
text-align: center;
8+
}
9+
}

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@
3030
"codeception/module-webdriver": "*",
3131
"oxid-esales/codeception-modules": "dev-b-7.4.x",
3232
"oxid-esales/codeception-page-objects": "dev-b-7.4.x",
33-
"mikey179/vfsstream": "^1.6"
33+
"mikey179/vfsstream": "^1.6",
34+
"pragmarx/google2fa": "^v8.0.3",
35+
"bacon/bacon-qr-code": "v3.0.1",
36+
"league/oauth2-google": "4.0.1",
37+
"league/oauth2-facebook": "2.2.0"
3438
},
3539
"minimum-stability": "dev",
3640
"prefer-stable": true,

metadata.php

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
* Metadata version
1010
*/
1111

12+
use OxidEsales\SecurityModule\Authentication\OAuth2\Service\ModuleSettingsService;
13+
use OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Service\ModuleSettingsService as TwoFactorAuthModuleSettings;
1214
use OxidEsales\SecurityModule\PasswordPolicy\Service\ModuleSettingsService as PasswordPolicyModuleSettings;
1315
use OxidEsales\SecurityModule\Captcha\Service\ModuleSettingsService as CaptchaModuleSettings;
16+
use OxidEsales\SecurityModule\Authentication\OAuth2\Service\ModuleSettingsService as OAuthModuleSettings;
1417
use OxidEsales\SecurityModule\Core\Module;
1518

1619
$sMetadataVersion = '2.1';
@@ -39,7 +42,9 @@
3942
],
4043
'controllers' => [
4144
'captcha' => \OxidEsales\SecurityModule\Captcha\Controller\CaptchaController::class,
42-
'password' => \OxidEsales\SecurityModule\PasswordPolicy\Controller\PasswordAjaxController::class
45+
'password' => \OxidEsales\SecurityModule\PasswordPolicy\Controller\PasswordAjaxController::class,
46+
'oauth' => \OxidEsales\SecurityModule\Authentication\OAuth2\Controller\OAuthController::class,
47+
'twofactorauth' => \OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Controller\TwoFactorAuthController::class,
4348
],
4449
'templates' => [
4550
],
@@ -109,6 +114,71 @@
109114
'type' => 'select',
110115
'constraints' => '5min|15min|30min',
111116
'value' => '15min'
112-
]
117+
],
118+
119+
//OAuth2 settings
120+
[
121+
'group' => 'oauth',
122+
'name' => OAuthModuleSettings::FACEBOOK_LOGIN_ENABLED,
123+
'type' => 'bool',
124+
'value' => false
125+
],
126+
[
127+
'group' => 'oauth',
128+
'name' => OAuthModuleSettings::FACEBOOK_CLIENT_ID,
129+
'type' => 'str',
130+
'value' => ''
131+
],
132+
[
133+
'group' => 'oauth',
134+
'name' => OAuthModuleSettings::FACEBOOK_CLIENT_SECRET,
135+
'type' => 'str',
136+
'value' => ''
137+
],
138+
[
139+
'group' => 'oauth',
140+
'name' => OAuthModuleSettings::FACEBOOK_REDIRECT_URL,
141+
'type' => 'str',
142+
'value' => ''
143+
],
144+
[
145+
'group' => 'oauth',
146+
'name' => OAuthModuleSettings::GOOGLE_LOGIN_ENABLED,
147+
'type' => 'bool',
148+
'value' => true
149+
],
150+
[
151+
'group' => 'oauth',
152+
'name' => OAuthModuleSettings::GOOGLE_CLIENT_ID,
153+
'type' => 'str',
154+
'value' => ''
155+
],
156+
[
157+
'group' => 'oauth',
158+
'name' => OAuthModuleSettings::GOOGLE_CLIENT_SECRET,
159+
'type' => 'str',
160+
'value' => ''
161+
],
162+
[
163+
'group' => 'oauth',
164+
'name' => OAuthModuleSettings::GOOGLE_REDIRECT_URL,
165+
'type' => 'str',
166+
'value' => ''
167+
],
168+
169+
//TwoFactorAuth settings
170+
[
171+
'group' => 'two_factor_auth',
172+
'name' => TwoFactorAuthModuleSettings::ACTIVE,
173+
'type' => 'bool',
174+
'value' => false
175+
],
176+
[
177+
'group' => 'two_factor_auth',
178+
'name' => TwoFactorAuthModuleSettings::TWO_FACTOR_TYPE,
179+
'type' => 'select',
180+
'constraints' => 'otp|totp',
181+
'value' => 'otp'
182+
],
113183
],
114184
];
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* Copyright © OXID eSales AG. All rights reserved.
7+
* See LICENSE file for license details.
8+
*/
9+
10+
namespace OxidEsales\SecurityModule\Migrations;
11+
12+
use Doctrine\DBAL\Schema\Schema;
13+
use Doctrine\Migrations\AbstractMigration;
14+
15+
final class Version20251128093245 extends AbstractMigration
16+
{
17+
public function up(Schema $schema): void
18+
{
19+
$this->addSql('ALTER TABLE `oxuser` ADD column `OESMOTPCODE` VARCHAR(128) default NULL COMMENT "OTP code"');
20+
$this->addSql('ALTER TABLE `oxuser` ADD column `OESMOTPEXPTIME` DATETIME default NULL COMMENT "OTP code expiration time"');
21+
$this->addSql('ALTER TABLE `oxuser` ADD column `OESMOTPATTEMPTS` INT NOT NULL default 0 COMMENT "OTP code attempts"');
22+
}
23+
24+
public function down(Schema $schema): void
25+
{
26+
}
27+
}

migration/migrations.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
table_storage:
2+
table_name: oxmigrations_oe_security_module
3+
migrations_paths:
4+
'OxidEsales\SecurityModule\Migrations': data

services.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
imports:
22
- { resource: src/Captcha/services.yaml }
33
- { resource: src/PasswordPolicy/services.yaml }
4+
- { resource: src/Authentication/services.yaml }
5+
- { resource: src/Shared/services.yaml }
46

57
services:
68
_defaults:
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
/**
4+
* Copyright © OXID eSales AG. All rights reserved.
5+
* See LICENSE file for license details.
6+
*/
7+
8+
namespace OxidEsales\SecurityModule\Authentication\OAuth2\Controller;
9+
10+
use OxidEsales\Eshop\Application\Controller\FrontendController;
11+
use OxidEsales\Eshop\Core\Registry;
12+
use OxidEsales\SecurityModule\Authentication\OAuth2\Service\ProviderCollectorInterface;
13+
use OxidEsales\SecurityModule\Authentication\OAuth2\Service\UserServiceInterface;
14+
15+
class OAuthController extends FrontendController
16+
{
17+
public function login(): void
18+
{
19+
$providerCollector = $this->getService(ProviderCollectorInterface::class);
20+
21+
$provider = $providerCollector->getProvider($_GET['provider']);
22+
23+
Registry::getUtils()->redirect($provider->getAuthorizationUrl());
24+
}
25+
26+
public function redirect(): void
27+
{
28+
//todo: get provider dynamically
29+
$provider = $this
30+
->getService(ProviderCollectorInterface::class)
31+
->getProvider('google');
32+
33+
$accessToken = $provider->getAccessToken($_GET['code']);
34+
35+
$userDTO = $provider->getUserInfo($accessToken);
36+
37+
$this
38+
->getService(UserServiceInterface::class)
39+
->login($userDTO);
40+
41+
Registry::getUtils()->redirect('');
42+
}
43+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/**
4+
* Copyright © OXID eSales AG. All rights reserved.
5+
* See LICENSE file for license details.
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace OxidEsales\SecurityModule\Authentication\OAuth2\DTO;
11+
12+
readonly class OAuth2UserDTO implements OAuth2UserDTOInterface
13+
{
14+
public function __construct(
15+
private ?string $firstName,
16+
private ?string $lastName,
17+
private ?string $email,
18+
) {
19+
}
20+
21+
public function getFirstName(): ?string
22+
{
23+
return $this->firstName;
24+
}
25+
26+
public function getLastName(): ?string
27+
{
28+
return $this->lastName;
29+
}
30+
31+
public function getEmail(): ?string
32+
{
33+
return $this->email;
34+
}
35+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
/**
4+
* Copyright © OXID eSales AG. All rights reserved.
5+
* See LICENSE file for license details.
6+
*/
7+
8+
namespace OxidEsales\SecurityModule\Authentication\OAuth2\DTO;
9+
10+
interface OAuth2UserDTOInterface
11+
{
12+
public function getFirstName(): ?string;
13+
14+
public function getLastName(): ?string;
15+
16+
public function getEmail(): ?string;
17+
}

0 commit comments

Comments
 (0)