简体   繁体   English

集成Angular 5 App和Spring引导。 Spring Security阻止了该应用程序

[英]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. 当我转到localhost:8080 ,未显示该应用程序。 How do i configure spring security to allow only the angular 5 app through. 我如何配置弹簧安全性以仅允许angular 5应用程序通过。

My Http configuration: 我的Http配置:

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. 因此,如果您未登录,则访问Spring会阻止访问根目录http://localhost:8080

Try logging in adding following line. 尝试登录添加以下行。

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

The above line must be only for testing. 上面的行只能用于测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring 启动 + 与 Angular 应用程序通信的安全配置 - Spring Boot + Security configuration for communication with Angular app 春季启动。 一个应用程序中@Ccontroller和@RestController的不同错误处理 - Spring Boot. Different errors hanldilng for @Ccontroller and @RestController in one app 将Spring Boot与Spring Security集成 - Integrating Spring boot with Spring Security 在春季启动中提供AngularJs应用。 刷新页面时Spring容器返回404 - AngularJs app serving in Spring boot. Spring container returns 404 when page is refreshed Spring Boot 安全性未加载 Angular 7 应用程序构建文件 - Spring boot security is not loading Angular 7 app build files Spring 开机。 userPrincipal 是 null - Spring boot. userPrincipal is null 弹簧靴。 在 RestController 上转发 - Spring Boot. Forward on RestController 我们如何在 Spring Boot 中模拟测试 IntegrationFlow。 我在使用 Spring Integration File 的 Spring Boot 应用程序中使用 Spring Integration - How can we mock test IntegrationFlow in spring boot. I am using Spring Integration inside a Spring boot app using Spring Integration File 将 Spring 引导后端 + oauth 与前端应用程序集成的问题 - Problem with integrating Spring Boot backend + oauth with frontend app 使用Spring Security保护Spring Boot Web App无效 - Securing Spring Boot Web App With Spring Security Doesn't Work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM