Symfony 5 - 需要信号量扩展 (sysvsem)

问题描述 投票:0回答:2

我已经实现了全新的 Symfony 身份验证系统:https://symfony.com/doc/current/security/experimental_authenticators.html

我添加了新的登录限制:https://symfony.com/blog/new-in-symfony-5-2-login-throtdling

一切都已正确配置。

我还安装了 RateLimiter 组件,它创建了一个环境变量:

LOCK_DSN=semaphore

但我有一个问题。首先,登录限制似乎被忽视了一半。一旦超出限制,我就不会收到任何错误消息。另一方面,如果我尝试使用良好的凭据进行连接,则会出现以下错误:

需要信号量扩展(sysvsem)。

我尝试安装信号量组件(https://symfony.com/doc/current/components/semaphore.html

但是同样的问题。

这是我的 security.yaml

security:
  enable_authenticator_manager: true

  encoders:
    App\Application\Entity\User:
      algorithm: auto

  # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
  providers:
    in_memory: { memory: ~ }
    # used to reload user from session & other features (e.g. switch_user)
    in_database:
      entity:
        class: App\Application\Entity\User
        property: email
  firewalls:
    dev:
      pattern: ^/(_(profiler|wdt)|css|images|js)/
      security: false

    main:
      user_checker: App\Application\Security\UserChecker
      provider: in_database
      lazy: true

      remember_me:
        secret: '%kernel.secret%'

      form_login:
        login_path: app_login
        check_path: app_login
        default_target_path: home

      logout:
        path: app_logout
        target: app_login

      custom_authenticators:
        - App\Application\Security\AppCustomAuthenticator

      entry_point: App\Application\Security\AppCustomAuthenticator

      # configuring the maximum login attempts (per minute)
      login_throttling:
        max_attempts: 2

我搜索是否有可以添加到 PHP 的扩展,但没有找到任何内容。所以我不知道该怎么办。 我使用的是 Windows 10

php symfony components symfony-ratelimiter
2个回答
18
投票

我也遇到了这个问题,你可以更改锁定的商店: https://symfony.com/doc/current/components/lock.html#available-stores

我的解决方案是更改 .env.local

###> symfony/lock ###
# Choose one of the stores below
# postgresql+advisory://db_user:db_password@localhost/db_name
LOCK_DSN=semaphore
###< symfony/lock ###

至:

###> symfony/lock ###
# Choose one of the stores below
# postgresql+advisory://db_user:db_password@localhost/db_name
LOCK_DSN=flock
###< symfony/lock ###


0
投票

似乎缺少扩展(模块)PHP。

我也有这个错误,当我阅读后面的 PHP 库的安装文档时:https://www.php.net/manual/en/sem.installation.php

要启用 System V 信号量支持,请使用选项 --enable-sysvsem 编译 PHP。要启用 System V 共享内存支持,请使用选项 --enable-sysvshm 编译 PHP。要启用 System V 消息支持,请使用选项 --enable-sysvmsg 编译 PHP。

当我使用 docker 图像时,我在

Dockerfile
图像上的
php
中添加了这个扩展,例如

RUN docker-php-ext-install sysvmsg sysvsem sysvshm

不要忘记在

docker compose build
目录上运行
docker build
Dockerfile
,它会起作用。

© www.soinside.com 2019 - 2024. All rights reserved.