简体   繁体   English

WSO2 ESB获取用户名

[英]WSO2 ESB Get Username

I like to use a proxy with authentification via username and password. 我喜欢使用通过用户名和密码进行身份验证的代理。 All the messages going over the ESB should be saved into a Database, including the user which is authenticated to the ESB. 所有通过ESB的消息都应保存到数据库中,包括已通过ESB验证的用户。 Is there a way to get the username in the proxy? 有没有办法在代理中获取用户名? I know you can get the message-id for example, but I couldn't find a solution to get the username. 我知道您可以获取例如message-id,但是我找不到找到用户名的解决方案。

Maybe you can help me :) 也许你可以帮我:)

It's working if you use $header to access the header information. 如果您使用$ header访问标头信息,则此方法有效。 Just get the xPath and extract the username like this example: 只需获取xPath并提取用户名,如下例所示:

<property xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" name="user" expression="$header/wsse:Security/wsse:UsernameToken/wsse:Username"/>

You can secure proxies using username token(ie: username/password). 您可以使用用户名令牌(即:用户名/密码)来保护代理。 Go to service dashboard-->security option and you can find the tools to enable username token. 转到服务仪表板->安全选项,您可以找到启用用户名令牌的工具。 If you secured like that, in your request you should send the basic auth header. 如果您这样确保安全,则在您的请求中应发送基本的auth标头。

Once proxy service is secured user name token or basic auth... After successful message authentication, user name can be retrieved. 一旦代理服务得到保护,用户名令牌或基本身份验证...成功的消息身份验证后,即可检索用户名。 User name can be retrieved from axis2 message context using property called "username". 可以使用名为“用户名”的属性从axis2消息上下文中检索用户名。 You can use property mediator (scope is axis2) or simple class mediator. 您可以使用属性介体(作用域为axis2)或简单类介体。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM