1

I have this template:

<head>
    <meta charset="utf-8"/>
    <meta content="width=device-width, initial-scale=1.0" name="viewport"/>

    <meta property="og:site_name"   th:content="#{social.media.title}" />
    <meta property="og:url"         content="https://www.taradell-planets.com"/>
    <meta property="og:type"        content="article"/>
    <meta property="og:title"       th:content="#{social.media.title}" />
    <meta property="og:description" th:content="#{social.media.description}" />
    <meta property="og:image"       content="https://www.taradell-planets.com/assets/images/app.png"/>

    <!-- Other meta tags -->
    <meta name="twitter:card"           content="summary_large_image">
    <meta name="twitter:title"          th:content="#{social.media.title}" />
    <meta name="twitter:description"    th:content="#{social.media.description}" />
    <meta name="twitter:image"          content="https://www.taradell-planets.com/assets/images/app.png">
    <!-- Other meta tags -->

    <title th:text="#{html.title}">Astrology and Spirituality...</title>
    <meta th:content="#{meta.content.description}" content="Explore the realms of astrology and spirituality.." name="description"/>
    <meta th:content="#{meta.content.keywords}"    content="astrology, spirituality..."                         name="keywords"/>
    <meta content="ie=edge" http-equiv="X-UA-Compatible"/>

    <!-- Favicons -->
    <link th:href="@{/assets/images/favicon.png}" rel="icon"/>
    <link th:href="@{/assets/images/apple-touch-icon.png}" rel="apple-touch-icon"/>


    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,600;1,700&amp;family=Montserrat:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&amp;family=Raleway:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&amp;display=swap"
          rel="stylesheet"/>
    <link rel="preconnect" href="https://fonts.googleapis.com"/>
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin=""/>
    <link href="https://fonts.googleapis.com/css2?family=Oswald:wght@500&amp;display=swap" rel="stylesheet" />
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400&amp;display=swap" rel="stylesheet"/>
    <!-- Vendor CSS Files -->
    <link th:href="@{/assets/vendor/aos/aos.css}" rel="stylesheet"/>
    <link th:href="@{/assets/stylesheets/font-awesome.min.css}" rel="stylesheet"/>
    <link th:href="@{/assets/vendor/swiper/swiper-bundle.min.css}" rel="stylesheet"/>
    <link th:href="@{/assets/vendor/glightbox/css/glightbox.min.css}" rel="stylesheet"/>
    <link th:href="@{/assets/vendor/bootstrap/css/bootstrap.min.css}" rel="stylesheet"/>
    <link th:href="@{/assets/vendor/bootstrap-icons/bootstrap-icons.css}" rel="stylesheet"/>

    <!-- Main CSS File -->
    <link th:href="@{/assets/stylesheets/styles.css}" rel="stylesheet"/>
    <link th:href="@{/assets/stylesheets/custom.css}" rel="stylesheet"/>
    <link th:href="@{/assets/stylesheets/responsive.css}" rel="stylesheet"/>

</head>

this config files:

@Profile("web")
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/resources/**")
                .addResourceLocations("classpath:/static/");
    }
}

and this:

@Configuration
@EnableWebSecurity
//@EnableMethodSecurity
@Profile("web")
public class WebSecurityConfig {

    private final JwtUtils jwtUtils;
    private final UserDetailsServiceImpl userDetailsService;
    private final AuthEntryPointJwt unauthorizedHandler;

    public WebSecurityConfig(JwtUtils jwtUtils,
                             UserDetailsServiceImpl userDetailsService,
                             AuthEntryPointJwt unauthorizedHandler) {
        this.jwtUtils = jwtUtils;
        this.userDetailsService = userDetailsService;
        this.unauthorizedHandler = unauthorizedHandler;
    }

    @Bean
    public AuthTokenFilter authenticationJwtTokenFilter() {
        return new AuthTokenFilter(jwtUtils, userDetailsService);
    }

    @Bean
    public DaoAuthenticationProvider authenticationProvider() {
        DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
        authProvider.setUserDetailsService(userDetailsService);
        authProvider.setPasswordEncoder(passwordEncoder());
        return authProvider;
    }

    @Bean
    public AuthenticationManager authenticationManager(AuthenticationConfiguration authConfig) throws Exception {
        return authConfig.getAuthenticationManager();
    }

    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }


    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {

        http.csrf(AbstractHttpConfigurer::disable)
                .exceptionHandling(exception -> exception.authenticationEntryPoint(unauthorizedHandler))
                .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
                .authorizeHttpRequests(auth -> auth
                        .anyRequest().permitAll() // 🔥 Allows all requests without authentication
                );

        http.authenticationProvider(authenticationProvider());
        http.addFilterBefore(authenticationJwtTokenFilter(), UsernamePasswordAuthenticationFilter.class);

        return http.build();
    }



    @Bean
    public LocaleResolver localeResolver() {
        SessionLocaleResolver slr = new SessionLocaleResolver();
        slr.setDefaultLocale(Locale.ENGLISH);
        return slr;
    }

    @Bean
    public LocaleChangeInterceptor localeChangeInterceptor() {
        LocaleChangeInterceptor interceptor = new LocaleChangeInterceptor();
        interceptor.setParamName("lang"); // Allows users to change locale via ?lang=fr
        return interceptor;
    }

    @Bean
    public WebMvcConfigurer localeInterceptorConfig() {
        return new WebMvcConfigurer() {
            @Override
            public void addInterceptors(InterceptorRegistry registry) {
                registry.addInterceptor(localeChangeInterceptor());
            }
        };
    }
}

enter image description here

I can access this file: http://localhost:8080/assets/images/apple-touch-icon.png but I have a 404 for the css: http://localhost:8080/assets/stylesheets/font-awesome.min.css

2
  • If the css file is in the assets folder, what's in the css folder? 404 is file-not-found, so it's not a problem with the security config. Commented Feb 19 at 10:56
  • Yes, there are: assets/stylesheets Commented Feb 19 at 10:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.