में स्प्रिंग विधि सुरक्षा अक्षम करें मेरे पास एक यूआरएल और विधियों दोनों पर पहुंच सीमित करने के लिए कॉन्फ़िगर किया गया वसंत सुरक्षा वाला एक वेब अनुप्रयोग है। मैं इसे पूरी तरह से डिफ़ॉल्ट रूप से अक्षम करना चाहता हूं, और अपने ग्राहकों को आसानी से इसे चालू करने की अनुमति देता हूं (वे केवल "वसंत-सुरक्षा.एक्सएमएल" तक पहुंच सकते हैं)।संस्करण 3.0.x
मैं यूआरएल अवरोधन बंद करने के लिए कामयाब रहे, लेकिन मेरे विधि सुरक्षा अभी भी सक्षम किया गया है ...
कोई सुराग?
(मैं ग्राहक मेरे web.xml बदल सकता है इसलिए दुर्भाग्य से "वैश्विक-विधि-सुरक्षा" हर बार की स्थापना एक विकल्प नहीं है को संशोधित करने जाने के लिए नहीं करना चाहते हैं ...)
यह मेरा अद्यतन है वसंत-security.xml विन्यास:
<http auto-config='true' use-expressions="true">
<intercept-url pattern="/**" access="permitAll" />
<http-basic />
<anonymous />
</http>
मैं इस तरह DelegatingFilterProxy.doFilter विधि ओवरराइड है
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
final String springSecured = System.getProperty("springSecured");
if (StringUtils.isNotBlank(springSecured) && springSecured.equalsIgnoreCase("true")) {
// Call the delegate
super.doFilter(request, response, filterChain);
} else {
// Ignore the DelegatingProxyFilter delegate
filterChain.doFilter(request, response);
}
}
और इस विधि सुरक्षा मैं का एक उदाहरण है:
@RequestMapping(
value = "applications/{applicationName}/timeout/{timeout}",
method = RequestMethod.POST)
public
@ResponseBody
@PreAuthorize("isFullyAuthenticated() and hasPermission(#authGroups, 'deploy')")
Object deployApplication() {
// ...
}