Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making my web api secure?

Tags:

security

web

api

I am creating a simple web api that returns json.

It will perform simple crud operations.

What is the best way to authenticate users, OAuth seems to be the main recommendation here but I'm looking for something I can implement myself simply, token based or and API key??

Any ideas suggestions tips would be great, thanks

UPDATE: Forgot to mention, this API wont be for general comsumption, its just for my own use but I want to make sure someone cant get in too easily if they stumble on it.

like image 986
Rigobert Song Avatar asked Nov 07 '11 15:11

Rigobert Song


People also ask

How do I protect my private API?

You can protect your API using strategies like generating SSL certificates, configuring a web application firewall, setting throttling targets, and only allowing access to your API from a Virtual Private Cloud (VPC).

How do I protect my public API?

Use HTTPS/TLS for REST APIs As one of the most critical practices, every API should implement HTTPS for integrity, confidentiality, and authenticity. In addition, security teams should consider using mutually authenticated client-side certificates that provide extra protection for sensitive data and services.


1 Answers

First of all in order to build a good API you should use other people's API to see how they work. To be RESTful an API key is used, which is just a really big random number or "cryptographic nonce". But really this is just like immortal session id to look up a users authentication information, which isn't that great. OAuth is great, if you want your own system kerberos is very secure.

It is possible to hijack json responses, which is a pitfall against json. If the API key is required for each request, then the attacker can't use this method.

like image 169
rook Avatar answered Oct 06 '22 01:10

rook