0

나는 내 SOAP WebService에의 Springboot 응용 프로그램에 대한 다음과 같은 자바 구성이 있습니다HttpSecurity SOAP 웹 서비스 (Springboot)에서 작동하지

WebSecurityConfiguration에게;

@Configuration 
@EnableWebSecurity 
public class AgreementWebSecurityConfiguration extends WebSecurityConfigurerAdapter { 

@Value("${spring.application.name}") 
private String applicationName; 

private static final String ROLE = "agreement-service"; 

/** 
* Defines which URL paths should be secured and which should not. 
* Specifically, the "/agreementservice-<version>/**" path is configured to require authentication. 
* 
* @param httpSecurity allows configuring web based security for specific http requests 
* @throws Exception if error is encountered when accessing the {code httpSecurity} 
*/ 
@Override 
protected void configure(final HttpSecurity httpSecurity) throws Exception { 
    final String pattern = "/"+applicationName+"/**"; 
    httpSecurity.csrf().disable().authorizeRequests().antMatchers(pattern).hasRole(ROLE).and().httpBasic(); 
} 

}

WebServiceConfiguration :

내 응용 프로그램은 내가 어떤을 인증 할 것이라고 말했다 갖는 컨텍스트 경로

/agreementservice-1.0.0 

에 톰캣 서버에 배포

@EnableWs 
@Configuration 
public class AgreementWebServiceConfiguration extends WsConfigurerAdapter { 

private static final String NAMESPACE_URI = "http://markets.sample.com/credit/schemas/agreement/messages"; 
private static final String URL_MAPPING = "/*"; 
private static final String PORT_TYPE_NAME = "AgreementResource"; 
private static final String LOCATION_URI = "/"; 
private static final String AGREEMENT_XSD_PATH = "agreement.xsd"; 
private static final String MASTER_AGREEMENT_XSD_PATH = "xsd/base/masterAgreement.xsd"; 

@Bean 
public ServletRegistrationBean messageDispatcherServlet(final ApplicationContext applicationContext) { 
    final MessageDispatcherServlet servlet = new MessageDispatcherServlet(); 
    servlet.setApplicationContext(applicationContext); 
    servlet.setTransformWsdlLocations(true); 
    return new ServletRegistrationBean(servlet, URL_MAPPING); 
} 

@Bean(name = "agreement") 
public DefaultWsdl11Definition defaultWsdl11Definition(final XsdSchema agreementSchema) { 
    return getWsdl11Definition(agreementSchema); 
} 

@Bean 
public XsdSchema agreementSchema() { 
    return new SimpleXsdSchema(new ClassPathResource(AGREEMENT_XSD_PATH)); 
} 

@Bean 
public XsdSchema masterAgreement() { 
    return new SimpleXsdSchema(new ClassPathResource(MASTER_AGREEMENT_XSD_PATH)); 
} 

private DefaultWsdl11Definition getWsdl11Definition(final XsdSchema agreementSchema) { 
    final DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition(); 
    wsdl11Definition.setPortTypeName(PORT_TYPE_NAME); 
    wsdl11Definition.setLocationUri(LOCATION_URI); 
    wsdl11Definition.setTargetNamespace(NAMESPACE_URI); 
    wsdl11Definition.setSchema(agreementSchema); 
    return wsdl11Definition; 
} 

위 URL에 대한 액세스. 그러나 현재 구성은 내 URL의 모든 요청을 허용합니다. 예를 들어, 나는 어떤 인증을 위해 메시지를 표시하지 않고 응용 프로그램 WSDL에 액세스 할 수 있었다 :는 SOAP UI를 사용하여 웹 서비스를 테스트 할 때

http://localhost:8080/agreementservice-1.0.0/agreement.wsdl 

같은 사실이다. SOAP UI에서 Authorization을 제공하지 않아도 실행할 수있었습니다.

답변

-1
I think inside configure() method of AgreementWebSecurityConfiguration class you have to add 

    formLogin().loginPage("/login") 


and inside your LoginController or any Login class you have to add 

@RequestMapping(value = "/login", method = RequestMethod.GET) 
public ModelAndView loginPage() { 
    return new ModelAndView("login"); 
    } 
+0

컨트롤러가없는 것을 잊어 버렸습니다. 우리 고객은 SOAP UI를 통해서만 웹 서비스에 액세스하고 있습니다. 인증은 SOAP UI의 인증 탭에서만 제공됩니다. 따라서 formLogin()을 추가하는 것은 옵션이 아닙니다. – Jown