refactor(oauth): drop the hand-written providers and keep only what the SDK ships
The previous commit added five direct clients (Douyin, Microsoft, Facebook, Twitter, Apple) written against each platform's own endpoints. Maintaining five bespoke OAuth implementations — including Apple's ES256 client secret and Twitter's PKCE — is maintenance the bundled yurunsoft SDK does not ask for, and none of them could be verified without production credentials. Only providers yurunsoft/yurun-oauth-login actually implements stay on the direct surface: GitHub, Gitee, QQ, Google, Weibo, Weixin, Baidu and Alipay. Baidu and Alipay move into OAuthProviderBroker's existing client() switch and normalize() map rather than living in a separate class, so there is no new layer to reason about. OAuthProviderClient, its harness and its contract test are deleted outright (-809 lines). The Apple form_post handling added to handle_callback() is reverted too — without Apple there is no POST callback to read. The aggregate-login channel keeps its 16 platforms, matching the reference; that list describes what the aggregation provider offers, not a local implementation. Brand icons for those names stay for the same reason. Verification: 869 widget/navigation tests pass, the PSR-4 audit reports 0 errors, and the catalog constant, PHP schema and Vue schema now list the same 16 aggregate platforms.
This commit is contained in:
1 parent
6db34646ed
commit
b1c3d86e44
8 files changed
+55
-809
No files matched your search
@@ -33,22 +33,35 @@ test('OAuth PHP behavior harness passes', () => {
|
||||
const output = execFileSync('php', [path.join(root, 'tests/widget-system/oauth-security-harness.php')], { encoding: 'utf8' })
|
||||
assert.match(output, /OAuth security harness passed/)
|
||||
})
|
||||
test('Baidu and Alipay are wired into the OAuth surface', () => {
|
||||
test('Baidu and Alipay are wired through the bundled SDK', () => {
|
||||
const catalog = read('src/Auth/OAuthProviderCatalog.php')
|
||||
const client = read('src/Auth/OAuthProviderClient.php')
|
||||
const broker = read('src/Auth/OAuthProviderBroker.php')
|
||||
const schema = read('src/Admin/Schema/SchemaUsers.php')
|
||||
|
||||
for (const provider of ['baidu', 'alipay']) {
|
||||
assert.match(catalog, new RegExp(`'${provider}'\\s*=>`), provider)
|
||||
assert.match(schema, new RegExp(`oauth_${provider}_s`), provider)
|
||||
// 两个平台都走 yurun SDK,而不是自建端点。
|
||||
assert.match(broker, new RegExp(`Yurun\\\\OAuthLogin\\\\${provider[0].toUpperCase()}${provider.slice(1)}\\\\OAuth2`), provider)
|
||||
}
|
||||
// 复用打包的 yurun SDK,而不是自己重写签名。
|
||||
assert.match(client, /Yurun\\OAuthLogin\\Baidu\\OAuth2/)
|
||||
assert.match(client, /Yurun\\OAuthLogin\\Alipay\\OAuth2/)
|
||||
// 支付宝的支付网关仍在,两者互不影响。
|
||||
assert.match(read('src/Payment/Gateways/AlipayGateway.php'), /class AlipayGateway/)
|
||||
})
|
||||
|
||||
test('未提供自建客户端的平台不进入 OAuth 表面', () => {
|
||||
const catalog = read('src/Auth/OAuthProviderCatalog.php')
|
||||
const schema = read('src/Admin/Schema/SchemaUsers.php')
|
||||
const jsSchema = read('assets/admin/src/schema/sections/users/oauth.js')
|
||||
|
||||
// 抖音 / Microsoft / Facebook / Twitter / Apple 只存在于聚合渠道,不再是直连平台。
|
||||
for (const provider of ['douyin', 'microsoft', 'facebook', 'twitter', 'apple']) {
|
||||
assert.doesNotMatch(catalog, new RegExp(`'${provider}'\\s*=>\\s*\\[`), provider)
|
||||
assert.doesNotMatch(schema, new RegExp(`oauth_${provider}_s`), provider)
|
||||
assert.doesNotMatch(jsSchema, new RegExp(`oauth_${provider}_s`), provider)
|
||||
}
|
||||
assert.equal(fs.existsSync(path.join(root, 'src/Auth/OAuthProviderClient.php')), false)
|
||||
})
|
||||
|
||||
test('Alipay payment remains available', () => {
|
||||
const functions = read('functions.php')
|
||||
const paymentSchema = read('src/Admin/Schema/SchemaPayment.php')
|
||||
@@ -72,7 +85,7 @@ test('OAuth uses one-time transactions and no PHP sessions', () => {
|
||||
|
||||
test('provider catalog is the canonical provider list', () => {
|
||||
const catalog = read('src/Auth/OAuthProviderCatalog.php')
|
||||
const direct = ['github', 'gitee', 'qq', 'google', 'weibo', 'weixin', 'douyin', 'baidu', 'alipay', 'microsoft', 'facebook', 'twitter', 'apple']
|
||||
const direct = ['github', 'gitee', 'qq', 'google', 'weibo', 'weixin', 'baidu', 'alipay']
|
||||
for (const provider of direct) {
|
||||
assert.match(catalog, new RegExp(`'${provider}'\\s*=>`), provider)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user