Skip to main content

用户与权限的 CAS 提供商设置

🌐 CAS provider setup for Users & Permissions

本页解释了如何为用户与权限功能设置 Auth0 提供程序。

🌐 The present page explains how to setup the Auth0 provider for the Users & Permissions feature.

Prerequisites

你已阅读 用户与权限提供程序文档

🌐 You have read the Users & Permissions providers documentation.

CAS 配置

🌐 CAS configuration

Note

可以配置一个远程 CAS 服务器以接受 localhost URL,或者你可以在本地运行自己的 CAS 服务器以接受它们。

🌐 A remote CAS server can be configured to accept localhost URLs or you can run your own CAS server locally that accepts them.

不需要使用 ngrok

🌐 The use of ngrok is not needed.

  • CAS 是一个 SSO 服务器,支持多种不同的方法来验证用户身份、获取用户属性,并通过如 SAML、OIDC 和 CAS 协议向应用传递该信息。如果 CAS 部署时支持 OIDC,Strapi 可以使用 CAS 服务器进行身份验证。
  • CAS 已经可以被你的公司或组织使用,或者你可以通过克隆 CAS Overlay 项目或使用更新的 CAS Initializr 来创建一个覆盖项目,从而设置本地CAS服务器。
  • 必须配置 CAS 服务器,以便它可以作为一个 OpenID Connect Provider运行
  • 已知 CAS 版本 6.3.x 及更高版本可与 Strapi 配合使用,但支持 OIDC 的旧版本也可以使用。
  • 为 Strapi 定义 CAS OIDC 服务并将其存储在正在使用的 CAS 服务注册表中。
  • 对于本地 Strapi 部署,CAS 服务定义可能如下所示:
{
"@class": "org.apereo.cas.services.OidcRegisteredService",
"clientId": "thestrapiclientid",
"clientSecret": "thestrapiclientsecret",
"bypassApprovalPrompt": true,
"serviceId": "^http(|s)://localhost:1337/.*",
"name": "Local Strapi",
"id": 20201103,
"evaluationOrder": 50,
"attributeReleasePolicy": {
"@class": "org.apereo.cas.services.ReturnMappedAttributeReleasePolicy",
"allowedAttributes": {
"@class": "java.util.TreeMap",
"strapiemail": "groovy { return attributes['mail'].get(0) }",
"strapiusername": "groovy { return attributes['username'].get(0) }"
}
}
}

Strapi 配置

🌐 Strapi configuration

  1. 访问用户与权限提供程序设置页面,地址为 http://localhost:1337/admin/plugins/users-permissions/providers

  2. 点击 CAS 提供商

  3. 填写信息:

    • 启用ON
    • 客户ID: thestrapiclientid
    • 客户端密钥: thestrapiclientsecret
    • 重定向到你的前端应用的 URL: http://localhost:1337/api/connect/cas/redirect
    • 提供者子域,以便以下 URL 对于你正在针对的 CAS 部署是正确的:
      authorize_url: https://[subdomain]/oidc/authorize
    access_url: https://[subdomain]/oidc/token
    profile_url: https://[subdomain]/oidc/profile

    For example, if running CAS locally with a login URL of: https://localhost:8443/cas/login, the value for the provider subdomain would be localhost:8443/cas.

你的配置已完成。启动后端和 react login example application,转到http://localhost:3000并尝试连接你配置的提供程序。