dsfliu1129 2014-11-30 21:07
浏览 53
已采纳

API安全问题

I'm aware multiple questions have been asked on the topic but none have really answered my specific question.

My app

I have a PHP-based API that retrieves AND posts information from my MySQL database. I use it to check for login, to create new accounts, but also to retrieve simple data from the database. My app isn't on the AppStore yet, and right now, my API has no security whatsoever: it's the first API I've ever made, and I was just focusing on the basics. Now it's over, I want to add some security. I've done lots of research and oAuth seems over the top and way too difficult for what I'm trying to do here. I'm confused on the oAuth topic, about 2-legged or 3-legged oAuth.

Let's say I want this simple scheme to be secured: 1) users enters login information 2) iOS app sends credentials to PHP-based API server 3) API checks in database if login credentials are correct 4) API returns (in jSON) the result of the request 5) App process the jSON

This is the current flow. What is the most simple way to secure this? Is oAuth worth it or can I make a simpler, hand-made encryption system with a private key only my app and my API would know and that I would simply add in the POST?

  • 写回答

1条回答 默认 最新

  • dousi0144 2014-11-30 21:16
    关注

    General rule of thumb for security is to go with a tried and tested solution. As such oAuth with some external sign-in method (Like Facebook, Google, Twitter etc) is a good way to go. I think you'll find that it's a lot less work actually than rolling your own user data base, password handling, authentication and so on.

    However if you're not keen on doing this, there are most likely complete PHP frameworks for adding security, for example PHP-LOGIN. If you insist on doing it yourself, the answers here might provide some detail: Developing a secure PHP login and authentication strategy although I strongly advise against implementing your own security solution unless you're an expert in the area.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 onlyoffice编辑完后立即下载,下载的不是最新编辑的文档
  • ¥15 求caverdock使用教程
  • ¥15 Coze智能助手搭建过程中的问题请教
  • ¥15 12864只亮屏 不显示汉字
  • ¥20 三极管1000倍放大电路
  • ¥15 vscode报错如何解决
  • ¥15 前端vue CryptoJS Aes CBC加密后端java解密
  • ¥15 python随机森林对两个excel表格读取,shap报错
  • ¥15 基于STM32心率血氧监测(OLED显示)相关代码运行成功后烧录成功OLED显示屏不显示的原因是什么
  • ¥100 X轴为分离变量(因子变量),如何控制X轴每个分类变量的长度。