如何设计RESTful的API权限

WBOY
Release: 2016-06-06 20:34:56
Original
1507 people have browsed it

RT,授权给某个app_id一个access_token,让其访问API的某些资源。如果每个url资源都设置权限的话,好像很麻烦,而且同一个url还分GET、POST等不同请求,如果分别设置权限好像更麻烦。

有没有好的解决方案?

回复内容:

RT,授权给某个app_id一个access_token,让其访问API的某些资源。如果每个url资源都设置权限的话,好像很麻烦,而且同一个url还分GET、POST等不同请求,如果分别设置权限好像更麻烦。

有没有好的解决方案?

1、token形式
2、oauth2

可以看看这个回答,希望能对你有帮助http://segmentfault.com/q/1010000002567482/a-1020000002568368

ps:不要怕麻烦,有这个需求就要做的。权限管理有很多工具的,比如spring security就是一个权限管理框架

推荐一个很不错的文章:

http://blog.jobbole.com/41233/

可以参考下。

RESTful的授权依靠框架就能解决 比如Jersey Spring,以及servlet容器等都提供授权机制;RESTful难的是认证,token一旦被劫持,授权就没有意义了。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!