knojector/steam-authentication-bundle
最新稳定版本:1.4.0
Composer 安装命令:
composer require knojector/steam-authentication-bundle
包简介
Symfony Bundle to integrate Steam authentication
README 文档
README
SteamAuthenticationBundle - Steam authentication for Symfony
The SteamAuthenticationBundle provides an easy way to integrate Steams OpenID login for your application.
Table of Contents
Installation
Step 1 - Install the bundle
composer require knojector/steam-authentication-bundle
Step 2 - Configuration
knojector_steam_authentication: login_success_redirect: 'app.protected_route' login_failure_redirect: 'app.error_route'
As you can see there are only two options available for configuration. Both are very self-explanatory. The option login_success_redirect contains the name of the route the user should be redirected to if the login was successful. The option login_failure_redirect contains the route the user is redirected to if the login fails.
Furthermore you have to adjust your security.yml. In the following snippet you can see an example with a basic configuration. There are only two important things to consider:
- The firewall name must be
steam - You can use any user provider as long as the Steam CommunityId is the property to query for
security: providers: users: entity: class: 'App\Entity\User' property: 'username' firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false steam: pattern: ^/ lazy: true provider: users
The final step is to enable the bundle's controller in your routes.yaml
steam_authentication_callback: path: /steam/login_check controller: Knojector\SteamAuthenticationBundle\Controller\SteamController::callback
Usage
Step 1 - Create your own registration subscriber
Technically there is no registration available in this bundle. The bundle receives an ID from Steam and tries to load a user via the configured user provider. If no user exists you can assume that the user logged in for the first time. Instead of throwing an exception, the bundle dispatches an event you can subscribe to. A simple example for your subscriber is shown below
<?php namespace App\Subscriber; use App\Entity\User; use Knojector\SteamAuthenticationBundle\Event\AuthenticateUserEvent; use Knojector\SteamAuthenticationBundle\Event\FirstLoginEvent; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; class FirstLoginSubscriber implements EventSubscriberInterface { public function __construct(private EventDispatcherInterface $eventDispatcher) {} /** * @inheritDoc */ public static function getSubscribedEvents() { return [ FirstLoginEvent::NAME => 'onFirstLogin' ]; } public function onFirstLogin(FirstLoginEvent $event) { $communityId = $event->getCommunityId(); $user = new User(); $user->setUsername($communityId); // e.g. call the Steam API to fetch more profile information // e.g. create user entity and persist it // dispatch the authenticate event in order to sign in the new created user. $this->eventDispatcher->dispatch(new AuthenticateUserEvent($user), AuthenticateUserEvent::NAME); } }
Step 2 - Place the login button
To place the "Sign in through Steam" button you can include the following snippet in your template
{% include '@KnojectorSteamAuthentication/button.html.twig' %} Bugs and ideas?
Feel free to open an issue or submit a pull request ????
Requirements
The bundle requires:
- PHP 8.0.0+
- Symfony 5.3/6
knojector/steam-authentication-bundle 适用场景与选型建议
knojector/steam-authentication-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14.57k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 knojector/steam-authentication-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 knojector/steam-authentication-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 14.57k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04