简体   繁体   English

WSO2数据服务中的多租户Web服务?

[英]Multi-tenant web service in WSO2 Data Services?

I want to build a web service where not every user can see all data. 我想构建一个并非每个用户都可以看到所有数据的Web服务。 Therefor I need to store data in a multi-tenant fashion. 因此,我需要以多租户的方式存储数据。

Quick example: Car dealers. 快速示例:汽车经销商。

dealer 经销商

  • ID ID
  • name 名称
  • username 用户名

car 汽车

  • ID ID
  • name 名称
  • dealer_id (owned by) Dealer_id(拥有者)

Now the dealer calls the get_my_cars web service with his user credentials and should only see the cars that are owned by him. 现在,经销商使用他的用户凭证调用get_my_cars Web服务,并且应该只看到他拥有的汽车。 Something like: 就像是:

SELECT car.id, car.name
FROM car
JOIN dealer ON car.dealer_id = dealer.id
WHERE dealer.username = %CURRENT_WEBSERVICE_USER%

But how do I get the %CURRENT_WEBSERVICE_USER% variable into the MySQL query? 但是,如何将%CURRENT_WEBSERVICE_USER%变量放入MySQL查询中? Or am I doing something horribly wrong here? 还是我在这里做错了什么? How else would you filter data so everyone can only see his own data? 您还将如何过滤数据,以便每个人只能看到自己的数据?

Thanks for your replies! 多谢您的回覆!

Your usecase is not a multitenant usecase. 您的用例不是多租户用例。 What you need is to write a webservice(dataservice) and secure it with usernametoken/basicauth. 您需要编写一个webservice(dataservice)并使用usernametoken / basicauth对其进行保护。 When an user calls that service with his credientials, you need to query the database and return back the results. 当用户使用其凭证调用该服务时,您需要查询数据库并返回结果。 Simple secured webservice is what you need. 您需要简单的安全Web服务。

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

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