Skip to content

Commit 553eed0

Browse files
Merge branch 'b-7.4.x-2fa-OXDEV-9078' into b-7.4.x-google-provider-OXDEV-9885
2 parents 41a6a7c + b1506d2 commit 553eed0

73 files changed

Lines changed: 1320 additions & 480 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
### Added
1515
- Extracted reusable Twig code into captcha.html.twig and password.html.twig
16+
- Facebook login OAuth-provider
1617

1718
### Changed
1819
- 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+
}

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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public function login(): void
1919
$providerCollector = $this->getService(ProviderCollectorInterface::class);
2020

2121
$provider = $providerCollector->getProvider($_GET['provider']);
22-
$provider->getClient();
2322

2423
Registry::getUtils()->redirect($provider->getAuthorizationUrl());
2524
}
@@ -31,8 +30,8 @@ public function redirect(): void
3130
->getService(ProviderCollectorInterface::class)
3231
->getProvider('google');
3332

34-
$provider->getClient();
3533
$accessToken = $provider->getAccessToken($_GET['code']);
34+
3635
$userDTO = $provider->getUserInfo($accessToken);
3736

3837
$this
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
}

src/Authentication/OAuth2/Factory/services.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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\Infrastructure\Factory;
11+
12+
use League\OAuth2\Client\Provider\FacebookUser;
13+
use OxidEsales\SecurityModule\Authentication\OAuth2\DTO\OAuth2UserDTO;
14+
use OxidEsales\SecurityModule\Authentication\OAuth2\DTO\OAuth2UserDTOInterface;
15+
16+
class OAuth2UserDTOFactory implements OAuth2UserDTOFactoryInterface
17+
{
18+
public function createFromFacebookUser(FacebookUser $facebookUser): OAuth2UserDTOInterface
19+
{
20+
return new OAuth2UserDTO(
21+
$facebookUser->getFirstName(),
22+
$facebookUser->getLastName(),
23+
$facebookUser->getEmail(),
24+
);
25+
}
26+
}

0 commit comments

Comments
 (0)