【发布时间】:2015-10-07 10:44:12
【问题描述】:
我有一个应用程序需要在 weblogic 10.3.6 服务器中部署 2 个安全 http 标签,Spring Framework 3.1.2 和 spring-security-3.1.2 版本: 1、Form-based-Login:用于用户使用登录页面直接登录。 2. 基本身份验证:Rest WebService 调用。
我已成功添加 FORM_BASED_LOGIN。-这很好用
感谢 BASIC Auth for REST WebServices 的任何方向。 对于基本身份验证:Weblogic 会弹出一个额外的弹出窗口,我必须在其中输入 weblogic 控制台的凭据。
为了解决这个问题,我找到了 2 种方法: 1. 使用以下标签更新服务器 config.xml 文件:
<enforce-valid-basic-auth-credentials>false</enforce-valid-basic-auth-credentials>
参考:Spring Security HTTP Basic Authentication
- 添加适配器和 applicationContext-acegi-security.xml 和 WeblogicAuthenticationFilter
我喜欢使用第二种方法,因为它不涉及对服务器配置的任何更改。 如果有人能指出我正确的方向或实现这一目标的示例,那就太好了。
参考:http://docs.tpu.ru/docs/oracle/en/fmw/11.1.1.6.0/web.1111/e14453/security.htm
更新:添加我当前的 spring-security 配置:
<http create-session="stateless" entry-point-ref="basicAuthEntryPoint" pattern="/api/**" use-expressions="true">
<intercept-url pattern="/api/listbyorderid" access="hasAnyRole('ROLE_USER','ROLE_ADMIN')" />
<intercept-url pattern="/api/listbycustomerid" access="hasAnyRole('ROLE_USER','ROLE_ADMIN')" />
<custom-filter ref="basicAuthenticationFilter" after="BASIC_AUTH_FILTER" />
</http>
<http auto-config="false" use-expressions="true" access-denied-page="/security/denied" entry-point-ref="authenticationEntryPoint">
<intercept-url pattern="/security/login" access="permitAll" />
<intercept-url pattern="/layouts/*" access="permitAll"/>
<intercept-url pattern="/tiles/*" access="permitAll"/>
<intercept-url pattern="/jquery/*" access="permitAll"/>
<intercept-url pattern="/css/*" access="permitAll"/>
<intercept-url pattern="/admin/css/*" access="permitAll"/>
<intercept-url pattern="/admin/images/*" access="permitAll"/>
<intercept-url pattern="/admin/ico/*" access="permitAll"/>
<intercept-url pattern="/admin/jquery/*" access="permitAll"/>
<logout invalidate-session="true" logout-url="/j_spring_security_logout" success-handler-ref="logoutSuccessHandler" delete-cookies="JSESSIONID"/>
<!-- Custom filter to deny unwanted users even though registered -->
<custom-filter ref="blacklistFilter" before="FILTER_SECURITY_INTERCEPTOR" />
<!-- Custom filter for username, password and domain. The real customization is done in the customAuthenticationManager -->
<custom-filter ref="authenticationFilter" position="FORM_LOGIN_FILTER" />
</http>
提前致谢。
【问题讨论】:
标签: spring spring-mvc jakarta-ee spring-security weblogic-10.x