简体   繁体   English

WSO2与其他租户共享超级租户Web服务

[英]WSO2 Sharing super tenant web service to other tenants

I would like to share web service which is deployed in super tenant to other tenants. 我想将在超级租户中部署的Web服务共享给其他租户。 As far as I know everyone can access the super admin services if they are using http:// localhost :8280/services/echo?wsdl url. 据我所知,每个人都可以使用http:// localhost:8280 / services / echo?wsdl url访问超级管理员服务。 But I do not want just to access super tenant application, I would also like to see request count on correct tenant. 但是我不想只访问超级租户应用程序,我还希望看到正确租户的请求计数。 Should I have to deploy the same application to every tenant and call service with proper url (http:// localhost .com:8280/services/t/tenantname/echo?wsdl) to collect the request counts? 我是否应该将相同的应用程序部署到每个租户并使用正确的URL(http:// localhost .com:8280 / services / t / tenantname / echo?wsdl)调用服务以收集请求计数?

Is there any other way to do this? 还有其他方法吗? For example maybe I could put header variable to my request which is showing, which tenant is calling the application etc., and with this kind of approach, I do not have to deploy my service to other tenants. 例如,也许我可以将标头变量放入正在显示的请求中,哪个租户正在调用应用程序等,并且通过这种方法,我不必将服务部署到其他租户。

You can use a code something like, 您可以使用类似的代码,

int tenantId = MultitenantUtils.getTenantId(this.getConfigContext());

to get the tenant ID of the current tenant and send it either in the message itself or in the header. 获取当前租户的租户ID,并将其发送到消息本身或标头中。 Then you can record the tenants accessed in the server side, by counting the tenant IDs. 然后,您可以通过计算租户ID来记录在服务器端访问的租户。

This will help you to get the tenant ID. 将帮助您获取租户ID。

One possibility is to deploy the application at each tenant. 一种可能性是在每个租户处部署应用程序。 Then you get a separate URL for each. 然后,您将分别获得每个URL。 Or else you can make your service multi tenant aware. 否则,您可以使您的服务多租户知道。 For this you need to make the service secured. 为此,您需要确保服务安全。 When log into the service, we can determine the tenant using the user name. 登录服务后,我们可以使用用户名确定租户。 For an example foo user should be a super tenant user while foo@bar.com should belongs to bar.com tenant. 例如,foo用户应为超级租户用户,而foo@bar.com应属于bar.com租户。 In this case carbon framework, does this authentication and set the tenant details to carbon context. 在这种情况下,碳框架将进行身份验证,并将租户详细信息设置为碳环境。 You can access that at the service level. 您可以在服务级别访问它。 eg. 例如。 CarbonContext.getCurrentContext().getTenantID() or with the method Maninda has mentioned. CarbonContext.getCurrentContext()。getTenantID()或Maninda提到的方法。

org.wso2.carbon.tomcat.ext.internal.Utils class has a function which name is getTenantDomain. org.wso2.carbon.tomcat.ext.internal.Utils类具有一个名为getTenantDomain的函数。

I have changed this methods to find tenant domain from headers, so it is working like a charm :) 我已经更改了此方法以从标题中查找租户域,所以它的工作就像一个魅力:)

I think WSO2 also thinks to customize this method. 我认为WSO2也在考虑定制此方法。

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

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