如果未注册X.509用户,则禁止CAS身份验证

问题描述 投票:1回答:2

我在X.509 authentication设置了Apereo CAS,它运行正常。我还得到了cas.authn.attributeRepository.jdbc设置,以便在用户成功进行身份验证时从数据库表中检索其他属性。

但是如果我的表中没有匹配的行,则仍然会对用户进行身份验证。他只是缺少表格列中的各种属性。在这种情况下,我希望身份验证失败。怎么可能完成?

cas
2个回答
1
投票

但是如果我的表中没有匹配的行...我希望在这种情况下验证失败。怎么可能完成?

正确的方法是查看此设置是否可以帮助您:

cas.authn.x509.principal.principalResolutionFailureFatal=true

设置说明如下:

如果为true,则返回错误,指示主分辨率已失败,并且无法根据身份验证要求找到主体。否则,只需将条件记录为错误,而不会引发灾难性错误。


1
投票

看看Enforce Attribute是不是你想要的:https://apereo.github.io/cas/5.3.x/installation/Configuring-Service-Access-Strategy.html#enforce-attributes

{
  "@class" : "org.apereo.cas.services.RegexRegisteredService",
  "serviceId" : "testId",
  "name" : "testId",
  "id" : 1,
  "accessStrategy" : {
    "@class" : "org.apereo.cas.services.DefaultRegisteredServiceAccessStrategy",
    "enabled" : true,
    "ssoEnabled" : true,
    "requiredAttributes" : {
      "@class" : "java.util.HashMap",
      "YOUR_JDBC_RETURN_ATTRIBUTE" : [ "java.util.HashSet", [ "*" ] ]
    }
  }
}

在这里,*有效,因为Enforce Attribute支持正则表达式,请看:

https://github.com/apereo/cas/blob/v5.3.9/core/cas-server-core-services-api/src/main/java/org/apereo/cas/services/DefaultRegisteredServiceAccessStrategy.java#L298

© www.soinside.com 2019 - 2024. All rights reserved.