Download the PHP package wiseadmin/wise-oauth without Composer
On this page you can find all versions of the php package wiseadmin/wise-oauth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package wise-oauth
wiseadmin/wise-oauth
为 ThinkPHP 6/8 提供的第三方 OAuth 登录包——支持微信/QQ/GitHub/钉钉/Google/微博/码云八大平台,自动关联或创建账号,多账号绑定解绑,零外部依赖。
特性
| 模块 | 说明 |
|---|---|
| 8 个内置平台 | 微信开放平台、微信公众号、QQ 互联、GitHub、钉钉、Google、微博、码云(Gitee) |
| 零外部依赖 | 纯 PHP 实现,仅需 PHP >= 8.0 + ThinkPHP 6/8 |
| 自动登录/注册 | OAuthUserResolver 五级匹配链(unionId → openid → email → mobile → 创建新用户) |
| 多账号绑定 | 一个平台账号可绑定多个本地用户,一个本地用户可绑定多个平台 |
| State/CSRF 防护 | OAuthStateManager 内置 CSRF 防护,可选 PKCE(RFC 7636)增强安全性 |
| Token 加密存储 | OAuthTokenEncryptor AES-256-CBC 加密 access_token/refresh_token |
| HasOAuth Trait | Admin/Member 挂载即获绑定/解绑/查询能力 |
| 多态绑定表 | oauth_users 表(user_type + user_id),不侵入用户原表 |
| 双控制器 | AdminOAuthController(Session + redirect) / ApiOAuthController(JWT + JSON) |
| 事件驱动 | OAuthUserLoggedIn / OAuthUserRegistered / OAuthUserBound / OAuthUserUnbound |
| Facade 门面 | OAuth::getAuthUrl() / OAuth::handleCallback() 一行搞定 |
安装
配置
发布配置和数据库迁移:
配置文件 config/wise-oauth.php:
使用指南
1. 用户模型接入(HasOAuth Trait)
HasOAuth 提供以下方法:
| 方法 | 说明 |
|---|---|
getOAuthBindings() |
获取所有绑定列表 |
bindOAuth(OAuthUserInfo $info) |
绑定平台账号 |
unbindOAuth(string $platform) |
解绑平台账号 |
hasOAuthBinding(string $platform) |
检查绑定状态 |
getOAuthUserByPlatform(string $platform) |
通过平台查询绑定 |
2. 获取授权跳转 URL
3. 处理 OAuth 回调
4. 绑定/解绑账号
5. 在模型中直接操作
6. OAuthUserInfo 结构
回调返回的标准化用户信息:
7. 事件监听
8. 自定义驱动
平台配置速查
| 平台 | 标识 | 申请地址 |
|---|---|---|
| GitHub | github |
https://github.com/settings/developers |
| 码云 | gitee |
https://gitee.com/oauth_applications |
google |
https://console.cloud.google.com/apis/credentials | |
| QQ 互联 | qq |
https://connect.qq.com |
| 微信开放平台 | wechat_open |
https://open.weixin.qq.com |
| 微信公众号 | wechat_mp |
https://mp.weixin.qq.com |
| 钉钉 | dingtalk |
https://open.dingtalk.com |
| 微博 | weibo |
https://open.weibo.com |
目录结构
License
MIT
All versions of wise-oauth with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.1
topthink/framework Version ^8.0
wiseadmin/wise-support Version 1.0.*
ext-json Version *
topthink/framework Version ^8.0
wiseadmin/wise-support Version 1.0.*
ext-json Version *
The package wiseadmin/wise-oauth contains the following files
Loading the files please wait ...