简体   繁体   English

API注册和认证服务

[英]API registration and authentication service

I'm working on an API registration and authentication service application using python. 我正在使用python开发API注册和身份验证服务应用程序。 Developers will be able to register their application (domain name of the application) and a random API key will be generated for the registered application. 开发人员将能够注册其应用程序(应用程序的域名),并且将为注册的应用程序生成一个随机的API密钥。

Next, the registered application will send the API key to the API service with each API request. 接下来,注册的应用程序将在每个API请求中将API密钥发送到API服务。 API server will authenticate the domain of the incoming request with the passed API key to confirm that the request is valid. API服务器将使用传递的API密钥对传入请求的域进行身份验证,以确认该请求有效。 I'm using Forwarded Host to validated the domain name of the API request, however it doesn't work as in some cases (when the opened page is the first page), Forward Host comes blank. 我正在使用转发主机来验证API请求的域名,但是在某些情况下(当打开的页面为第一页时)它不起作用,转发主机为空白。

Are there a better approach to authenticate the request or any changes required in the API registration process to reliably authenticate the request? 是否有更好的方法来认证请求或API注册过程中需要进行任何更改以可靠地认证请求? Some pointers will be helpful. 一些指针会有所帮助。

Using Authorization proxy 使用授权代理

Samples are "3scale.net", offering free tier, other commercial solutions exist too. 样本为“ 3scale.net”,提供免费套餐,还存在其他商业解决方案。

Open source solution I am aware of is ApiAxle , which is much simpler, but still very useful. 我知道的开源解决方案是ApiAxle ,它虽然简单得多,但仍然非常有用。

The proxy takes care of managing access keys and forwards request back to real application only in case, it is really to be served. 代理负责管理访问密钥,并且仅在确实需要服务的情况下才将请求转发回真实应用程序。

Using Authorization service 使用授权服务

Another solution is to have some internal service evaluating set of client provided keys (providerid, appid, accesskey, ...) are authrized or not. 另一个解决方案是让一组内部服务评估客户端提供的密钥(提供密钥,appid,accesskey等)是否经过认证。 For this purpose, you have to: 为此,您必须:

  • set up authorization service 设置授权服务
  • modify your code by adding 2-3 lines at the top of each call calling the authentication service. 通过在每个调用身份验证服务的呼叫的顶部添加2-3行来修改您的代码。

Sample code for 3scale is here: https://github.com/3scale/3scale_ws_api_for_python 3scale的示例代码在这里: https : //github.com/3scale/3scale_ws_api_for_python

Conclusions 结论

  • Authentication proxy makes the application simple and not bothering about who is asking. 身份验证代理使应用程序变得简单,并且无需担心谁在询问。 This can be advantage until your application needs to know who is asking. 在您的应用程序需要知道谁在询问之前,这可能是一个优势。
  • Authentication service requires changing your code. 身份验证服务需要更改您的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM