1000 search results

``` collectionOperations: [ 'get', 'post' => [ "security" => "is_granted('IS_AUTHENTICATED_ANONYMOUSLY')", 'validation_groups' => ['Default', 'create'] ] ],``` and ``` #[SerializedName('password')] /** * @Assert\NotBlank(groups={"create"}) */ private $plainPassword;``` also add return type above getPlainPassword function ``` /** * @return string */ public function getPlainPassword(): string { return $this->plainPassword; } ``` after setup this things…
31 lines | src/Controller/SecurityController.php
// ... lines 1 - 9
class SecurityController extends AbstractController
{
// ... lines 12 - 14
public function login(AuthenticationUtils $authenticationUtils): Response
{
return $this->render('security/login.html.twig', [
// ... line 18
'last_username' => $authenticationUtils->getLastUsername(),
]);
}
// ... lines 22 - 29
}
See Code Block in Script
22 lines | src/Controller/SecurityController.php
// ... lines 1 - 9
class SecurityController extends AbstractController
{
// ... lines 12 - 14
public function login(AuthenticationUtils $authenticationUtils): Response
{
return $this->render('security/login.html.twig', [
'error' => $authenticationUtils->getLastAuthenticationError(),
]);
}
}
See Code Block in Script
132 lines | src/Entity/User.php
// ... lines 1 - 7
use Symfony\Component\Security\Core\User\UserInterface;
// ... lines 9 - 12
class User implements UserInterface
{
// ... lines 15 - 130
}
See Code Block in Script
130 lines | src/Entity/User.php
// ... lines 1 - 6
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
// ... lines 8 - 12
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
// ... lines 15 - 128
}
See Code Block in Script
22 lines | src/Controller/SecurityController.php
// ... lines 1 - 7
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class SecurityController extends AbstractController
{
// ... lines 12 - 14
public function login(AuthenticationUtils $authenticationUtils): Response
{
// ... lines 17 - 19
}
}
See Code Block in Script
22 lines | src/Controller/SecurityController.php
// ... lines 1 - 9
class SecurityController extends AbstractController
{
// ... lines 12 - 14
public function login(AuthenticationUtils $authenticationUtils): Response
{
return $this->render('security/login.html.twig', [
'error' => $authenticationUtils->getLastAuthenticationError(),
]);
}
}
See Code Block in Script
21 lines | src/Controller/SecurityController.php
// ... lines 1 - 2
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class SecurityController extends AbstractController
{
/**
* @Route("/security", name="security")
*/
public function index(): Response
{
return $this->render('security/index.html.twig', [
'controller_name' => 'SecurityController',
]);
}
}
See Code Block in Script
19 lines | src/Controller/SecurityController.php
// ... lines 1 - 8
class SecurityController extends AbstractController
{
/**
* @Route("/login", name="app_login")
*/
public function login(): Response
{
return $this->render('security/login.html.twig');
}
}
See Code Block in Script
115 lines | src/Entity/User.php
// ... lines 1 - 7
use Symfony\Component\Security\Core\User\UserInterface;
// ... lines 9 - 12
class User implements UserInterface
{
// ... lines 15 - 113
}
See Code Block in Script
I tried the security.yaml configuration for logout (via a front-end Axios call) and I can see it does the 302 redirect - but the cookie remains (which isn't good). If I try to build my own symfony controller with this: ``` // clear the token…
php bin/console security:check The web service failed for an unknown reason (HTTP 403). T_T how to fix it?
// ... lines 1 - 7
use Symfony\Component\Security\Core\Security;
class SetIsMeOnCurrentUserSubscriber implements EventSubscriberInterface
{
private $security;
public function __construct(Security $security)
{
$this->security = $security;
}
// ... lines 18 - 39
}
See Code Block in Script
65 lines | src/DataPersister/UserDataPersister.php
// ... lines 1 - 9
use Symfony\Component\Security\Core\Security;
class UserDataPersister implements ContextAwareDataPersisterInterface
{
// ... lines 14 - 16
private $security;
public function __construct(DataPersisterInterface $decoratedDataPersister, UserPasswordEncoderInterface $userPasswordEncoder, LoggerInterface $logger, Security $security)
{
// ... lines 21 - 23
$this->security = $security;
}
// ... lines 26 - 63
}
See Code Block in Script
40 lines | src/DataProvider/UserDataProvider.php
// ... lines 1 - 8
use Symfony\Component\Security\Core\Security;
class UserDataProvider implements ContextAwareCollectionDataProviderInterface, RestrictedDataProviderInterface
{
// ... line 13
private $security;
public function __construct(CollectionDataProviderInterface $collectionDataProvider, Security $security)
{
// ... line 18
$this->security = $security;
}
// ... lines 21 - 38
}
See Code Block in Script
…All I needed to do was `composer update` to update the Symfony components before I installed Sentry. I didn't get quite the same error as you (though it does say `Script security-checker security:check returned with error code 1`) but it's similar…
// ... lines 1 - 6
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
// ... lines 8 - 11
class ValidIsPublishedValidator extends ConstraintValidator
{
// ... lines 14 - 22
public function validate($value, Constraint $constraint)
{
// ... lines 25 - 54
// we are UNpublishing
if (!$this->security->isGranted('ROLE_ADMIN')) {
// you can return a 403
throw new AccessDeniedException('Only admin users can unpublish');
// or a normal validation error
$this->context->buildViolation('Only admin users can unpublish')
->addViolation();
}
}
}
See Code Block in Script
217 lines | src/Entity/CheeseListing.php
// ... lines 1 - 17
/**
* @ApiResource(
// ... lines 20 - 21
* itemOperations={
// ... lines 23 - 25
* "put"={
* "security"="is_granted('EDIT', object)",
* "security_message"="Only the creator can edit a cheese listing"
* },
// ... line 30
* },
// ... lines 32 - 43
* )
// ... lines 45 - 55
*/
class CheeseListing
{
// ... lines 59 - 215
}
See Code Block in Script
I got error from security checker when installing profiler. ` ➜ composer require profiler --dev 14s Using version ^1.0 for symfony/profiler-pack ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Restricting packages listed in "symfony/symfony…
94 lines | src/Repository/UserRepository.php
// ... lines 1 - 7
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
// ... lines 9 - 16
class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
{
// ... lines 19 - 92
}
See Code Block in Script