KalVik
KalVik

Reputation: 19

Is there any way to restrict some users to access cloudflare cached videos from s3

Suppose I have a educational app which serves videos from cloudflare cache from s3 (as direct accessing from s3 would be expensive). So is there any way to serve these videos only to paid users. ? Signed url is expensive as then I cant use caching.

Upvotes: 1

Views: 135

Answers (1)

Paolo Tagliaferri
Paolo Tagliaferri

Reputation: 1021

Using Cloudflare, this scenario can be supported in a number of ways:

  1. Use Firewall Rules to require a valid HMAC token on the requests. Your application would be responsible for creating the token.
  2. Use Cloudflare Workers to write your own token authentication logic, allowing only paying users to reach the videos. I recommend the following tutorial which explains how to handle authentication (with Auth0 as an example). Workers also expose a Cache API which can be used to fine tune the caching behaviour (if needed).
  3. Migrate the videos from S3 to Cloudflare Stream. Then use the Stream API to create Signed URLs / tokens for authorization.

Cloudflare Stream could be interesting in particular since it also offers an API for the upload of the videos, meaning most of the capabilities are ready to use and to integrate into your application.

Upvotes: 2

Related Questions