claroline / remote-user-synchronization-bundle
Claroline 远程用户同步插件
Requires
- php: >=5.5
- claroline/core-bundle: ~6.0
This package is auto-updated.
Last update: 2024-09-13 21:15:42 UTC
README
############################################################
Claroline Connect 的远程用户同步插件
############################################################
| 描述 |
此插件定义了一个可以通过允许的远程客户端调用的 POST 方法。该方法首先通过将提供的令牌与平台管理参数中定义的安全令牌列表进行校验,检查客户端是否授权,然后,如果客户端授权,根据给定数据创建或更新用户。
可以通过此方法修改(或仅创建)的用户数据包括:- 用户名 - 首名 - 姓氏 - 电子邮件地址 - 密码 - 工作空间注册
| 要求 |
-
"claroline/core-bundle": ">=3.2"
-
必须在 "管理 > 参数 > 安全令牌管理" 中创建和配置一个安全令牌。
此安全令牌由以下定义
- 名称:客户端名称
- IP 地址:客户端 IP 地址
- 令牌:安全令牌
| 使用 |
-
必须调用的 URL:"[PATH TO app.php|app_dev.php]/remote-user-synchronization/remote/user/sync"
-
HTTP 请求方法类型:"POST"
-
HTTP 请求内容类型:"application/json"
-
POST 数据格式
{ 'client': '', 'token': '', 'username': '', 'firstName': '', 'lastName': '', 'email': '', 'password': '', 'workspaces': [ { '': '' }, { '': '' }, { '': '' }, ... ], 'userId': }
-
字段说明
必需:client, token, username, firstName, lastName, email, password 可选:workspaces, userId
出于安全考虑
- client : It must match the name of a security token defined in administration. - token : It must match the token of the security token defined in administration associated to the client given above. * In addition the IP address of the client is retrieved. So the threesome "client", "token" and "IP address" must match a security token defined in administration.
用于用户同步
- username, firstName, lastName, email, password : These fields are simply used to filled the corresponding properties of the user who is created or updated. - workspaces : It defines the list of the workspaces where the user is registered. The user is registered to workspaces defined in the list and unregistered from those not present (Excepted the workspaces whose the user is the creator/owner). If the "workspaces" field is not defined the user will be unregistered from all the workspaces he is registered to (Excepted the workspaces whose the user is the creator/owner). This array is composed of associative arrays of the following format : { <Worspace code>: <Translation key of a workspace role> } * The associative array can only contain 1 element. * The key of the associative array is the code of a workspace. * The value of the associative array is the translation key of a role of the workspace whose code matches the key of the associative array. - userId : If defined the user whose id is equal to given 'userId' is updated. Otherwise a new user is created.
| 响应 |
-
成功
- 状态:200
- 正文:[创建/同步用户的 ID]
- 创建/更新的用户会话 cookie 可在响应头中找到
-
缺少 'client','token' 或 'client','token' 和 'IP 地址' 与管理中定义的安全令牌不匹配
- 抛出 AccessDeniedException
- 状态:403
- 正文:'拒绝访问'
-
缺少 'username','firstName','lastName','email' 或 'password'
- 状态:400
- 正文:'错误请求'
-
'userId' 已定义,但关联的用户在平台中找不到
- 状态:404
- 正文:'未找到'
-
由于数据格式不正确或唯一性约束,无法创建或更新用户
- 状态:400
- 正文:'用户编辑错误'
| 示例 |
-
首先需要在 "管理 > 参数 > 安全令牌管理" 中创建一个安全令牌
- 名称:Claroline
- IP 地址:127.0.0.1
- 令牌:xxxxxxxxxx
-
然后,以下是要发送以创建新用户并将其注册到工作空间 'Course 1 (C001)'(角色 'collaborator')和工作空间 'Course 2 (C002)'(自定义角色 'custom-role-C002')的数据示例
{ 'client': 'Claroline', 'token': 'xxxxxxxxxx', 'username': 'JohnDoe', 'firstName': 'John', 'lastName': 'Doe', 'email': 'jonh.doe@claroline.net', 'password': 'xyz123', 'workspaces': [ { 'C001': 'collaborator' }, { 'C002': 'custom-role-C002' } ] }
新创建用户的 ID 作为响应返回。他的用户会话 cookie 可在响应头中找到。对于此示例,返回的值是 12。
-
以下是一个示例,展示了需要发送的数据,用于更新现有用户的密码,并注册他为“Course 3 (C003)”工作空间中的“manager”角色,并从“Course 2 (C002)”工作空间中注销。
{ 'client': 'Claroline', 'token': 'xxxxxxxxxx', 'username': 'JohnDoe', 'firstName': 'John', 'lastName': 'Doe', 'email': 'jonh.doe@claroline.net', 'password': 'new-password-123', 'workspaces': [ { 'C001': 'collaborator' }, { 'C003': 'manager' } ], 'userId': 12 }