【问题标题】:Spring Security Basic Authentication in Weblogic by using Adapter使用适配器在 Weblogic 中使用 Spring Security 基本身份验证
【发布时间】:2015-10-07 10:44:12
【问题描述】:

我有一个应用程序需要在 weblogic 10.3.6 服务器中部署 2 个安全 http 标签,Spring Framework 3.1.2 和 spring-security-3.1.2 版本: 1、Form-b​​ased-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

  1. 添加适配器和 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


    【解决方案1】:

    Spring Security 开箱即用地支持这一点。对于基于 Java 的配置,您可以查看 helloworld-jc,对于基于 xml 的配置,您可以查看 helloworld-xml。鉴于您使用的是带有 weblogic 10.3.6 的 servlet 2.5,您将需要使用 XML 示例。

    【讨论】:

    • 我之前应该提到我的Spring Framework环境和spring-security版本是3.1.4。该示例使用 4.0.1.RELEASE。
    • 我正在寻找问题中提到的指定 URL 的 REST WebService 调用的基本身份验证配置。
    猜你喜欢
    • 2021-09-19
    • 2013-02-11
    • 2014-10-27
    • 2015-02-06
    • 2011-02-11
    • 2016-03-20
    • 1970-01-01
    • 2012-06-20
    • 2020-06-05
    相关资源
    最近更新 更多