【问题标题】:Spring Security weblogic js loadingSpring Security weblogic js加载
【发布时间】:2018-03-24 03:46:53
【问题描述】:

我有一个带有 Spring 安全性的网络应用程序。

当我在 tomcat9 上运行我的应用程序时一切正常,但是当 我使用 oracle Weblogic 出了点问题,我在应用程序中的 js 脚本不起作用。

拒绝执行来自“http://localhost:7001/ais/s/lib/datetime/js/moment-with-locales.min.js”的脚本,因为它的 MIME 类型 ('application/octet-stream') 不可执行,并且启用了严格的 MIME 类型检查。

这是我的安全配置:

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    UserService service;


    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
        .authorizeRequests()
            .antMatchers("/s/**").permitAll() 
            .anyRequest().authenticated()
            .and()
        .formLogin()
            .loginPage("/login")
            .permitAll()
            .and()
        .logout()
            .logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
            .permitAll();
    }




    @Override
    protected void configure(AuthenticationManagerBuilder auth)
            throws Exception {
        auth
        .userDetailsService(new UserDetailServiceImpl(service));
    }
}

【问题讨论】:

  • 我相信对于 weblogic,你需要一些额外的配置。你的项目中有WEB-INF 文件夹吗?
  • @AtaurRahmanMunna 是的,我的 /s/ 文件夹带有 js css,/views/
  • 和 xml:dispatcher-servlet、web、weblogic、jdbc、tiles

标签: javascript spring spring-security weblogic weblogic11g


【解决方案1】:

在 WEB-INF 文件夹中添加一个 weblogic 部署描述符。构建您的项目并进行部署。在我的情况下,我的 xml 看起来像。 weblogic.xml

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
  <jsp-descriptor>
    <keepgenerated>true</keepgenerated>
    <debug>true</debug>
  </jsp-descriptor>
  <container-descriptor>
    <prefer-web-inf-classes>true</prefer-web-inf-classes>
  </container-descriptor>
  <context-root>/ContextRootOfYourApp</context-root>
</weblogic-web-app>

【讨论】:

    【解决方案2】:

    我只是通过把这个放到 SecurityConfig 来解决它

    @Override
    public void configure(WebSecurity web) throws Exception {
      web.ignoring().antMatchers("/s/**");
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-11
      • 2014-10-11
      • 2012-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-22
      • 2017-05-02
      相关资源
      最近更新 更多