示例:将基于证书的身份验证与 PingFederate 集成
本示例提供了如何增强下类 SSO 环境的详细步骤:此类 SSO 环境已在 PingFederate 作为中央身份验证服务器 (CAS) 和标识提供者 (IdP) 以及 Windchill DS 作为具有基于证书的身份验证 (CBA) 的数据存储的前提下将 ThingWorx 配置为单点登录。它允许用户使用凭据或证书登录到 ThingWorx。
有关 PingFederate 文档的详细信息,请参阅
配置 X.509 证书 IdP 适配器。
第 1 部分:先决条件
步骤 1:生成证书
设置基于证书的身份验证时,可以配置 PingFederate,以便可根据 PingFederate 中存储的证书颁发机构 (CA) 证书对用于用户身份验证的证书进行验证。如果没有 CA 和用户证书,则可以生成自签名证书并在 PingFederate 中进行使用。要生成公钥和客户端证书,请使用以下命令:
1. openssl genrsa -out ptc-sso-ca.key 4096
2. openssl req -x509 -new -nodes -key ptc-sso-ca.key -days 3650 -out ptc-sso-ca.pem
3. openssl genrsa -out ptc-sso-jsmith.key 2048
4. openssl req -new -key ptc-sso-jsmith.key -out ptc-sso-jsmith.csr
5. 创建 v3.ext 文件:
extendedKeyUsage=clientAuth
keyUsage = digitalSignature
6. openssl x509 -req -in ptc-sso-jsmith.csr -CA ptc-sso-ca.pem -CAkey ptc-sso-ca.key -CAcreateserial -out ptc-sso-jsmith.pem -days 1024 -sha256 -extfile <path to v3.ext file>
7. openssl pkcs12 -export -out ptc-sso-jsmith.pfx -inkey ptc-sso-jsmith.key -in ptc-sso-jsmith.pem
步骤 2:将 CA 证书添加到 PingFederate
要使用 X.509 令牌,PingFederate 需要一个二级 SSL 端口。要设置二级 SSL 端口,可通过将 pf.secondary.https.port 的值更改为有效的端口号来编辑 <pf-install>/ping federate/bin/run.properties 文件。(本示例中端口号配置为 9032)。
步骤 3:添加受信任的 CA 证书
1. 导航至 > > 。
2. 选择 CA 颁发机构证书文件 (pem 文件)。
3. 在 Summary 窗口中,审阅配置并按需修改,然后单击 Save。
步骤 4:将用户证书存储在浏览器中
现在,将用户证书 (pfx 文件) 导入到浏览器中。
第 2 部分:创建 X509 证书 IDP 适配器
此适配器将用于根据用户证书对用户进行身份验证。
1. 以管理员身份登录 PingFederate。导航至 > > > 。单击 Create New Instance
2. 输入 Instance Name 和 Instance ID。将类型设置为 X.509 Certificate IdP Adapter 1.3.1。单击 Next。
3. 输入为 pf.secondary.https.port (9032) 指定的 Client Auth Port。对于 client hostname,输入 PingFederate 系统的 fqdn。
4. 选中 Match Issuer DN in Client X.509 certificate,然后单击 Show Advanced Fields。
5. 使用 Policy OID 设置 Authentication Context,然后选择 Include Subject Alternative Name (SAN) 选项。单击 Next。
6. 在 Extended Contract 选项卡中,使用 Add 按钮输入 userPrincipalName 和 Cn,然后单击 Next。
7. 在 Adapter Attributes 选项卡中,设置 userPrincipalName 属性的 Pseudonym 选项,然后单击 Next。
8. 在 Adapter Contract Mapping 选项卡中,您可以配置数据存储中的其他属性和 Issuance Criteria。Issuance Criteria 使用证书中提供的信息验证用户在 LDAP 中是否存在。
| 必须在 ThingWorx 中为 CBA 设置 Issuance Criteria。 |
a. 单击 Configure Adapter Contract。
b. 在 Adapter Contract Mapping 中单击 ADD Attribute Source。
c. 将 LDAP 设置为 Attribute Source Id 和 Attribute Source Description。在 Active Data Store 中,选择您的 WindchillDS 数据存储,然后单击 Next。
d. 在 LDAP Directory Search 中,提供以下参数:
i. Base DN = cn=Windchill_11.1,o=ptc
ii. Search Scope = Subtree
iii. 添加以下用户属性:uid、CN 和 Subject DN
e. 单击 Next。
f. 在 LDAP FILTER 中,设置筛选器 uid=${CN}。单击 Next 和 Done。
g. 在 Adapter Contract Fulfillment中,将 userPrincipalName 源设置为具有 uid 值的 LDAP。将所有其他合同源设置为 Adapter。单击 Next。
h. 在 Issuance Criteria 中,单击 Show Advanced Criteria。
i. 添加以下 Expression:#this.get("ds.LDAP.uid").hasValue(#this.get("CN").getValue())
ii. 提供 Error Result,例如“未找到用户”
iii. 单击 ADD。
9. 单击 Next,然后单击 Save
第 3 部分:将证书适配器添加到 SP 连接
1. 以管理员身份登录 PingFederate。导航至 > > 。选择连接名称。
2. 单击 > 。
3. 在 Adapter Instance 选项卡中,选择在第 2 部分中创建的适配器名称。单击 Next。
4. 将各种属性映射到适配器值或动态文本值。
5. 单击 Next,然后单击 Save。