安装指南 > Codebeamer 安装指南 > Codebeamer 配置 > 单一登录 (SSO) > SAML > SSO 常见问题解答和故障排除
SSO 常见问题解答和故障排除
SSO 配置和管理
要在 SSO 系统中使用 Codebeamer,必须同时配置 Codebeamer 和 SSO 系统。
要配置 SSO 系统,需要了解 SSO 系统,并具有配置 SSO 系统的管理权限。
* 
Codebeamer 支持无权访问 SSO 系统,也无法对其进行配置。在开始配置过程之前,强烈建议咨询 SSO 管理员/邀请其加入!
哪个版本的 SAML 受支持?
IdP 提供者必须支持 SAML 2.0 协议。
哪个版本的 ADFS 受支持?
支持 ADFS 2.0 或更高版本。
Codebeamer 是否支持 Azure AD?
Azure AD 正在使用并支持 SAML 2.0,因此这应该可行且受支持。但是,我们尚未使用 Azure AD 对此进行测试。
如何检查/从何处找到 Codebeamer 中的 SP 元数据?
打开 https://yourCodebeamer.domain.com/cb/saml/sp/metadata,应该能够成功下载 XML 文件。
请知悉:根据您的安装和配置,Codebeamer 基本 URL 可能不同,请尝试两个 URL:
<您的_Codebeamer>/cb/saml/sp/metadata 或 <您的_Codebeamer_基本_url>/saml/sp/metadata
如果无法下载 XML 文件,确保在“SAML 配置”页面中正确填写了“标识提供者配置”。检查 IdP 提供的 XML,并确保其已正确插入。重新启动 Codebeamer 实例,然后重试。
要让 SSO 正常运行,至少需要进行哪些配置?
转至“系统管理”-“SAML 配置”页面,然后填写所有必填字段
需要:
1. 常规配置
a. 启用 SAML 配置
b. 输入域名
c. 填写用户映射
2. 标识提供者配置
a. 可在 IdP XML 文件的 "entityID" 属性中找到 EntityID。例如:
<EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" ID="_c13d8658-35d4-4846-844d-f75a2d411228" entityID="http://fs.codebeamer.com/adfs/services/trust">
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
b. URL - 如果 IdP XML 通过 URL 提供,则可以使用此字段,而不是复制和粘贴 XML 内容
c. XML - 如果 IdP XML 无法通过 URL 提供,或者需要手动更改其中的内容。
3. 服务提供者配置
a. EntityID 可以是任意标识符,建议仅使用字母数字字符
b. 根据 IdP 配置选中复选框
c. 生成并输入活跃和备用私钥和证书 (自签名证书在此同样有效)
如何配置用户映射? 如何使用 IdP 元数据文件中的 claimType URI?
您需要设置 Codebeamer 端的属性,并将这些属性与您的标识提供者端的声明关联。
通过以下断言属性的第一个非空值完成用户帐户匹配:
ssoId
name
email
有关更多详情,请参阅此 Wiki 页面。
是否可以将以下内容用于用户映射?

{
"ssoId":"emailaddress",
"name":"name",
"email":"emailaddress"
}
这取决于您的 IdP 配置。在测试 IdP 服务器中,存在以下 claimType:
<auth:ClaimType xmlns:auth="http://docs.oasis-open.org/wsfed/authorization/200706" Optional="true" Uri="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier">
<auth:DisplayName>PPID</auth:DisplayName>
<auth:Description>The private identifier of the user</auth:Description>
</auth:ClaimType>
<auth:ClaimType xmlns:auth="http://docs.oasis-open.org/wsfed/authorization/200706" Optional="true" Uri="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname">
<auth:DisplayName>Given Name</auth:DisplayName>
<auth:Description>The given name of the user</auth:Description>
</auth:ClaimType>
<auth:ClaimType xmlns:auth="http://docs.oasis-open.org/wsfed/authorization/200706" Optional="true" Uri="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name">
<auth:DisplayName>Name</auth:DisplayName>
<auth:Description>The unique name of the user</auth:Description>
</auth:ClaimType>
对此进行以下配置:

