2012-06-28 20 views
13

पर रीडायरेक्ट कर रहा है मैं स्प्रिंग सुरक्षा 3.1 का उपयोग कर रहा हूं। प्राधिकरण के बाद पुनर्निर्देशित करते समय मुझे एक समस्या है। यह एक फेविकॉन 404 त्रुटि पर रीडायरेक्ट करता है। फेविकॉन के लिए role_anonymous जोड़ना मदद नहीं करता था।डिफ़ॉल्ट स्प्रिंग सुरक्षा फ़ेविकॉन

<beans:beans xmlns="http://www.springframework.org/schema/security" 
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
    http://www.springframework.org/schema/security 
    http://www.springframework.org/schema/security/spring-security-3.1.xsd"> 

<!--To enable spring security comment this string 
    <http auto-config="true" security="none"/>--> 

    <!-- To enable spring security remove comment from this code--> 
     <http auto-config="true"> 
       <intercept-url pattern="/**" access="ROLE_ADMIN"/> 
       <intercept-url pattern="/favicon.ico" access="ROLE_ANONYMOUS" /> 
     </http> 


<authentication-manager> 
    <authentication-provider> 
     <user-service> 
      <user name="hey" password="there" authorities="ROLE_ADMIN" /> 
     </user-service> 
    </authentication-provider> 
</authentication-manager> 

</beans:beans> 

उत्तर

27

फ़िल्टर फ़िल्टर से उस पथ को पूरी तरह से छोड़ना सबसे अच्छा है।

उपयोग

<http pattern="/favicon.ico" security="none" /> 

<http auto-config="true"> 
    <intercept-url pattern="/**" access="ROLE_ADMIN"/> 
</http> 

बजाय।

यह भी याद रखें कि आपको अपने intercept-url तत्वों को सबसे कम से कम विशिष्ट पैटर्न से ऑर्डर करने की आवश्यकता है, इसलिए आपकी मूल कॉन्फ़िगरेशन किसी भी मामले में फेविकॉन पैटर्न को अनदेखा कर देगी।

मैं यह भी सिफारिश करता हूं कि आप auto-config का उपयोग न करें, लेकिन उन सुविधाओं को निर्दिष्ट करें जिन्हें आप स्पष्ट रूप से उपयोग करना चाहते हैं ताकि आप स्पष्ट हो सकें कि सुरक्षा फ़िल्टर श्रृंखला में क्या जोड़ा जा रहा है।

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