Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for account specific sub-domains #7

Closed
B-Interactive opened this issue Aug 24, 2022 · 6 comments
Closed

Option for account specific sub-domains #7

B-Interactive opened this issue Aug 24, 2022 · 6 comments
Labels
enhancement Not a bug, an improvement

Comments

@B-Interactive
Copy link
Owner

Perhaps to address issues with some countries blocking Cloudflare Stream access, Cloudflare has announced support for account specific sub-domain access to Cloudflare Stream resources.

The subdomain consists of an account specific code. I've not yet probed or tested this, but hopefully the code is obtainable via token based access to the API. If so, a plugin user could choose to activate use of the subdomain with a checkbox option.

I believe it needs to remain optional, because it could conflict with any pre-existing content security policies active on the web host (effectively blocking user access to content). In those cases, an admin needs to first update their web hosts content security policies to ensure the subdomain is permitted.

@davidmpurdy
Copy link
Collaborator

I agree with making it optional. Maybe in the future or for new plugin installs it should be enabled by default?

I don't see a way to get just the customer number via the API, but it does seem to be in pretty much all the URLs. I see two options:

  1. Make the user enter it in the options page (with instructions on where to find it). Right now they have it in a nice callout box at the top of the Stream dashboard, but if you dismiss that box (or they stop showing it), the only place I can find to get it is in the URL for an actual video.
  2. Use the API to do another operation (like list videos) and parse the customer ID from the source (e.g., for a thumbnail or manifest). The challenge here is I don't see an endpoint that looks like it would have the customer number in it if the account had no videos, which could be a common state when first setting up the plugin. So I would think the API call would have to happen later (e.g., when embedding or uploading a video for the first time).

Maybe I'm overlooking something, but aside from that (dismissible) callout box, it appears there's no way to get the customer number from an account with no videos (via the API or the dashboard). Maybe this is something to request?

@B-Interactive
Copy link
Owner Author

I want to expand scope of this into two areas of relevance.

Server: Server access to Cloudflare API and responses.
Client: End-user direct access to Cloudflare content (video, thumbnails), via embed code.

The Client aspect of this, I think is the more pressing issue, because it's the greater unknown. As admins, we know where our server geographically resides and to the best of our ability, ensure access to the Cloudflare API. However, we can't always know where the end-user resides, or what means they're using to connect to our service (VPN, proxy, etc).

The API generated embed code for displaying content to the end-user, would naturally include the subdomain. But as we currently use a manual embed code, the subdomain must be separately obtained.

I've queried this in the Cloudflare forum on the topic, with the hopeful outcome of an API call that includes the subdomain as a specific data object.

Failing that, we could otherwise parse it from an API call (like list videos) as you mentioned and populate the missing data, if and when it's available, which might not be right away if the account has no uploaded videos.

@B-Interactive
Copy link
Owner Author

Cloudflare have said they'll think about the ideal way to provide this subdomain/code via the API. For now, I'll standby for the outcome of that.

@B-Interactive B-Interactive added the enhancement Not a bug, an improvement label Aug 30, 2022
@B-Interactive
Copy link
Owner Author

I misunderstood the scope of this. When testing this more now and reviewing the announcement details, it's now clear this only impacts embed codes and thumbnail/video URLs.

Server-side code continues to reference the current domain for API requests.

@B-Interactive
Copy link
Owner Author

Initial steps for this have been added with b65053c.

It provides option for media domain in admin settings:

  • cloudflarestream.com (default)
  • videodelivery.net

The third option to be added still, will be the Cloudflare accounts unique sub-domain.

@B-Interactive
Copy link
Owner Author

B-Interactive commented Sep 5, 2022

Account specific sub-domains are now added with 74bfc5d. The embed code structure is slightly different when using it, so a bit of logic was necessary to handle that.

The subdomain details are parsed from the API response at /stream. Specifically, the thumbnail from the first video in the list. If no videos have been uploaded to the account, the option is not presented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Not a bug, an improvement
Projects
None yet
Development

No branches or pull requests

2 participants