{
"ssoId":"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier",
"name":"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name",
"email":"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"
}
我已正确填写“SAML 配置”页面,但身份验证仍然不起作用。
保存并完成“SAML 配置”后,重新启动 Codebeamer 服务。此外,每次更改 SAML 配置时,都需要重新启动 Codebeamer 服务。
备用证书的用途是什么?
如果主要证书过期,将使用次要证书。否则,IdP 可能因证书已过期而无法接受身份验证请求。
请确保次要证书的到期日期晚于主要证书,且覆盖的时间段不同。例如,如果主要证书有效期为 2020 年 1 月到 2021 年 12 月,我们建议创建覆盖 2021 年 11 月至 2022 年 11 月这一时间段的次要证书。
是否可以使用自签名证书?
是,由于这些证书仅用于加密通信,因此自签名证书将起作用,不一定必须为 CA 证书。
如何追溯从 Codebeamer 到 IdP 的请求和响应并进行排除故障?
所有通信均在浏览器中进行,您可以使用 Google Chrome 中的开发人员工具,并记录 Codebeamer 与 IdP 之间的所有请求/响应。这些通常是 Base64 编码消息。您可以使用网站 https://www.samltool.com/decode.php 对其进行解码。
我收到 NullPointerException 错误
2020-09-16 10:57.26,787 ERROR [localhost].[/].[default] - Servlet.service() for servlet [default] in context with path [] threw exception [Thread-6] [17] {Req#=-, Sess#=-, serverId=server}
java.lang.NullPointerException: null
at com.intland.codebeamer.saml.config.SamlAuthenticationRequestEnhancer.enhance(SamlAuthenticationRequestEnhancer.java:25) [cb.jar:?]
at com.intland.codebeamer.saml.config.SamlAuthenticationRequestEnhancer.enhance(SamlAuthenticationRequestEnhancer.java:20) [cb.jar:?]
at org.springframework.security.saml.provider.service.HostedServiceProviderService.authenticationRequest(HostedServiceProviderService.java:181) [spring-security-saml2-core.jar:2.0.0.M31]
检查 IdP 元数据 xml,然后检查是否存在 "NameIDFormat" 节点。如果不存在,请将此节点添加至 xml。
可将其添加至 SingleLogoutService 节点后面。例如:
<SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="https://login.com/test/saml2"/>
<NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress</NameIDFormat>
我在尝试登录时收到错误页面
如果错误在 IdP 端进行身份验证后出现并记录了 IdP 的响应,请检查日志文件。
日志应包含以下带有 "SAMLResponse" 的日志条目。例如:
com.intland.codebeamer.saml.controller.SamlSigninController.samlLogin(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse),parameters={method 'samlLogin' parameter 0,method 'samlLogin' parameter 1},responseStatus=,responseStatusReason=,resolvedFromHandlerMethod=,interfaceParameterAnnotations=[],description=com.intland.codebeamer.saml.controller.SamlSigninController#samlLogin(HttpServletRequest, HttpServletResponse)], org.springframework.web.servlet.HandlerMapping.bestMatchingPattern=/saml/sp/SSO/**, org.springframework.web.servlet.HandlerMapping.matrixVariables={} // LinkedHashMap[accessOrder=false,threshold=0,loadFactor=0.75], org.springframework.web.servlet.HandlerMapping.pathWithinHandlerMapping=/saml/sp/SSO/alias/SAML2.spr, org.springframework.web.servlet.HandlerMapping.uriTemplateVariables={} // LinkedHashMap[accessOrder=false,threshold=0,loadFactor=0.75], org.springframework.web.servlet.resource.ResourceUrlProvider=org.springframework.web.servlet.resource.ResourceUrlProvider@dfa59b // ResourceUrlProvider[logger=org.apache.commons.logging.impl.SLF4JLocationAwareLog@25aba6c3,urlPathHelper=org.springframework.web.util.UrlPathHelper@4cb50fff,pathMatcher=org.springframework.util.AntPathMatcher@4c3ddff4,handlerMap={},autodetect=true], requestId=68, userGeoLocation=false}
requestParameters={RelayState={"1ec5fb7b-c5c9-4fac-995f-07a6f50edc4b"}, SAMLResponse={"<< SAMLResponse >>"}}
user=null
throwable=com.intland.codebeamer.persistence.util.exception.codebeamerRuntimeException: org.springframework.security.authentication.InsufficientAuthenticationException: Validation Errors:
1. An error response was returned: urn:oasis:names:tc:SAML:2.0:status:Responder
复制 SAMLResponse 的内容,并在 https://www.samltool.com/decode.php 页面上对其进行解码。预期会获得一个 XML
<samlp:Response Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified" Destination="https://example.com/cb/saml/sp/SSO/alias/SAML2.spr" ID="_2c55b43a-0e7b-467b-a98e-139f08430a4c" InResponseTo="ARQa7eee9a-300d-4200-9bca-07e126b15402" IssueInstant="2020-05-04T16:37:29.208Z" Version="2.0" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
<Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">http://server.example.com/adfs/services/trust</Issuer>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
<ds:Reference URI="#_2c55b43a-0e7b-467b-a98e-139f08430a4c">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>Fbcu+lHislndMwd2wjLKdGlU645/BE2KPWDMECgZoCQ=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue><<SignatureValue>></ds:SignatureValue>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<ds:X509Data><<X509Data>></ds:X509Certificate>
</ds:X509Data>
</KeyInfo>
</ds:Signature>
<samlp:Status>
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Responder">
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:__RequestDenied__"/>
</samlp:StatusCode>
</samlp:Status>
</samlp:Response>
检查 XML 中的 "samlp:Status"。在上述给定示例中,IdP 拒绝了身份验证请求。
我收到 "InvalidNameIDPolicy" 错误
Codebeamer 日志包含具有以下响应的 XML。
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Requester">
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicy" />
</samlp:StatusCode>
检查 IdP 上的声明映射。请参阅:SAML
如何捕获 Google Chrome HAR 日志
1. 启动 Chrome。
2. 按 F12 键,或打开开发人员工具并转至“网络”选项卡,选中“保留日志”选项。
3. 登录 Codebeamer
4. 重现问题。
5. 右键单击控制台内容中的任意位置,然后选中“将所有内容另存为包含内容的 HAR”。
这对您有帮助吗?