一个Web API令牌计划好办法? [英] Good approach for a web API token scheme?

查看:170
本文介绍了一个Web API令牌计划好办法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个REST API为到现在为止,我们已经为一对夫妇的伴侣应用内部开发的Web应用程序。现在,我们正在考虑开放给我们想要的标记,以帮助确定谁正在请求加入到API外部开发并在总体上帮助管理它的使用。在这一点上,我们使用的是HTTPS和基本身份验证的API用户认证。

I am working on a REST API for a web application that up until now we have developed internally for a couple of companion applications. Now that we are looking at opening up to outside developers we want to add tokens to the API in order to help identify who is making requests and in general to help manage it's use. At this point we are using https and basic authentication for user authentication on the API.

该标记方案,我们一直在讨论将是非常简单的,其中每个开发人员将被分配1个或多个标记和这些标记将与每个请求的参数传递。

The token scheme we've been discussing would be very simple where each developer would be assigned 1 or more tokens and these tokens would be passed as a parameter with each request.

我的问题是,如果你做了之前类似的东西你怎么做(你做多还是少,你是怎么处理的安全性等),你有什么建议?

My question is if you've done something similar before how did you do it (did you do more or less, how did you handle security, etc) and do you have any recommendations?

谢谢!

推荐答案

首先,你可能想看看 http://OAuth.net 。根据您的用例,它可能会提供您所需的安全性。

First, you might want look at http://OAuth.net. Depending on your usecases, it might provide the security you need.

至于令牌,这是一个BLOB大多数的协议,其中包括OAuth。你可以把你需要它的任何格式的任何信息。

As to the token, it's a BLOB to most protocols, including OAuth. You can put any information you need in it in any format.

下面就是我们要做的,


  1. 首先,我们为每个开发人员相关的秘密密钥。

  2. 令牌本身是一个加密的名称 - 值对。我们把东西像用户名,过期,会话ID,角色等在那里。它与我们自己的秘密加密,因此没有人可以做到这一点。

  3. 对于易于使用的Web API的使用,我们用Base64编码的URL安全的版本,以便令牌始终是URL安全的。

希望帮助!

这篇关于一个Web API令牌计划好办法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