Securing a REST API in Java [closed]

2019-04-28 20:39发布

I am building a REST API in Java - using Jersey. I want to secure sensitive API calls with an API token security scheme, but I don't have any idea where to start.

Is there a framework that will do this for me out of the box? Or do I have to implement my own security scheme?

2条回答
Ridiculous、
2楼-- · 2019-04-28 21:22

There are several frameworks to do secure Java RESTful web services. I would recommend "Apache Shiro" (http://shiro.apache.org/), it is a very nice and easy to use security framework that will allow you to implement the API token security scheme you mention. Take a look at this response: REST API key generation strategy (where I gave some insights on creating such a solution).

There are other security frameworks you can use, namely Java EE has support for security and also Spring provides support for security. Take a look at this very nice presentation by Matt Raible where he presents and demos these three frameworks: http://www.slideshare.net/mraible/java-web-application-security-denver-jug-2013

Avoid to implement "your own security scheme" (if you are not an expert in the topic...), there are many issues that may be overlooked and lead to problems... normally these frameworks help a lot on avoiding that.

HTH.

查看更多
Rolldiameter
3楼-- · 2019-04-28 21:29

You can take a look at OAuth. Its widely adopted and there are libraries that help you implement the protocol

查看更多
登录 后发表回答