douzi0609 2014-03-20 18:23
浏览 68
已采纳

将我的RESTful API仅限于我的应用程序

I recently started using BackboneJS and for a new project I need to access a MySQL database on a server I have full access to.

I've been reading up on RESTful APIs and now I want to set up one but I'm not quite sure about one thing: will other people be able to insert rows into my database via the RESTful API I will set up (using Slim)

I know it won't be possible using JavaScript/AJAX because of the same domain policy. But what if someone POSTs to the API using PHP/cURL or something similar? Will it be possible to insert rows using this method without me checking stuff on the server-side?

In short I just want to be sure I'm the only one that can insert (create, put, delete) things into the database, I don't really care about reading (get) but I'm guessing that if you can't insert you can't read either.

EDIT

Please note that this question is not about authenticating users, It's about whether others will be able to simply use my API using cURL or something similar.

  • 写回答

2条回答 默认 最新

  • drvvepadi289421028 2014-03-20 19:04
    关注

    Limit your API to respond to only servers that are allowed. E.g: Limit the IP addresses that can use the API.

    If your RESTful API and MySQL are hosted on the same server, you could limit the API to respond only if the requesting IP address is 127.0.0.1.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条