How can I use Spring Security without sessions?

前端 未结 7 1462
执念已碎
执念已碎 2020-11-29 15:53

I am building a web application with Spring Security that will live on Amazon EC2 and use Amazon\'s Elastic Load Balancers. Unfortunately, ELB does not support sticky sessio

7条回答
  •  离开以前
    2020-11-29 16:37

    Take a look at SecurityContextPersistenceFilter class. It defines how the SecurityContextHolder is populated. By default it uses HttpSessionSecurityContextRepository to store security context in http session.

    I have implemented this mechanism quite easily, with custom SecurityContextRepository.

    See the securityContext.xml below:

    
    
    
        
    
        
    
        
    
        
            
        
    
        
            
            
                
                    
                
            
        
    
        
            
            
                
                    
                    
                    
                
            
            
                
                    
                
            
            
            
        
    
        
    
        
            
            
        
    
    
        
            
                
                    
                
            
            
                
                    
                
            
            
                
            
        
    
        
    
        
            
                
            
        
    
        
            
                
                    
                    
                    
                    
                
            
            
            
        
    
        
            
                
                    
                    
                
            
        
    
        
            
                
                    
                        
                        
                        
                        
                    
                
            
        
    
        
    
        
            
        
    
    
    

提交回复
热议问题