eduplex-api / cake-api-lti
CakePHP 的 LTI 插件
0.1.14
2024-08-07 10:00 UTC
Requires
- php: >=7.2
- ext-json: *
- cakephp/cakephp: ^4.3
- cakephp/migrations: ^3.2
- ct-imsglobal/lti-1p3-tool: 0.1.6
- firebase/php-jwt: 5.*
- freefri/cake-rest-api: ^0.5.18
Requires (Dev)
- freefri/cake-rest-api-fake-app: ^0.1.3
- phpunit/phpunit: ^8.5 || ^9.3
README
LTI 实现
兼容性
与运行在 cake-rest-api 之上的 CakePHP 插件兼容。
设置
一些设置需要在平台和工具之间手动交换。
工具提供的设置
- 工具 URL: https://www.example.com/launch/
- 启动登录 URL
Platform.LTI.toolLoginUrl
: https://www.example.com/login/ - 重定向 URL(S)
Platform.LTI.toolRedirectionUrl
: https://www.example.com/launch/ - 公钥集 URL
Platform.LTI.toolKeysetUrl
: https://www.example.com/jwks/
平台提供的设置
- 平台 ID/URL: https://www.example.com/api/v3/lti/platform
- 客户端 ID
Platform.LTI.clientId
: xxxxxxxx-yyyy-xxxx-yyyy-xxxxxxxxxxxx - 部署 ID
Platform.LTI.deploymentId
: xxxxxxxx-yyyy-xxxx-yyyy-xxxxxxxxxxxx - 公钥集 URL https://www.example.com/api/v3/lti/platform/jwks
- 访问令牌 URL https://www.example.com/api/v3/lti/platform/token
- 身份验证请求 URL https://www.example.com/api/v3/lti/platform/login
在平台配置设置中,我们应该存储配置值,以便通过 Configure::read('Platform.LTI.<…>')
访问。
必须生成并存储在 .env 中的 RSA 私钥 RSA_PRIVATE_KEY_BASE64
openssl ecparam -name prime256v1 -genkey -noout -out private.key
openssl ec -in private.key -pubout -out public.pem
echo "RSA_PRIVATE_KEY_BASE64=" && base64 -w 9999 private.key
Openapi 文档
在 /api/v3/lti/openapi/ 中的 Swagger UI
演示工具工作流程
以下是启动过程的流程图
sequenceDiagram
title LTI demo launch flow
participant User as User
participant Platform as LTI Platform<br>(Tool Consumer)
participant Tool as LTI Tool<br>(Tool Provider)
User->>Platform: Access Tool via iframe
Platform->>Tool: Render iframe in loginUrl
Note right of Tool: Params: <br> iss <br> lti_deployment_id <br> client_id <br> target_link_uri (redirect URI)
Tool->>Tool: do_oidc_login_redirect()
Tool->>Platform: Redirect to Platform loginUrl(client_id, redirect_uri)
Note left of Platform: Params: <br> scope <br> response_type <br> response_mode <br> prompt <br> client_id <br> redirect_uri <br> state <br> nonce
Platform->>Tool: Post form to redirect_uri
Note right of Tool: Params: <br> state <br> id_token (JWT)
Tool->>Tool: Validate JWT (LtiMessageLaunch)