telixj / phpbb-bundle
Symfony 与 phpBB 的集成
v3.0
2023-12-06 20:18 UTC
Requires
- php: ^8.2
- doctrine/orm: ^2.5
- symfony/security-bundle: ^5.4|^6.0
README
Symfony 与 phpBB 集成。使用 phpBB 作为认证提供者并共享其会话。
配置
首先,确保在您的应用程序中通过使用以下方式忽略 phpBB 表(每个实体管理器都需要此操作)
doctrine: dbal: schema_filter: ~^(?!phpbb_)~
where phpbb_ 是由 phpBB 生成的表的表前缀。如果不进行此配置更改,可能会导致您的论坛表被删除!
然后,如果您将论坛放在其他数据库中,请向 doctrine 连接添加自定义 entity_manager 和 dbal
doctrine: dbal: default_connection: default connections: acme: # this is an example for your website's database but it's not required driver: "%database_driver%" host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_user%" password: "%database_password%" charset: "UTF8" forum: driver: "%forum_database_driver%" host: "%forum_database_host%" port: "%forum_database_port%" dbname: "%forum_database_name%" user: "%forum_database_user%" password: "%forum_database_password%" charset: "UTF8" orm: entity_managers: default: # same here, not required, but you will probably have this in your configuration connection: default forum: connection: forum mappings: PhpbbBundle: ~
然后将捆绑配置添加到 config/packages/phpbb.yaml
phpbb: session: cookie_name: "phpbb_foo" # must match your forum admin cookie name configuration login_page: "ucp.php?mode=login" # your login page, by default phpbb login page but you can use a custom page force_login: false # if true, anonymous users will be redirected to the login page database: entity_manager: "forum" # must match the key bellow doctrine.orm.entity_managers prefix: "phpbb_" # change this if you do not use the default "phpbb_" prefix roles: #relation between group_id from groups table of phpBB and roles of your application 1: anonymous #GUESTS 2: user #REGISTERED 4: moderator #GLOBAL_MODERATORS 5: administrator #ADMINISTRATORS 6: bot #BOTS 7: app_role_name #example of new group create in phpBB and new role in your application 8: administrator #you can assing same application roles to various phpBB groups
更新您的 config/packages/security.yaml
以匹配此配置
security: enable_authenticator_manager: true firewalls: main: pattern: ^/ stateless: true # stateless should be set to true, or your symfony user may be stored in the session even if you logged out from the phpbb instance custom_authenticators: - TeLiXj\PhpbbBundle\Security\PhpbbSessionAuthenticator
要使用记住我功能,您必须编辑您的论坛中的 ucp.php
以在检测到正确的会话密钥后启用重定向。将行 redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
更改为 redirect($request->variable('redirect', append_sid("{$phpbb_root_path}index.$phpEx")));
缺失的功能
有一些边缘功能缺失
会话 IP 验证
被视为 "A.B.C",无论您在管理员控制面板配置中指定了什么