FastComments.com

FastComments PHP SSO SDK


这是 FastComments 的官方 PHP SSO SDK。

用于 FastComments SSO 集成的 PHP SDK

仓库

在 GitHub 上查看


安装 Internal Link

composer require fastcomments/sso

使用 Internal Link

简单 SSO

简单 SSO 使用起来很直接,但比安全 SSO 提供的安全性要低:

use FastComments\SSO\FastCommentsSSO;
use FastComments\SSO\SimpleSSOUserData;

// 创建用户数据
$userData = SimpleSSOUserData::create(
    'username123',
    'user@example.com',
    'https://example.com/avatar.png'
);

// 使用基于 URL 的登录/登出
$sso = FastCommentsSSO::createWithUrls(
    null,
    $userData,
    'https://example.com/login',
    'https://example.com/logout'
);

// 或使用回调
$sso = FastCommentsSSO::createWithCallbacks(
    $userData,
    function($url) { /* 处理登录 */ },
    function($url) { /* 处理登出 */ }
);

// 获取要传递给 FastComments 的令牌
$token = $sso->prepareToSend();

安全 SSO

安全 SSO 通过 HMAC 验证提供增强的安全性:

use FastComments\SSO\FastCommentsSSO;
use FastComments\SSO\SecureSSOUserData;

// 创建用户数据
$userData = SecureSSOUserData::create(
    'user-123',
    'user@example.com',
    'username123',
    'https://example.com/avatar.png'
);

// 如有需要,添加可选数据
$userData->isAdmin = true;
$userData->groupIds = ['group-1', 'group-2'];

// 使用您的 API 密钥创建 SSO 对象
$sso = FastCommentsSSO::createSecure('your-api-key', $userData);

// 获取要传递给 FastComments 的令牌
$token = $sso->prepareToSend();

文档 Internal Link


有关 FastComments SSO 的完整文档,请参阅 FastComments 文档.

需要帮助?

如果您在使用 PHP SSO SDK 时遇到任何问题或有任何疑问,请:

贡献

欢迎贡献!请访问 GitHub 仓库 查阅贡献指南。