authorization and authentication mechanism in GCP

廉价感情. 提交于 2021-02-11 14:21:54

问题


I want to create a Udemy like video platform where a user can see all videos but can watch videos only that he has purchased.

I am making a rest call to get the videos from the storage bucket from an angular application, using Firebase authentication here. In my GET request to storage bucket I am passing the access token that I got from Firebase authn.

Does this access token can be used to determine scope of the user to access video in a bucket?

Assume if I have given read access for a video in a bucket for a specific user, using the access token can I get the video? But every time I tried it shows unauthorized. Is there any other way to verify users access to storage bucket object.


回答1:


Google recommend to not use ACL because it's hard to manage and to have a global view on the authorization.

In most cases, Cloud Identity and Access Management (Cloud IAM) is the recommended method for controlling access to your resources.

Caution: Permissions can be granted either by ACLs or Cloud IAM policies. In general, permissions granted by Cloud IAM policies do not appear in ACLs, and permissions granted by ACLs do not appear in Cloud IAM policies. The only exception is for ACLs applied directly on a bucket and certain bucket-level Cloud IAM policies, as described in Cloud IAM relation to ACLs.

IMO, the best pattern is to have a database on your side with the file on GCS allowed per user. You can store these in Firestore: affordable, pay as you use, generous free tier. For downloading the video, you can generate a temporarily access to the user by generating a signedUrl.




回答2:


As per mention Guillaume Cloud Storage use the ACL pattern in order to have a control to the access of the resources stored in their buckets.

Nevertheless, when you need to storage wide objects per user in this case a video, you can store these in Firestore: affordable, pay as you use, generous free tier. This is a very suitable option since Firestore can use as another resource

Is recommended for this scenario generate a signed URL



来源:https://stackoverflow.com/questions/62532907/authorization-and-authentication-mechanism-in-gcp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!