wapplersystems/oauth-service
Composer 安装命令:
composer require wapplersystems/oauth-service
包简介
Central OAuth2 client and token management for TYPO3 — Authorization Code Flow with PKCE, encrypted token storage, automatic refresh and expiry monitoring
README 文档
README
Central OAuth2 client and token management for TYPO3 v14.
Features
- Manage multiple OAuth2 clients and connections via a backend module
- Authorization Code Flow with PKCE (RFC 7636, OAuth 2.1 compliant)
- Encrypted token storage (libsodium, derived from TYPO3 encryption key)
- Automatic token refresh via console command / scheduler
- Expiry monitoring with configurable email warnings
- Extensible provider system — register custom OAuth providers from any extension
Requirements
- TYPO3 v14
- PHP 8.2+
ext-sodium
Installation
composer require wapplersystems/oauth-service
Then update the database schema:
typo3 extension:setup
Configuration
Extension settings under Admin Tools > Settings > Extension Configuration > oauth_service:
| Setting | Default | Description |
|---|---|---|
thresholdSeconds |
300 |
Refresh tokens expiring within this many seconds |
debounceMinutes |
360 |
Min. gap between failure notifications per connection |
warningEmail |
Comma-separated emails for expiry warnings | |
warningThresholdDays |
7,3,1 |
Days before expiry to send warnings |
debounceHours |
20 |
Min. gap between warning emails per connection |
Usage
Backend Module
The module is available at System > OAuth Services (admin only). It lists all configured clients with their connections, token status, and expiry info.
Registering a Provider
Providers are registered via a DI tag — ProviderRegistry's constructor consumes a tagged iterator and populates itself at container build time. This makes registered providers visible in any bootstrap mode, including the TYPO3 Install Tool's failsafe boot (where extension ext_localconf.php files are NOT executed). Use this for any code path the Install Tool might hit, such as the "Test Mail Setup" form when a mail transport depends on OAuth tokens.
Recommended: Configuration/Services.yaml
services: _defaults: autowire: true autoconfigure: true public: false # … your other services … my_extension.provider_definition: class: WapplerSystems\OauthService\Provider\ProviderDefinition autowire: false arguments: $identifier: 'my_provider' $title: 'My Provider' $type: 'generic_oauth2' $authorizationUrl: 'https://provider.example/oauth/authorize' $tokenUrl: 'https://provider.example/oauth/token' $defaultScopes: ['read', 'write'] tags: - 'oauth_service.provider_definition'
Equivalent: Configuration/Services.php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use WapplerSystems\OauthService\Provider\ProviderDefinition; return static function (ContainerConfigurator $container): void { $services = $container->services() ->defaults() ->autowire() ->autoconfigure(); $services->load('Vendor\\MyExtension\\', __DIR__ . '/../Classes/*'); $services->set('my_extension.provider_definition', ProviderDefinition::class) ->autowire(false) ->args([ '$identifier' => 'my_provider', '$title' => 'My Provider', '$type' => 'generic_oauth2', '$authorizationUrl' => 'https://provider.example/oauth/authorize', '$tokenUrl' => 'https://provider.example/oauth/token', '$defaultScopes' => ['read', 'write'], ]) ->tag('oauth_service.provider_definition'); };
Legacy: imperative registration
Older releases registered providers via ext_localconf.php:
$registry = GeneralUtility::makeInstance(ProviderRegistryInterface::class); $registry->register(new ProviderDefinition( identifier: 'my_provider', title: 'My Provider', type: 'generic_oauth2', /* … */ ));
This still works — register() is idempotent by identifier, so existing code is not broken by the DI-tag mechanism. However, providers registered only this way are invisible to the Install Tool's failsafe bootstrap, so prefer the DI-tag pattern above.
Retrieving Tokens
Use OAuthClientService to get decrypted access tokens:
use WapplerSystems\OauthService\Service\OAuthClientService; class MyService { public function __construct( private readonly OAuthClientService $oAuthClientService, ) {} public function callApi(): void { $connection = $this->oAuthClientService->getActiveConnectionByProvider('my_provider'); $accessToken = $connection['access_token']; // use $accessToken for API calls } }
Console Commands
Refresh expiring tokens (recommended: every 5 minutes via scheduler):
typo3 oauth-service:refresh-tokens typo3 oauth-service:refresh-tokens --uid 3 --force typo3 oauth-service:refresh-tokens --threshold 600
Monitor connections (recommended: daily):
typo3 oauth-service:monitor-connections
Security
- All tokens and client secrets are encrypted with libsodium (XSalsa20-Poly1305)
- CSRF protection via state parameter with SHA-256 hash and 10-minute timeout
- PKCE (S256) on every authorization code flow
- Token fields are read-only in the backend UI
License
GPL-2.0-or-later
wapplersystems/oauth-service 适用场景与选型建议
wapplersystems/oauth-service 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 78 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Authentication」 「oauth」 「oauth2」 「extension」 「typo3」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wapplersystems/oauth-service 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wapplersystems/oauth-service 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wapplersystems/oauth-service 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
WeChat OAuth SDK
Automatically logs-in users if they are already authenticated by a remote source. (e.g. environment variable REMOTE_USER)
GraphQL authentication for your headless Craft CMS applications.
Ory-Hydra OAuth 2.0 Client Provider for The PHP League OAuth2-Client
Library for ORCID web services
A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.
统计信息
- 总下载量: 78
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 41
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2026-04-21