如何在 CAS 5 中启用基于文件的身份验证
How to enable file-based authentication in CAS 5
我在我的本地机器上为 tinkering/hacking 建立了一个独立的 CAS 5 实例,我试图将它设置为一个独立的 WAR 文件部署到 Tomcat 使用简单的基于文件的身份验证。
从 WAR 覆盖模板开始(https://github.com/apereo/cas-overlay-template), I've added the following dependency as indicated at https://apereo.github.io/cas/5.0.x/installation/Whitelist-Authentication.html#example-password-file。
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-generic</artifactId>
<version>${cas.version}</version>
</dependency>
然后我在 src/main/resources
.
中创建了一个包含以下内容的简单 passwd.txt
文件
bob::bob
alice::alice
最后,我将基于文件的属性 (c.f. https://apereo.github.io/cas/5.0.x/installation/Configuration-Properties.html#file-authentication) 添加到 etc/cas/config/cas.properties
.
cas.authn.file.filename=classpath:passwd.txt
cas.authn.accept.users=
cas.authn.file.passwordEncoder.type=NONE
cas.authn.file.separator=::
当我部署应用程序时,应用程序启动,但在登录表单中接受的唯一用户是 casuser
/ Mellon
(默认值)。我什至尝试将 属性 cas.authn.policy.any.tryAll=true
添加到 cas.properties
文件,但 Alice 和 Bob 都无法识别。
是否有不同的地方我应该设置这些选项?我还需要做些什么来启用基于文件的身份验证吗?
在这个问题上花了太多时间之后,我想让其他人免于头痛。这里的关键是我在修改/etc/cas/config/cas.properties
。这在编译独立 WAR 以部署在 servlet 容器上时没有达到预期效果。我的猜测(未经验证)是,如果您正在创建可执行 JAR,它的工作方式会有所不同。
我最后做的是注释掉 /etc/cas/config/cas.properties
中的所有条目并将它们移动到 /src/main/resources/application.properties
。这有效果,但导致了一些关于 org.springframework.beans.factory.BeanCreationException: Cannot create binder factory, no META-INF/spring.binders resources found on the classpath
.
的模糊错误
我按照 https://groups.google.com/a/apereo.org/d/msg/cas-user/doLj6Aa10u8/2o9urrQpCwAJ 的建议将默认配置复制到 /src/main/resources/application.properties
,在上面添加了 cas.authn.*
选项,重建、重新部署,一切正常。
设置独立 WAR 叠加层的最佳方法似乎是采用提供的模板,从 CAS 源代码复制默认设置(https://github.com/apereo/cas/blob/958a9fbb87fb728875a7a35ee45124e818f90b17/webapp/resources/application.properties 在撰写本文时) ,添加文档指示的 Maven 依赖项,然后 add/modify 属性以获得您想要的效果。
我在我的本地机器上为 tinkering/hacking 建立了一个独立的 CAS 5 实例,我试图将它设置为一个独立的 WAR 文件部署到 Tomcat 使用简单的基于文件的身份验证。
从 WAR 覆盖模板开始(https://github.com/apereo/cas-overlay-template), I've added the following dependency as indicated at https://apereo.github.io/cas/5.0.x/installation/Whitelist-Authentication.html#example-password-file。
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-generic</artifactId>
<version>${cas.version}</version>
</dependency>
然后我在 src/main/resources
.
passwd.txt
文件
bob::bob
alice::alice
最后,我将基于文件的属性 (c.f. https://apereo.github.io/cas/5.0.x/installation/Configuration-Properties.html#file-authentication) 添加到 etc/cas/config/cas.properties
.
cas.authn.file.filename=classpath:passwd.txt
cas.authn.accept.users=
cas.authn.file.passwordEncoder.type=NONE
cas.authn.file.separator=::
当我部署应用程序时,应用程序启动,但在登录表单中接受的唯一用户是 casuser
/ Mellon
(默认值)。我什至尝试将 属性 cas.authn.policy.any.tryAll=true
添加到 cas.properties
文件,但 Alice 和 Bob 都无法识别。
是否有不同的地方我应该设置这些选项?我还需要做些什么来启用基于文件的身份验证吗?
在这个问题上花了太多时间之后,我想让其他人免于头痛。这里的关键是我在修改/etc/cas/config/cas.properties
。这在编译独立 WAR 以部署在 servlet 容器上时没有达到预期效果。我的猜测(未经验证)是,如果您正在创建可执行 JAR,它的工作方式会有所不同。
我最后做的是注释掉 /etc/cas/config/cas.properties
中的所有条目并将它们移动到 /src/main/resources/application.properties
。这有效果,但导致了一些关于 org.springframework.beans.factory.BeanCreationException: Cannot create binder factory, no META-INF/spring.binders resources found on the classpath
.
我按照 https://groups.google.com/a/apereo.org/d/msg/cas-user/doLj6Aa10u8/2o9urrQpCwAJ 的建议将默认配置复制到 /src/main/resources/application.properties
,在上面添加了 cas.authn.*
选项,重建、重新部署,一切正常。
设置独立 WAR 叠加层的最佳方法似乎是采用提供的模板,从 CAS 源代码复制默认设置(https://github.com/apereo/cas/blob/958a9fbb87fb728875a7a35ee45124e818f90b17/webapp/resources/application.properties 在撰写本文时) ,添加文档指示的 Maven 依赖项,然后 add/modify 属性以获得您想要的效果。