Implement spring security on google app engine

后端 未结 1 701
我寻月下人不归
我寻月下人不归 2021-01-20 03:16

I\'m trying to integrate the spring security on google app engine. But it doesn\'t work properly. I wang to authenticate user when they try to access index page

1条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-20 03:24

    WebApplicationInitializer requires Servlet 3.0, but Appengine supports only Servlet 2.5. So you have to use plain XML based config, at least for initialization. And configure Spring filter/servlet in web.xml manually.

    You need to put into web.xml:

    
        contextConfigLocation
        /WEB-INF/spring-security.xml
    
    
        org.springframework.web.context.ContextLoaderListener
    
    
    
        springSecurityFilterChain
        org.springframework.web.filter.DelegatingFilterProxy
    
    
        springSecurityFilterChain
        /*
    
    
    
        spring-dispatcher
        org.springframework.web.servlet.DispatcherServlet
        1
        
            contextClass
            org.springframework.web.context.support.AnnotationConfigWebApplicationContext
        
        
            contextConfigLocation
            path.to.AppConfig
        
    
    
        spring-dispatcher
        /*
    
    

    and into spring-security.xml:

    
    
    

    Basically it's all standard stuff from pre-servlet 3.0 time, and you could use any tutorial (or old docs) based on servlet 2.4 or 2.5, it will work on Appengine.

    PS also you could vote for Servlet 3.0 support at https://code.google.com/p/googleappengine/issues/detail?id=3091

    0 讨论(0)
提交回复
热议问题