Skip to content

Commit 96822e5

Browse files
lukmzigstunnerparas
authored andcommitted
[Reset Password] Make endpoint available without authentication (#1520)
* make reset password endpoint public * update docs
1 parent bb40f07 commit 96822e5

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

doc/00_Installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ security:
2626
firewalls:
2727
pimcore_studio: '%pimcore_studio_backend.firewall_settings%'
2828
access_control:
29-
- { path: ^/pimcore-studio/api/(docs|docs/json|translations)$, roles: PUBLIC_ACCESS }
29+
- { path: ^/pimcore-studio/api/(docs|docs/json|translations|user/reset-password)$, roles: PUBLIC_ACCESS }
3030
- { path: ^/pimcore-studio/api, roles: ROLE_PIMCORE_USER }
3131
```
3232

src/Security/Voter/PublicAuthorizationVoter.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,16 @@ final class PublicAuthorizationVoter extends Voter
3333
use RequestTrait;
3434
use PublicTranslationTrait;
3535

36-
private const SUPPORTED_ATTRIBUTE = 'PUBLIC_STUDIO_API';
36+
private const string SUPPORTED_ATTRIBUTE = 'PUBLIC_STUDIO_API';
3737

38-
private const SUPPORTED_SUBJECTS = ['translation'];
38+
private const string TRANSLATION_SUBJECT = 'translation';
39+
40+
private const string RESET_PASSWORD_SUBJECT = 'resetPassword';
41+
42+
private const array SUPPORTED_SUBJECTS = [
43+
self::TRANSLATION_SUBJECT,
44+
self::RESET_PASSWORD_SUBJECT,
45+
];
3946

4047
public function __construct(
4148
private readonly RequestStack $requestStack,
@@ -70,7 +77,8 @@ protected function voteOnAttribute(string $attribute, mixed $subject, TokenInter
7077
private function voteOnRequest(Request $request, string $subject): bool
7178
{
7279
return match ($subject) {
73-
'translation' => $this->voteOnTranslation($request->getPayload()),
80+
self::TRANSLATION_SUBJECT => $this->voteOnTranslation($request->getPayload()),
81+
self::RESET_PASSWORD_SUBJECT => true,
7482
default => false,
7583
};
7684
}

src/User/Controller/ResetPasswordController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Symfony\Component\HttpFoundation\Response;
2929
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
3030
use Symfony\Component\Routing\Attribute\Route;
31+
use Symfony\Component\Security\Http\Attribute\IsGranted;
3132
use Symfony\Component\Serializer\SerializerInterface;
3233

3334
/**
@@ -46,6 +47,7 @@ public function __construct(
4647
* @throws RateLimitException|DomainConfigurationException|SendMailException
4748
*/
4849
#[Route('/user/reset-password', name: 'pimcore_studio_api_user_reset_password', methods: ['POST'])]
50+
#[IsGranted(self::VOTER_PUBLIC_STUDIO_API, 'resetPassword')]
4951
#[Post(
5052
path: self::PREFIX . '/user/reset-password',
5153
operationId: 'user_reset_password',

0 commit comments

Comments
 (0)