简体   繁体   中英

Integrating Angular 5 App and Spring boot. Spring security blocks the app

I have added the built angular app to the static folder under resources. when i go to localhost:8080 , the app is not shown. How do i configure spring security to allow only the angular 5 app through.

My Http configuration:

http
            .cors()
                .and()
            .csrf()
                .disable()
            .exceptionHandling()
                .authenticationEntryPoint(unauthorizedHandler)
                .and()
            .sessionManagement()
                .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
                .and()
            .authorizeRequests()
                .antMatchers("/auth/**").permitAll()
                .antMatchers("/h2-console/**").permitAll()
                .antMatchers("/users/checkUsernameAvailability",
                        "/users/checkEmailAvailability")
                    .permitAll()
                .anyRequest().authenticated();

You have following:

.anyRequest().authenticated();

So accessing http://localhost:8080 which is the root will be blocked by Spring Security if you are not logged in.

Try logging in adding following line.

.antMatchers("/**").permitAll()

The above line must be only for testing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM