phpway/one-auth-server
Composer 安装命令:
composer require phpway/one-auth-server
包简介
Simple OAuth2 server implementation with limited functionality designed for Single Page Applications
README 文档
README
OneAuth server is very simple OAuth2 server implementation with limited functionality specifically designed for authenticating single page applications (SPA) according to the workflow described below with exclusive use of reference tokens only.
If you need a fully-featured OAuth2 server implementation, you can look up the official OAuth page https://oauth.net/code/php/.
Features
At the moment, OneAuth server provides 3 controllers:
AuthorizeController- handle requests for obtaining theAuthorization Codewhich is one-time use, short-lived random code to be used by SPA for obtaining theAccess Token.TokenController- handle requests for obtaining theAccess Token.ResourceController- to verify API requests.
Request data required for each controller together with response details are described in the workflow below.
Since OneAuth server is designed for authenticating SPAs, all communication between OneAuth server and the client app is transparent to the user (either via url search params, or via sending form data in POST requests), meaning there is no back channel for exchanging data between these two entities.
Thus, there is no client secret in the workflow as the SPA has no mechanism to hide it. But it uses PKCE protection that requires the client app sending code verifier (random string) hash in the initial request for the authorization code, and then sending code verifier in plain text when exchanging this authorization code for the access token.
PSR-7 Request / Response
OneAuth server uses PSR-7 compatible request and response objects for handling requests to obtain authorization codes and/or access tokens. Thus, you will need to provide a PSR-7 implementation that best fits your application. Here are few options you can choose from:
- Slim-Psr7 - Slim Framework PSR-7 implementation
- httpsoft/http-message & httpsoft/http-server-request - Fast, strict and lightweight implementation
To send the response to the client, you will also need to implement a response emitter, or use an existing one (for example ResponseEmitter.php from the Slim framework).
SPA Workflow
TODOs
- Add resource controller for protecting APIs
- Recognize token in headers
- Recognize token in GET
- Recognize token in POST
- Implement revoking tokens
- Individual token
- All for given user
- Add functionality for refresh tokens
phpway/one-auth-server 适用场景与选型建议
phpway/one-auth-server 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 05 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「oauth2」 「SPA」 「one-auth」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 phpway/one-auth-server 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phpway/one-auth-server 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 phpway/one-auth-server 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
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.
A Laravel-Nuxt starter project template.
Email Toolkit Plugin for CakePHP
Appui DOM Interface
The missing social authentication for thephpleague/oauth2-server, adapted from schedula/league-oauth2-social
A Laravel-Vue SPA starter project template with Tailwind CSS integration.
统计信息
- 总下载量: 18
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-31
