我将 ESB 与许多不同的代理一起使用。
其中之一是将消息发送到其他代理端点。所有代理都在 ESB 中。
目前这些端点代理不安全。我喜欢使用场景 1 作为他们的安全保障。 但我怎样才能将消息发送到这些端点。这意味着:如何在代理配置中添加包含用户名和密码的安全 header ,以便我可以使用用户“admin”和密码“admin”进行身份验证?
最佳答案
据我了解,您需要保护代理并将其转发到不安全的后端服务。
为此,您可以尝试从 WSO2 ESB 管理控制台执行以下步骤。我从 WSO2 ESB 4.7.0 尝试过这个
- 添加 pass through proxy service .
- 从服务仪表板查看代理。
- 点击该服务的“安全”。
- 为“启用安全性?”选择"is"
- 选择“UsernameToken”并单击“下一步”。你提到的场景1。这将使用带有用户名 token 的 WS-Security 标准。
- 您可以在此处选择“admin”组,然后点击“完成”
现在将为您的服务启用安全性。
代理服务现在需要身份验证,您现在可以使用“admin”用户。 (或您添加的任何用户)。
如果您使用的是 Java 客户端,则使用带有 Rampart 模块的 Axis2 可能会更容易。这方面的例子有很多。
请参阅以下链接。
http://blog.facilelogin.com/2008/11/security-policy-with-rampart.html (这有一个简单的客户端)
http://blog.thilinamb.com/2009/08/securing-web-service-with-username.html
我使用 SoapUI 对此进行了测试。您可以从请求属性传递用户名和密码。
您的请求将类似于以下内容。
Wed Aug 21 01:15:32 IST 2013:DEBUG:>> "POST /services/SimpleStockQuoteService.SimpleStockQuoteServiceHttpsSoap12Endpoint HTTP/1.1[\r][\n]"
Wed Aug 21 01:15:32 IST 2013:DEBUG:>> "Accept-Encoding: gzip,deflate[\r][\n]"
Wed Aug 21 01:15:32 IST 2013:DEBUG:>> "Content-Type: application/soap+xml;charset=UTF-8;action="urn:getQuote"[\r][\n]"
Wed Aug 21 01:15:32 IST 2013:DEBUG:>> "Content-Length: 1195[\r][\n]"
Wed Aug 21 01:15:32 IST 2013:DEBUG:>> "Host: isurup-ThinkPad-T530:8243[\r][\n]"
Wed Aug 21 01:15:32 IST 2013:DEBUG:>> "Connection: Keep-Alive[\r][\n]"
Wed Aug 21 01:15:32 IST 2013:DEBUG:>> "User-Agent: Apache-HttpClient/4.1.1 (java 1.5)[\r][\n]"
Wed Aug 21 01:15:32 IST 2013:DEBUG:>> "[\r][\n]"
Wed Aug 21 01:15:32 IST 2013:DEBUG:>> "<soap:Envelope xmlns:ser="http://services.samples" xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://services.samples/xsd">[\n]"
Wed Aug 21 01:15:32 IST 2013:DEBUG:>> " <soap:Header><wsse:Security soap:mustUnderstand="true" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsu:Timestamp wsu:Id="TS-63"><wsu:Created>2013-08-20T19:45:32Z</wsu:Created><wsu:Expires>2013-08-20T21:08:52Z</wsu:Expires></wsu:Timestamp><wsse:UsernameToken wsu:Id="UsernameToken-62"><wsse:Username>admin</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">admin</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">WG8iV7vik8QqZkzlaIabWg==</wsse:Nonce><wsu:Created>2013-08-20T19:45:32.861Z</wsu:Created></wsse:UsernameToken></wsse:Security></soap:Header>[\n]"
Wed Aug 21 01:15:32 IST 2013:DEBUG:>> " <soap:Body>[\n]"
Wed Aug 21 01:15:32 IST 2013:DEBUG:>> " <ser:getQuote>[\n]"
Wed Aug 21 01:15:32 IST 2013:DEBUG:>> " <ser:request>[\n]"
Wed Aug 21 01:15:32 IST 2013:DEBUG:>> " <xsd:symbol>WSO2</xsd:symbol>[\n]"
Wed Aug 21 01:15:32 IST 2013:DEBUG:>> " </ser:request>[\n]"
Wed Aug 21 01:15:32 IST 2013:DEBUG:>> " </ser:getQuote>[\n]"
Wed Aug 21 01:15:32 IST 2013:DEBUG:>> " </soap:Body>[\n]"
Wed Aug 21 01:15:32 IST 2013:DEBUG:>> "</soap:Envelope>"
更新 如果后端服务也安全的话,可以引用下面的博文。
http://soasecurity.org/2012/11/05/how-to-invoke-secured-backend-service-using-wso2-esb/
关于security - WSO2 ESB 安全代理端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18342777/