So we're building a RESTful service on google cloud running on GCE instances. This service is going to be consumed internally, i.e. web servers. I'm thinking about securing this service using Oauth.
Instead of maintaining our own database of consumer key/secrets tho, is it possible to leverage on what Google authentication already provide? So I'm envisioning the following:
I couldn't find anything like this in Google cloud documentation, thought I throw it out here and see if SO knows better :)
Thanks!
答案 0 :(得分:4)
这里有几件事要考虑。
首先,我们提供server to server authentication through OAuth,但这是针对Google API的。
第二,我们提供Cloud Endpoints server to server authentication,但这是Cloud Endpoints上托管的API,而不是您自己的GCE VM上托管的自定义API。
我想了解的是,您在VM端使用什么框架或代码来处理OAuth。您想允许/禁止谁?您末端实际上不可能没有任何身份验证代码,否则有什么意义?任何服务帐户都可以通过。您如何控制范围?服务帐户如何知道请求的范围?您的API如何处理授权部分?如果您要使用完整的API,则最好使用Cloud Endpoints,因为我之前提到的所有内容都将在我们端得到处理。
如果您要设计一个简单的HTTP API,基本上是一个处理GET / POST请求并在Google Cloud上吐出对您自己的服务的响应的处理程序,则只需设置secure service to service communication
答案 1 :(得分:3)
对于遇到这个问题的任何人,您可能都希望使用身份识别代理-https://cloud.google.com/iap/docs/authentication-howto
它将在您的服务之前放置一个托管代理,该代理需要具有Google帐户的oAuth2才能通过。同时具有浏览器流和程序流。
然后它通过标头传递到您的服务,您可以使用该标头查看用户身份并验证他们是否经过身份验证
答案 2 :(得分:3)
您的用例正是Google Cloud Endpoints为您提供的: -使用服务帐户进行身份验证 -控制台中的API指标
Cloud Endpoints是一个API管理系统,可帮助您使用Google用于其API的相同基础结构来保护,监视,分析和设置API的配额。将API部署到Cloud Endpoints后,您可以使用Cloud Endpoints Portal创建开发人员门户,API用户可以访问该网站以查看文档并与API进行交互。
在身份验证部分中,找到有关如何使用服务帐户(其他可用方法)进行安全保护的relevant documentation。