【问题标题】:CAS authentication failing with Drupal but working as standaloneDrupal 的 CAS 身份验证失败,但可以独立运行
【发布时间】:2019-01-24 13:26:48
【问题描述】:

我正在尝试在本地设置 CAS 服务器,并且我也在本地运行 Drupal。我将 Mongo DB 用于 CAS ticket registryuser authentication。对于 CAS 服务注册表,我使用基于文件的 JSON service registry

我的服务注册表:

{
  "@class": "org.apereo.cas.services.RegexRegisteredService",
  "id": 3,
  "serviceId": "http(s)?:\\/\\/relo.local(:\\d{4,5})?(\\/.*)?$",
  "name": "relo.local",
  "evaluationOrder": 10,
  "accessStrategy": {
    "@class": "org.apereo.cas.services.DefaultRegisteredServiceAccessStrategy",
    "enabled": true,
    "ssoEnabled": true
  },
  "attributeReleasePolicy": {
    "@class": "org.apereo.cas.services.ReturnAllAttributeReleasePolicy"
  }
}

在 MongoDB 中,我创建了一个名为 accounts 的集合,其中我创建了一些虚拟用户记录,如下所示:

/* 1 */
{
    "_id" : ObjectId("5c24f234e51c56a02af5873f"),
    "username" : "casuser",
    "password" : "casuser",
    "firstname" : "wohn",
    "lastname" : "smith",
    "mail" : "casuser@test.com"
}

/* 2 */
{
    "_id" : ObjectId("5c24f24de51c56a02af58757"),
    "username" : "wasuser",
    "password" : "wasuser",
    "firstname" : "wohn",
    "lastname" : "smith",
    "mail" : "wasuser@test.com"
}

对于票据注册表,我不需要创建任何集合。 CAS 负责创建票证注册表集合并在我尝试登录时在其中插入一条记录。

Drupal 正在使用 cas 模块,该模块使用 phpCAS 库与 CAS 服务器连接。

  • Drupal 版本:7.34
  • phpCAS 版本:1.3.0
  • CAS 版本:6.1.0-RC1-SNAPSHOT

CAS 提供自己的登录屏幕。完成所有这些配置后,我可以使用 casuserwasuser 帐户登录 CAS 服务器。

我的 cas.properties 文件:

# Required CAS settings
cas.server.name=https://localhost:8443
cas.server.prefix=${cas.server.name}/cas

# Log4j config file location
logging.config: file:/etc/cas/config/log4j2.xml
# Control log levels via properties
logging.level.org.apereo.cas=DEBUG

# Restrict admin endpoints (like /status) to localhost
# cas.adminPagesSecurity.ip=127\.0\.0\.1

# Authenticate if any handler succeeds
cas.authn.policy.any.tryAll=false

# Disable authentication with a static list of credentials
# If below line is commented then you can use default
# username/password:casuser/Mellon
cas.authn.accept.users=ram::ram,shyam::shyam

# Ticket Grant Cookie (TGC) encryption key
cas.tgc.crypto.encryption.key=<my key>
# Ticket Grant Cookie (TGC) Signing key
cas.tgc.crypto.signing.key=<my key>

# Webflow encryption key
cas.webflow.crypto.encryption.key=<my key>
# Webflow signing key
cas.webflow.crypto.signing.key=<my key>

# Embedded Tomcat settings
server.servlet.context-path=/cas
server.port=8443
server.ssl.keyStore=file:/etc/cas/thekeystore
server.ssl.keyStorePassword=changeit
server.ssl.keyPassword=changeit

# JSON Service Registry
cas.serviceRegistry.json.location=file:/etc/cas/config/services-staging

# MongoDb Ticket registry
cas.ticket.registry.mongo.host=localhost
cas.ticket.registry.mongo.port=27017
cas.ticket.registry.mongo.userId=casDbAdmin
cas.ticket.registry.mongo.password=admin
cas.ticket.registry.mongo.databaseName=casdb
cas.ticket.registry.mongo.authenticationDatabaseName=casdb


# MongoDb Authentication
cas.authn.mongo.host=localhost
cas.authn.mongo.port=27017
cas.authn.mongo.userId=casDbAdmin
cas.authn.mongo.password=admin
cas.authn.mongo.databaseName=casdb
cas.authn.mongo.authenticationDatabaseName=casdb
cas.authn.mongo.usernameAttribute=username
cas.authn.mongo.attributes=
cas.authn.mongo.passwordAttribute=password
cas.authn.mongo.collection=accounts

# Authentication Policy
cas.authn.policy.requiredHandlerAuthenticationPolicyEnabled=true

# Default attributes.
cas.authn.attributeRepository.defaultAttributesToRelease=firstname,lastname,mail

# Spring Webflow
cas.webflow.autoconfigure=true
cas.webflow.alwaysPauseRedirect=false
cas.webflow.refresh=true
cas.webflow.redirectSameState=false

cas.webflow.session.lockTimeout=30
cas.webflow.session.compress=false
cas.webflow.session.maxConversations=5
cas.webflow.session.storage=true

我已将 Drupal 配置为使用本地 CAS 服务器进行身份验证。当我尝试访问 Drupal 时,它会将我重定向到 CAS 登录屏幕。将凭据放入登录表单并提交后失败并显示以下错误,我无法弄清楚。我不是很擅长JAVA。 CAS 已嵌入 Spring webflow。我认为该错误与webflow有关。在身份验证过程中,CAS 有一个叫做原则解析和属性解析的东西,它决定使用哪个身份验证处理程序以及响应附加多少属性。

错误:

2019-01-24 14:35:32,348 INFO [org.apereo.inspektr.audit.support.Slf4jLoggingAuditTrailManager] - <Audit trail record BEGIN
=============================================================
WHO: casuser
WHAT: TGT-5-*****b6YD2V8OBQ4X-jet
ACTION: TICKET_GRANTING_TICKET_CREATED
APPLICATION: CAS
WHEN: Thu Jan 24 14:35:32 IST 2019
CLIENT IP ADDRESS: 0:0:0:0:0:0:0:1
SERVER IP ADDRESS: 0:0:0:0:0:0:0:1
=============================================================

>
2019-01-24 14:35:32,353 ERROR [org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/cas].[dispatcherServlet]] - <Servlet.service() for servlet [dispatcherServlet] in context with path [/cas] threw exception [Request processing failed; nested exception is org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing org.apereo.cas.web.flow.GenerateServiceTicketAction@147375b3 in state 'generateServiceTicket' of flow 'login' -- action execution attributes were 'map[[empty]]'] with root cause>
java.lang.NullPointerException: null

完整的错误堆栈跟踪: https://pastebin.com/vEvcvFte

感谢任何帮助。我几天来一直在为这个错误而苦苦挣扎,但我无法弄清楚这个问题。请帮忙。

【问题讨论】:

    标签: drupal cas


    【解决方案1】:

    您可能需要考虑强制更新您的 SNAPSHOT。虽然您的日志没有显示提交 ID,但您可能正在运行一个旧版本,该版本的错误已被修复。如果您检查项目的自述文件,您将找到有关如何通过 Gradle 更新快照版本的说明。

    【讨论】:

    • 我的一位同事拥有具有相同配置的 CAS 5.2 版本,他也面临同样的问题。我会尝试更新我的 CAS。
    猜你喜欢
    • 2018-07-11
    • 2023-03-31
    • 2013-09-22
    • 2013-01-02
    • 1970-01-01
    • 2013-04-15
    • 2014-01-24
    相关资源
    最近更新 更多