dunglas / solid-client-php
PHP 的 Solid 客户端实现
v1.0.0
2023-05-25 15:31 UTC
Requires
- php: >=8.1
- easyrdf/easyrdf: ^1.1
- jumbojett/openid-connect-php: ^0.9.10
- ml/json-ld: ^1.2
- symfony/http-client: ^6.0
- web-token/jwt-checker: ^3.0
- web-token/jwt-core: ^3.0
- web-token/jwt-key-mgmt: ^3.0
- web-token/jwt-signature: ^3.0
- web-token/jwt-signature-algorithm-ecdsa: ^3.0
- web-token/jwt-signature-algorithm-hmac: ^3.0
- web-token/jwt-signature-algorithm-rsa: ^3.0
Requires (Dev)
- symfony/browser-kit: ^6.0
- symfony/console: ^6.0
- symfony/css-selector: ^6.0
- symfony/debug-bundle: ^6.0
- symfony/dependency-injection: ^6.0
- symfony/form: ^6.0
- symfony/framework-bundle: ^6.0
- symfony/http-foundation: ^6.0
- symfony/phpunit-bridge: ^6.0
- symfony/routing: ^6.0
- symfony/security-bundle: ^6.0
- symfony/security-core: ^6.0
- symfony/stopwatch: ^6.0
- symfony/twig-bundle: ^6.0
- symfony/validator: ^6.0
- symfony/web-profiler-bundle: ^6.0
- vimeo/psalm: ^5.12
README
重新去中心化网络
Solid (源自 "social linked data")是一组建议的规范和工具,用于基于 Linked Data 原则构建 去中心化 Web 应用。
此存储库包含一个 PHP 库,用于访问存储在 Solid Pod 中的数据和管理数据权限。它还包含一个用于使用 Symfony 和 API Platform 框架轻松构建 Solid 应用的 Symfony Bundle。
查看 在 SymfonyLive Paris 2022 会议上的此库演示。
安装
composer require dunglas/solid-client-php
如果您使用 Symfony 或 API Platform,则会自动安装 bundle 和相应的配方。
示例
<?php use Dunglas\PhpSolidClient\SolidClientFactory; use Dunglas\PhpSolidClient\OidcClient; use Symfony\Component\HttpClient\HttpClient; $solidClientFactory = new SolidClientFactory(HttpClient::create()); // Create an anonymous Solid client $anonymousSolidClient = $solidClientFactory->create(); // Fetch the WebID profile of a user $profile = $anonymousSolidClient->getProfile('https://example.com/your/webid'); // Fetch the OIDC issuer for a user $oidcIssuer = $anonymousSolidClient->getOidcIssuer('https://example.com/your/webid'); // Create a Solid OIDC client for this user $oidcClient = new OidcClient($oidcIssuer); // Register the OIDC client dynamically $oidcClient->register(); // Authenticate the user $oidcClient->authenticate(); // At this point you may want to save $oidcClient in the session // The user will be redirected to the OIDC server to log in // Create a Solid client generating DPoP access tokens for the logged-in user $loggedSolidClient = $solidClientFactory->create($oidcClient); // Create a new container $containerResponse = $loggedSolidClient->createContainer('https://mypod.example.com', 'blog'); $container = $containerResponse->getContent(); // Post a new note $apiPlatformResponse = $loggedSolidClient->post('https://mypod.example.com/blog', 'api-platform-conference', <<<TTL @prefix as: <http://www.w3.org/ns/activitystreams#>. <> a as:Note; as:content "Going to API Platform Conference". TTL ); $apiPlatformCon = $apiPlatformResponse->getContent(); // Fetch an existing note $symfonyLiveResponse = $loggedSolidClient->get('https://mypod.example.com/blog/symfony-live'); $symfonyLive = $symfonyLiveResponse->getContent(); // Logout $oidcClient->signOut($oidcClient->getIdToken());
特性
- 独立的 PHP 库
- Symfony Bundle
- OAuth/OIDC 认证器
- 作为服务的 Solid 客户端
认证
- 现代且功能齐全的 OAuth 和 OpenID Connect 客户端(即使在没有 Solid 的情况下也能工作,扩展
jumbojett/openid-connect-php
)- 椭圆曲线数字签名算法 (ECDSA) JWT/JWK 密钥(使用 JWT Framework)
- 在应用层演示证明所有者(DPoP)
- Solid OIDC
身份
读取和写入资源
尚未实现
- OAuth 客户端 ID
- Solid OIDC "请求流程"(目前主流 Solid 服务器不支持)
- Web 访问控制
- WebSocket API
- 社交 Web 应用协议
- WebID-TLS(不再在网页浏览器中支持)
- Symfony Bundle
- 登录后重定向