相关疑难解决方法(0)

如何在Spring的CAS服务属性中正确设置服务URL

使用Spring Security + CAS时,我会一直使用发送到CAS的回调URL(即服务属性)来触及一个小路障.我已经看了一堆的例子,如,但它们都使用硬编码网址(甚至Spring的CAS文档).一个典型的剪辑看起来像这样......

  <bean id="serviceProperties" class="org.springframework.security.ui.cas.ServiceProperties">
    <property name="service" value="http://localhost:8080/click/j_spring_cas_security_check" />
  </bean>
Run Code Online (Sandbox Code Playgroud)

首先,我不想硬编码服务器名称或端口,因为我希望这个WAR可以在任何地方部署,我不希望我的应用程序在编译时绑定到特定的DNS条目.其次,我不明白为什么Spring无法自动检测我的应用程序的上下文和请求的URL来自动构建URL.该声明的第一部分仍然有效,但As Raghuram通过此链接指出,出于安全原因,我们无法信任来自客户端的HTTP Host Header.

理想情况下,我希望服务URL完全符合用户的要求(只要请求有效,例如mycompany.com的子域),所以它是无缝的,或者至少我只想指定一些相对于我的路径应用程序上下文root并让Spring动态确定服务URL.像下面这样的东西......

  <bean id="serviceProperties" class="org.springframework.security.ui.cas.ServiceProperties">
    <property name="service" value="/my_cas_callback" />
  </bean>
Run Code Online (Sandbox Code Playgroud)

要么...

  <bean id="serviceProperties" class="org.springframework.security.ui.cas.ServiceProperties">
    <property name="service" value="${container.and.app.derived.value.here}" />
  </bean>
Run Code Online (Sandbox Code Playgroud)

这有可能或容易,还是我错过了明显的?

java spring cas spring-security

8
推荐指数
2
解决办法
1万
查看次数

标签 统计

cas ×1

java ×1

spring ×1

spring-security ×1