【问题标题】:Enable REST service for CAS Apereo version cas-overlay-template-6.0为 CAS Apereo 版本 cas-overlay-template-6.0 启用 REST 服务
【发布时间】:2020-04-19 01:24:02
【问题描述】:

我想为 CAS Apereo 版本 cas-overlay-template-6.0(在 Ubuntu 16.04 上)启用 REST 服务

我已经完成了这一步:

第 1 步:将 REST API 的编译添加到 build.gradle 文件中

root@ubuntu16:~/cas-overlay-template-6.0# nano build.gradle
And add two line below under dependencies clock
compile "org.apereo.cas:cas-server-support-rest:6.0.0"
compile "org.apereo.cas:cas-server-support-rest-services:6.0.0"

第 2 步:干净构建

root@ubuntu16:~/cas-overlay-template-6.0# ./build.sh clean

第 3 步:再次构建源代码

root@ubuntu16:~/cas-overlay-template-6.0# ./build.sh run

但在第 3 步中,我遇到了这样的错误。

CAS is configured to accept a static list of credentials for authentication. While this is generally    useful for demo purposes, it is STRONGLY recommended that you DISABLE this authentication method (by     setting 'cas.authn.accept.users' to a blank value) and switch to a mode that is more suitable for production.>
2019-12-30 01:17:55,465 WARN [org.apereo.cas.config.support.authentication.AcceptUsersAuthenticationEventExecutionPlanConfiguration] - <>
2019-12-30 01:17:55,806 INFO [org.apereo.cas.config.CasPersonDirectoryConfiguration] - <Found and added static attributes [[email]] to the list of candidate attribute repositories>
2019-12-30 01:17:59,004 WARN [org.apereo.cas.web.CasWebApplicationContext] - <Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'registeredServiceResourceRestController' defined in class path resource [org/apereo/cas/support/rest/config/RestServicesConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apereo.cas.support.rest.RegisteredServiceResource]: Factory method 'registeredServiceResourceRestController' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: No attribute name is defined to enforce authorization when adding services via CAS REST APIs. This is likely due to misconfiguration in CAS settings where the attribute name definition is absent>

我哪里出错了?

【问题讨论】:

    标签: single-sign-on cas apereo


    【解决方案1】:

    删除这个:

    compile "org.apereo.cas:cas-server-support-rest-services:6.0.0"
    

    这个模块是这样做的:

    调用 CAS 将应用程序注册到它自己的服务注册表中。 REST 调用必须使用基本身份验证进行身份验证,其中凭据通过现有的 CAS 身份验证策略进行身份验证和接受,此外,必须使用预先配置的角色/属性名称和值授权经过身份验证的主体,该名称和值在 CAS 配置中通过CAS 属性。请求的主体必须是以 JSON 格式注册的服务定义,当然,CAS 必须配置为接受主体中定义的特定服务类型。此请求接受的媒体类型是 application/json。

    因此,如果您不需要该功能,可以将其删除。

    如果您确实需要它,您将需要定义可以强制授权的属性名称/值,因为错误消息告诉您。

    通过 CAS REST API 添加服务时,未定义任何属性名称来强制授权。这可能是由于缺少属性名称定义的 CAS 设置中的错误配置。

    所以,定义:

    # cas.rest.attributeName=
    # cas.rest.attributeValue=
    

    PS 不要添加你不需要的东西。

    【讨论】:

    猜你喜欢
    • 2022-10-19
    • 2020-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-09
    • 1970-01-01
    • 2018-07-11
    • 1970-01-01
    相关资源
    最近更新 更多