【问题标题】:Spring + Angular set up and securitySpring + Angular 设置和安全性
【发布时间】:2015-04-26 15:14:50
【问题描述】:

我想知道最好的方法是设置一个包含 Spring RESTful API 以及提供静态 Angularjs 页面以使用 RESTful Web 服务的能力的项目。以下实现有效,但我现在希望在应用程序中添加安全性,但我不确定如何将 Spring Security 应用于 REST Api 和静态页面。

  • 以下设置是否适合我的最终目标?
  • 如何保护 REST Api 和静态页面?

我有以下项目结构

Servlet 配置

import javax.servlet.ServletContext;  
import javax.servlet.ServletException;  
import javax.servlet.ServletRegistration.Dynamic;  

import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.WebApplicationInitializer;  
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;  
import org.springframework.web.servlet.DispatcherServlet; 



@ComponentScan
public class WebAppInitializer implements WebApplicationInitializer {
    public void onStartup(ServletContext servletContext) throws ServletException {  

        servletContext.addFilter("corsFilter", new CORSFilter());

        AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();  
        ctx.register(WebMvcConfig.class);  
        ctx.setServletContext(servletContext);                 

        Dynamic dynamic = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));  
        dynamic.addMapping("/api/*");  
        dynamic.setLoadOnStartup(1);  
   }  
} 

【问题讨论】:

    标签: angularjs spring rest maven spring-security


    【解决方案1】:
    猜你喜欢
    • 2015-12-02
    • 2017-07-01
    • 2016-08-05
    • 1970-01-01
    • 2013-09-21
    • 2021-06-24
    • 1970-01-01
    • 1970-01-01
    • 2015-11-18
    相关资源
    最近更新 更多