3
我試圖從彈簧安全應用程序連接到cas服務器。當我在CAS中登錄時,請求被重定向到我的webapp,但在我的UserDetailsService中,我收到_cas_stateful_作爲用戶名,並且我無法在webapp中找到我的用戶加載權限jasig cas服務器返回_cas_stateful_作爲用戶名與彈簧
我試圖從彈簧安全應用程序連接到cas服務器。當我在CAS中登錄時,請求被重定向到我的webapp,但在我的UserDetailsService中,我收到_cas_stateful_作爲用戶名,並且我無法在webapp中找到我的用戶加載權限jasig cas服務器返回_cas_stateful_作爲用戶名與彈簧
問題在於authenticationManager。由於文件說,你必須使用CasAuthenticationProvider這樣的:
<beans:bean id="casAuthenticationProvider"
class="org.springframework.security.cas.authentication.CasAuthenticationProvider">
<beans:property name="authenticationUserDetailsService">
<beans:bean
class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper">
<beans:constructor-arg ref="mongoUserDetailsService" />
</beans:bean>
</beans:property>
<beans:property name="serviceProperties" ref="serviceProperties" />
<beans:property name="ticketValidator">
<beans:bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator">
<beans:constructor-arg index="0" value="https://localhost:7443/cas" />
</beans:bean>
</beans:property>
<!-- Esta clave es única por aplicación -->
<beans:property name="key" value="your-provider-auth" />
</beans:bean>
然後,你必須到casAuthenticationProvider設置到的AuthenticationManager:
<authentication-manager alias="authenticationManager">
<!-- <authentication-provider user-service-ref='mongoUserDetailsService'/> -->
<authentication-provider ref="casAuthenticationProvider" />
</authentication-manager>
正如你可以看到,自定義mongoUserDetailsService沒有被分配到authenticationManager但新的casAuthenticationProvider,然後我們將casAuthenticationProvider設置爲authenticationManager