Skip to content

Commit 68df0d3

Browse files
Merge branch 'b-7.4.x-2fa-OXDEV-9078' into b-7.4.x-implement-otp-OXDEV-9927
2 parents 4027aae + 1b9d625 commit 68df0d3

83 files changed

Lines changed: 1790 additions & 478 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+
}

metadata.php

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use OxidEsales\SecurityModule\Authentication\TwoFactorAuth\Service\ModuleSettingsService as TwoFactorAuthModuleSettings;
1414
use OxidEsales\SecurityModule\PasswordPolicy\Service\ModuleSettingsService as PasswordPolicyModuleSettings;
1515
use OxidEsales\SecurityModule\Captcha\Service\ModuleSettingsService as CaptchaModuleSettings;
16+
use OxidEsales\SecurityModule\Authentication\OAuth2\Service\ModuleSettingsService as OAuthModuleSettings;
1617
use OxidEsales\SecurityModule\Core\Module;
1718

1819
$sMetadataVersion = '2.1';
@@ -42,7 +43,6 @@
4243
'controllers' => [
4344
'captcha' => \OxidEsales\SecurityModule\Captcha\Controller\CaptchaController::class,
4445
'password' => \OxidEsales\SecurityModule\PasswordPolicy\Controller\PasswordAjaxController::class,
45-
4646
'oauth' => \OxidEsales\SecurityModule\Authentication\OAuth2\Controller\OAuthController::class
4747
],
4848
'templates' => [
@@ -118,25 +118,49 @@
118118
//OAuth2 settings
119119
[
120120
'group' => 'oauth',
121-
'name' => ModuleSettingsService::FACEBOOK_ACTIVE,
121+
'name' => OAuthModuleSettings::FACEBOOK_LOGIN_ENABLED,
122122
'type' => 'bool',
123123
'value' => false
124124
],
125125
[
126126
'group' => 'oauth',
127-
'name' => ModuleSettingsService::FACEBOOK_CLIENT_ID,
127+
'name' => OAuthModuleSettings::FACEBOOK_CLIENT_ID,
128+
'type' => 'str',
129+
'value' => ''
130+
],
131+
[
132+
'group' => 'oauth',
133+
'name' => OAuthModuleSettings::FACEBOOK_CLIENT_SECRET,
134+
'type' => 'str',
135+
'value' => ''
136+
],
137+
[
138+
'group' => 'oauth',
139+
'name' => OAuthModuleSettings::FACEBOOK_REDIRECT_URL,
140+
'type' => 'str',
141+
'value' => ''
142+
],
143+
[
144+
'group' => 'oauth',
145+
'name' => OAuthModuleSettings::GOOGLE_LOGIN_ENABLED,
146+
'type' => 'bool',
147+
'value' => true
148+
],
149+
[
150+
'group' => 'oauth',
151+
'name' => OAuthModuleSettings::GOOGLE_CLIENT_ID,
128152
'type' => 'str',
129153
'value' => ''
130154
],
131155
[
132156
'group' => 'oauth',
133-
'name' => ModuleSettingsService::FACEBOOK_CLIENT_SECRET,
157+
'name' => OAuthModuleSettings::GOOGLE_CLIENT_SECRET,
134158
'type' => 'str',
135159
'value' => ''
136160
],
137161
[
138162
'group' => 'oauth',
139-
'name' => ModuleSettingsService::FACEBOOK_REDIRECT_URL,
163+
'name' => OAuthModuleSettings::GOOGLE_REDIRECT_URL,
140164
'type' => 'str',
141165
'value' => ''
142166
],

services.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ imports:
22
- { resource: src/Captcha/services.yaml }
33
- { resource: src/PasswordPolicy/services.yaml }
44
- { resource: src/Authentication/services.yaml }
5+
- { resource: src/Shared/services.yaml }
56

67
services:
78
_defaults:

src/Authentication/OAuth2/Controller/OAuthController.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<?php
22

3+
/**
4+
* Copyright © OXID eSales AG. All rights reserved.
5+
* See LICENSE file for license details.
6+
*/
7+
38
namespace OxidEsales\SecurityModule\Authentication\OAuth2\Controller;
49

510
use OxidEsales\Eshop\Application\Controller\FrontendController;
@@ -14,18 +19,16 @@ public function login(): void
1419
$providerCollector = $this->getService(ProviderCollectorInterface::class);
1520

1621
$provider = $providerCollector->getProvider($_GET['provider']);
17-
$provider->getClient();
1822

1923
Registry::getUtils()->redirect($provider->getAuthorizationUrl());
2024
}
2125

2226
public function redirect(): void
2327
{
28+
//todo: get provider dynamically
2429
$provider = $this
2530
->getService(ProviderCollectorInterface::class)
26-
->getProvider('facebook');
27-
28-
$provider->getClient();
31+
->getProvider('google');
2932

3033
$accessToken = $provider->getAccessToken($_GET['code']);
3134

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+
}

src/Authentication/OAuth2/DTO/UserDTO.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,18 @@
1212
class UserDTO implements UserDTOInterface
1313
{
1414
public function __construct(
15-
private readonly ?string $firstName,
16-
private readonly ?string $lastName,
17-
private readonly ?string $email,
15+
private readonly string $userId,
16+
private readonly bool $isBlocked
1817
) {
1918
}
2019

21-
public function getFirstName(): ?string
20+
public function getId(): string
2221
{
23-
return $this->firstName;
22+
return $this->userId;
2423
}
2524

26-
public function getLastName(): ?string
25+
public function isBlocked(): bool
2726
{
28-
return $this->lastName;
29-
}
30-
31-
public function getEmail(): ?string
32-
{
33-
return $this->email;
27+
return $this->isBlocked;
3428
}
3529
}

src/Authentication/OAuth2/DTO/UserDTOInterface.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99

1010
interface UserDTOInterface
1111
{
12-
public function getFirstName(): ?string;
12+
public function getId(): string;
1313

14-
public function getLastName(): ?string;
15-
16-
public function getEmail(): ?string;
14+
public function isBlocked(): bool;
1715
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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\Exception;
11+
12+
class ProviderNotActiveException extends \Exception
13+
{
14+
}

0 commit comments

Comments
 (0)