PastorPL
PastorPL

Reputation: 1024

JAX-WS web service and spring security

I'm trying to develop web servces for application that is secured with Spring Security. Everything works fine except one thing: my web service should be unsecured and wsdl should be served without any authentication/autorisation. So I've add appropriate intercept-url pattern. However, I cannot get to the wsdl page. I'm being redirected to the login page. After passing good login/password I can get to wsdl, but without them I can't. I've tried many patterns and evething failed. Maybe some advices :) ?

My Spring Security code(with current intercept-url):

<?xml version="1.0" encoding="UTF-8"?>
<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.1.xsd
        http://www.springframework.org/schema/security 
        http://www.springframework.org/schema/security/spring-security-3.1.xsd">

    <http pattern="/resources/*" security="none" />

    <http auto-config="true" use-expressions="true">
        <intercept-url pattern="/auth/login" access="permitAll" />
        <intercept-url pattern="/auth/logout" access="permitAll" />
        <intercept-url pattern="/auth/denied" access="permitAll" />
        <intercept-url pattern="/**SampleInputImpl?wsdl**" access="permitAll" />
        <intercept-url pattern="/user" access="hasRole('ROLE_USER')" />
        <intercept-url pattern="/admin" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/*" access="isAuthenticated()" />

        <form-login login-page="/auth/login" authentication-failure-url="/auth/login?error=true"
            default-target-url="/" />

        <access-denied-handler error-page="/auth/denied" />

        <logout invalidate-session="true" logout-success-url="/auth/login?logout=true" />



    </http>

    <authentication-manager>
        <authentication-provider user-service-ref="userDetailsService">
            <password-encoder hash="md5" />
        </authentication-provider>
    </authentication-manager>
</beans:beans>

Upvotes: 2

Views: 2548

Answers (1)

Rob Winch
Rob Winch

Reputation: 21720

Ant patterns in intercept-url do not use the query string, so adding ?wsdl is probably causing Spring Security to not match on your wsdl. I'd suggest trying <intercept-url pattern="/**/SampleInputImpl" access="permitAll" />.

If that does not work, please provide the URL you want to be public and enabling the debug logging and posting the logs.

Upvotes: 3

Related Questions