dpc-sdp / tide_authenticated_content
允许内容管理员通过用户认证保护页面和部分
Requires
- dpc-sdp/tide_core: ^4.0.0
- dpc-sdp/tide_event: ^4.0.0
- dpc-sdp/tide_landing_page: ^4.0.0
- dpc-sdp/tide_media: ^4.0.0
- dpc-sdp/tide_site: ^4.0.0
- drupal/jsonapi_extras: ^3.8
- drupal/jwt: ^1.0
- drupal/permissions_by_term: ^3.1
- dev-develop
- 4.0.0-p1
- 4.0.0
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-reference
- dev-feature/explicitly-set-query-access-checked
- dev-master
- dev-release/4.0.0
- dev-release/3.0.8
- dev-remove-noncanonical-repo
- dev-feature/SDPAP-7701-JWT-throwing-errors-in-logs
- dev-release/3.0.6
- dev-release/3.0.5
- dev-bug/add-config-jwt-timeout
- dev-test-branch
- dev-feature/json-api-routes-configurations
- dev-feature/poc-branch
- dev-feature/update-permissions-by-term
- dev-feature/SDPA-3810-update-labels
This package is auto-updated.
Last update: 2024-09-23 07:21:35 UTC
README
Tide发行版的认证内容功能。
- 暴露了注册、登录、重置和忘记密码的新自定义API端点。
- 为用户添加“site”字段以显示正确的前端登录/重置URL。
- 添加模块配置选项以设置后端用户。
- 更新激活和重置密码电子邮件,包含用户站点的后端URL。
- 添加“user_authentication_block”段落,在前端显示登录表单,并将用户导向所选页面。
- 添加用于保护内容的“Restricted Content”术语词汇表。
注册
- 接受标准用户字段,姓名,电子邮件,密码 + 客户字段“field_”...
- 前端用户将被分配他们注册的站点。
- 站点配置必须设置为“访客”或“访客需管理员批准”注册,否则请求将被拒绝。
配置
Drupal配置
在着陆页上启用认证内容字段
/admin/structure/types/manage/landing_page/form-display
- 将“认证内容”拖动到顶部以启用
将认证内容登录段落添加到着陆页
admin/structure/types/manage/landing_page/fields/node.landing_page.field_landing_page_component
- 启用“认证内容”
创建和安装私钥
openssl genrsa -out /tmp/private.key 2048 && cat /tmp/private.key
在此粘贴密钥: /admin/config/system/keys/add
为JWT发行者设置密钥
/admin/config/system/jwt
- 算法:使用SHA-256的RSASSA-PKCS1-v1_5 (RS256)
- 密钥
配置选项
以下配置选项存在,可以导出供您的网站使用:backend_user_roles是考虑为“后端”角色的Drupal角色的列表。使用密码重置功能但不在这些角色中的用户,将在他们的重置电子邮件中的URL切换到在tide_site模块中定义的当前Drupal安装的网站的前端URL。
backend_user_roles:
- "administrator"
- "editor"
- "approver"
auto_apply_user_roles与backend_user_roles类似。在此列表中定义的角色将被自动分配给通过API注册的新用户。
auto_apply_user_roles:
- "member"
default_site_id是在未定义其他站点的情况下使用的默认站点ID。它与backend_user_roles一起定义了用于输出密码重置电子邮件的前端URL。
default_site_id: 1
block_be_user_registration是布尔值。如果设置为1,则将阻止用户通过Drupal界面注册。这是为了允许网站Drupal设置允许通过API进行用户注册,同时阻止CMS的注册。
block_be_user_registration: 1
protect_jsonapi_user_route是布尔值。使用jsonapi_user_route值来保护特定的json api路由。
protect_jsonapi_user_route: 1
jsonapi_user_route是字符串数组。添加需要保护的路线,例如/api/v1/user/user
路由将受到外部访问的保护。
jsonapi_user_route:
- "/api/v1/user/user"
用法 - 内容管理员
添加术语
/admin/structure/taxonomy/manage/authenticated_content/add
- 设置名称
- 设置权限
添加认证内容
/node/add/landing_page
- 标题: ...
- 保护内容: <上面术语的名称>
发布页面
添加认证内容 - 登录页面
/node/add/landing_page
- 标题: ...
- 保护内容:留空(对公众开放)
- 正文
- 添加 认证内容
- 设置下一页: <认证内容页面标题>
发布页面
用法(API认证)
注册
POST: /api/v1/user/register
{ "mail": "jason+13@portable.com.au", "pass": "tester-13" }
成功状态 200
{ "message": "User account requested" }
失败状态 400
{ "message": "User Registration Failed" }
错误状态 500 HTML/文本错误
登录请求
POST /api/v1/user/login?_format=json
{ "name": "user@example.com", "pass": "tester2" }
状态码:200
{ "current_user": { "uid": "6105", "name": "<email>@<domain>" }, "csrf_token": "pl-6J8a832zq2fP6IHNShBgeWrT0hmqoW7tfGUrCYEs", "logout_token": "4OlOTkjv-DHqzrc6amms1lZCMybNQjRODPlhH-YY8vE", "auth_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1Ni...cSsJ-i3j1EsHSKo6O_A" }
失败状态:400
{ "message": "Sorry, unrecognized username or password." }
密码重置(请求)
POST: /api/v1/user/request_reset
{ "mail": "user@example.com" }
或者
{ "name": "username" }
成功:200
{ "message":"Forgot password email has been sent." }
失败:400
{ "message":"Forgot reset failed." }
密码重置
POST: /api/v1/user/reset_password
{ "id":6111, "time":1545219066, "hash":"IThqJHTa1ZqJbdLWRjKfPgeI9-wVlNtpkPgXf7Mx3qA", "pass":"a new password" }
成功:200
{ "message":"Forgot password email has been sent." }
失败:400
{ "message":"Password Reset Failed", }
待办事项
- 待办:实现洪水控制
- 待办:尊重站点配置以允许用户注册
- 待办:替换硬编码的链接过期时间
- 待办:一旦模块提取到自己的仓库中,则移除 @skipped。
- 待办:将硬编码的 alpha.vic.gov.au 域名替换为用户站点
- 待办:仅替换前端用户的 URL
- 待办:将后端登录链接(http://content-vicgovau.docker.amazee.io/user)替换为用户注册的前端链接(例如,自定义着陆页)