spring-guides / gs-securing-web

Securing a Web Application :: Learn how to protect your web application with Spring Security.
http://spring.io/guides/gs/securing-web/
Apache License 2.0
364 stars 447 forks source link

howto access assets from login.html #13

Closed mmly closed 10 years ago

mmly commented 10 years ago

I like new spring guides. I clone this repo and using this project as baseline for my new project. Howto access static assets(js, css) from login.html ? My solution: I think that spring boot have automatic acces to /resources/static so I: -created /resources/static folder and put there my static assets(/js /css) -add spring security rule: .antMatchers("/", "/home", "/resources/**").permitAll() but assets aren't accessible and they are protected.

gregturn commented 10 years ago

Did you put your assets in src/main/resources/static inside your project? You seemed to indicate just /resources/static. That has to do with how Boot configures view resolvers.

And be sure to confirm everything works BEFORE you turn on security. That way you aren't trying to solve the wrong problem.

mmly commented 10 years ago

Yes I put assets into src/main/resources/static. And yes assets are accessible with turn off spring security, but when spring security is turn on assets are not accessible.

gregturn commented 10 years ago

Check the path to your static assets and cross check with http://docs.spring.io/spring-security/site/docs/3.2.4.RELEASE/reference/htmlsingle/#authorize-requests to put right path into permitAll.