Skip to content

Commit

Permalink
Fix security deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin de Rooij committed Feb 18, 2024
1 parent f99328b commit b612a04
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
15 changes: 7 additions & 8 deletions config/packages/security.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
security:
enable_authenticator_manager: true
password_hashers:
App\Entity\Member:
algorithm: auto
Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface: 'auto'

# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
Expand All @@ -14,15 +14,14 @@ security:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: true
lazy: true
provider: app_user_provider
form_login:
login_path: login
check_path: login
default_target_path: member_home
always_use_default_target_path: true
csrf_token_generator: security.csrf.token_manager
enable_csrf: true
logout:
path: logout

Expand All @@ -35,13 +34,13 @@ security:
# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
- { path: ^/login$, roles: IS_ANONYMOUS }
- { path: ^/login$, roles: PUBLIC_ACCESS }
- { path: ^/steunlid-worden(/|$), roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/wachtwoord-opvragen$, roles: IS_ANONYMOUS }
- { path: ^/wachtwoord-instellen/.+$, roles: IS_ANONYMOUS }
- { path: ^/wachtwoord-opvragen$, roles: PUBLIC_ACCESS }
- { path: ^/wachtwoord-instellen/.+$, roles: PUBLIC_ACCESS }
- { path: ^/aanmelden$, roles: [IS_AUTHENTICATED_ANONYMOUSLY] }
- { path: ^/aanmelden/.*$, roles: [IS_AUTHENTICATED_ANONYMOUSLY] }
- { path: ^/api/.+$, roles: IS_ANONYMOUS }
- { path: ^/api/.+$, roles: PUBLIC_ACCESS }
- { path: ^/admin$, roles: [ROLE_ADMIN, ROLE_DIVISION_CONTACT] }
- { path: '^/auth/check_admin'}
- { path: '^', roles: ROLE_USER }
9 changes: 8 additions & 1 deletion src/Entity/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
use Symfony\Component\Validator\Constraints as Assert;
use DateTime;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use App\Repository\MemberRepository;

/**
* @ORM\Entity
* @ORM\Table("admin_member")
*/
class Member implements UserInterface {
class Member implements UserInterface, PasswordAuthenticatedUserInterface {

const PERIOD_MONTHLY = 0;
const PERIOD_QUARTERLY = 1;
Expand Down Expand Up @@ -293,6 +294,12 @@ public function getManagingEmails(): Collection {
/** @see UserInterface */
public function getUsername(): string { return $this->id; }

/** @see UserInterface */
public function getUserIdentifier(): string
{
return $this->getUsername();
}

/** @see UserInterface */
public function getRoles(): array {
$roles = $this->roles;
Expand Down
2 changes: 1 addition & 1 deletion src/Security/IdOrEmailMemberProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct(EntityManagerInterface $entityManager) {
$this->entityManager = $entityManager;
}

public function loadUserByUsername(string $usernameOrEmail) {
public function loadUserByUsername(string $usernameOrEmail): UserInterface {
$user = $this->entityManager->createQuery('SELECT m FROM App\Entity\Member m WHERE m.id = ?1 OR m.email = ?1')
->setParameter(1, $usernameOrEmail)
->getOneOrNullResult()
Expand Down

0 comments on commit b612a04

Please sign in to comment.