2011-07-18 17 views
7

मैं स्प्रिंग सुरक्षा का उपयोग कर वसंत एमवीसी अनुप्रयोग को निम्नलिखित तरीके से कॉन्फ़िगर करना चाहता हूं।वसंत सुरक्षा बुनियादी विन्यास

  1. केवल एक समवर्ती लॉगिन की अनुमति है।
  2. जब HTTP सत्र समाप्त हो जाता है तो उपयोगकर्ता को /security/sessionTimeout.html
  3. पर रीडायरेक्ट किया जाएगा जब उपयोगकर्ता सफलता पर लॉग इन करेगा तो उसे फ़ोल्डर में रीडायरेक्ट किया जाएगा।
  4. जब उपयोगकर्ता लॉग आउट करते हैं, तो उन्हें "/" पर भी रीडायरेक्ट किया जाएगा।

मैं इसे निम्नलिखित तरीके से कॉन्फ़िगर किया गया:

<security:http> 
<security:form-login login-page="/security/login.html" login-processing-url="/login" authentication-failure-url="/login.jsp?login_error=1" default-target-url="/"/> 
    <security:session-management invalid-session-url="/security/sessionTimeout.html"> 
     <security:concurrency-control max-sessions="1" /> 
    </security:session-management> 
    <security:logout logout-url="/logout" logout-success-url="/"/> 
    </security:http> 

और मैं निम्नलिखित मुद्दे हैं:

  1. मैं 2 विभिन्न ब्राउज़रों पर उसी खाते से प्रवेश करने में सक्षम हूँ (कोई संगामिति नियंत्रण काम कर रहा है)
  2. जब मैं लॉग आउट पर क्लिक करता हूं तो मुझे "/security/sessionTimeout.html" के बजाय "/" पर रीडायरेक्ट किया जाता है।

मैंने वसंत सुरक्षा संदर्भ मार्गदर्शिका का पालन किया है। मैं क्या गलत कर रहा हूँ?

अपडेटेडः इस प्रकार मेरा वेब.एक्सएमएल दिखता है।

अद्यतन 2: बस डिबग मोड में log4j चलाने के लिए और इस मैं क्या हो गया, जब लॉगआउट पर क्लिक है:

DEBUG [http-8080-2] (FilterChainProxy.java:375) - /index.html at position 1 of 11 in additional filter chain; firing Filter: 'ConcurrentSessionFilter' 
DEBUG [http-8080-2] (FilterChainProxy.java:375) - /index.html at position 2 of 11 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter' 
DEBUG [http-8080-2] (HttpSessionSecurityContextRepository.java:130) - No HttpSession currently exists 
    DEBUG [http-8080-2] (HttpSessionSecurityContextRepository.java:88) - No SecurityContext was available from the HttpSession: null. A new one will be created. 
    DEBUG [http-8080-2] (FilterChainProxy.java:375) - /index.html at position 3 of 11 in additional filter chain; firing Filter: 'LogoutFilter' 
    DEBUG [http-8080-2] (FilterChainProxy.java:375) - /index.html at position 4 of 11 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter' 
    DEBUG [http-8080-2] (FilterChainProxy.java:375) - /index.html at position 5 of 11 in additional filter chain; firing Filter: 'BasicAuthenticationFilter' 
    DEBUG [http-8080-2] (FilterChainProxy.java:375) - /index.html at position 6 of 11 in additional filter chain; firing Filter: 'RequestCacheAwareFilter' 
    DEBUG [http-8080-2] (FilterChainProxy.java:375) - /index.html at position 7 of 11 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter' 
    DEBUG [http-8080-2] (FilterChainProxy.java:375) - /index.html at position 8 of 11 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter' 
    DEBUG [http-8080-2] (AnonymousAuthenticationFilter.java:67) - Populated SecurityContextHolder with anonymous token: 'org.sprin[email protected]9055c2bc: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.sprin[email protected]b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null; Granted Authorities: ROLE_ANONYMOUS' 
    DEBUG [http-8080-2] (FilterChainProxy.java:375) - /index.html at position 9 of 11 in additional filter chain; firing Filter: 'SessionManagementFilter' 
    DEBUG [http-8080-2] (SessionManagementFilter.java:87) - Requested session IDD8429BBAAA9561A97E1D2350ED63BC35 is invalid. 
    DEBUG [http-8080-2] (SessionManagementFilter.java:90) - Starting new session (if required) and redirecting to '/security/sessionTimeout.html' 

यह लगता है जैसे मैं सत्र प्रबंधन फिल्टर /index.html और फिर पर लागू किया है कोई सत्र मौजूद नहीं है। मैं इसे कैसे सुलझाऊं?

+0

आइटम बी) शायद इसलिए हो रहा है क्योंकि आपने किसी भी उपयोगकर्ता द्वारा यूआरएल '/' तक पहुंचने की अनुमति नहीं दी है। – bluefoot

+0

आप किस वसंत संस्करण का उपयोग कर रहे हैं? – Simeon

+0

@ शिमोन, 3.0.5 और वसंत 3.0.4 –

उत्तर

2
the Spring Security documentation से

:

<listener> 
    <listener-class> 
    org.springframework.security.web.session.HttpSessionEventPublisher 
    </listener-class> 
</listener> 

आप इस जोड़ दिया:

समवर्ती सत्र समर्थन का उपयोग करने के लिए आपको web.xml के लिए निम्न जोड़ने की आवश्यकता होगी?

+0

ऐसा लगता है कि मेरे पास है, लेकिन मैंने अपडेट में अपना पूरा वेब.एक्सएमएल कॉन्फ़िगरेशन पोस्ट किया है। –

+0

इससे मेरे लिए समस्या का समाधान नहीं हुआ। –

संबंधित मुद्दे