如何仅向经过身份验证的用户显示流媒体视频?

发布于 2024-10-20 18:15:25 字数 270 浏览 1 评论 0原文

我正在 CakePHP 中创建一个 Web 应用程序,让用户注册并上传他们的照片和 flv 视频,然后用户自己和他列表中的朋友就可以查看这些照片和 flv 视频。现在,对于图像部分,上传的文件将转到 htaccess 受保护的文件夹,然后经过身份验证的用户通过 php 脚本读取该文件夹。但是,我也想通过流媒体视频实现同样的目标。

那么,是否可以通过 php 流式传输视频,并且使用 htaccess 来保护您的用户文件是否安全?如果没有,有人可以指导我以正确的方式处理这种情况吗?

提前致谢。

I am creating a web application in CakePHP that lets a user register and upload their photos and flv videos that can be then viewed by the user himself and the friends in his list. Now, for the images part, the uploaded files are going to a htaccess protected folder which are then being read through a php script by the authenticated users. But, I want to achieve the same with streaming videos as well.

So, is it possible to stream videos through php and is it safe to use htaccess to protect your user files? If not, can someone guide me through a proper way of handling such situations?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷荒 2024-10-27 18:15:25

aadravid,

阅读有关 htaccess 解决方案的信息,我想知道是否 AUTH/基于 ACL 的方法不会更好。进入这个领域的最简单方法是acl/auth 教程< /a>.

仅使用 CakePHP 功能来实现它可以消除看起来奇怪的 Apache 身份验证弹出窗口。

编辑0:
也许安全组件适合您?

编辑1:
进一步思考和讲授,您可能:

  1. 必须为每个用户创建一个文件夹,使父文件夹不显示索引(通过 .htaccess)。如果您想尝试一下,您可以将文件夹名称随机映射到用户,这为“好奇的人”增加了另一个困难。
  2. 自动为每个文件夹创建 .htaccess 文件,包括必要的文件,例如 webroot 之外的 usersHTpasswd。在 usersHTPasswd 中,您可以根据在初始化用户文件夹的同时使用的方法添加 htpasswd 哈希值。只需查找这是如何完成的(猜猜 md5,但你可以调整那个恕我直言)
  3. 通过 PHP 标头函数(或更好的蛋糕)操作基本身份验证凭据。
    对于组访问,您可以在此步骤中施展一些魔法。

优点(如果该解决方案有效,你就是我的小白鼠:-)):

  • 一旦设置完毕,安全性就相当于 htaccess 解决方案,解决了用户泄露其凭据的唯一弱点。
  • 基本想法是,如果用户尚未经过身份验证,则仅使用 SecurityComponents 强制登录功能(也许可以完全省略 SecurityComponent)
  • 流式视频就像在视图中弹出 html5 视频标签并引用目标一样简单。
  • 在具有(.htaccess 文件)的共享主机上工作
  • 将比 SSL 更酷

弱点:
- 不幸的是,这不是一个一键蛋糕php就会做的解决方案

明确用于创建这篇文章的来源:

  • devshed ,有很好的想法,但受到可读文件夹
  • apache httpd for htaccess,DirectoryIndex

我花了很长时间才想出这个,所以每个人都可以随意讨论你的想法(或投赞成票:-))

编辑2:
wrksx 是 cakePHP 社区的活跃贡献者,他给了我尝试 MediaView 的建议
*嗅探*

编辑3:
另一个贡献者, voidet,指出 MediaView 的分块 - 以及您使用的通过 PHP 提供静态文件的方法 - 会占用 CPU。您可以安装
x-sendfile 作为 apache 模块或诉诸我的解决方案,如果性能影响太大。
维护 htaccess 文件可能具有挑战性。

aadravid,

reading about the htaccess solution, i wonder if a AUTH/ACL based approach would not be better. The easiest way to enter this realm is the acl/auth tutorial.

Implementing it exclusively with the CakePHP features would get rid of the strangely looking Apache authentication popup.

Edit0:
Maybe the Security Component is for you?

Edit1:
Giving it further thought and lecture, you maybe:

  1. Have to create a folder for every user, making the parent folder not showing the indices (via .htaccess). If you want to go fancy, you could map foldernames to users randomly, adding another difficulty for "curious people".
  2. Create the .htaccess file for each of these folders automatically, including the necessary file e.g. usersHTpasswd somewhere out of the webroot. In usersHTPasswd you would add the htpasswd hash according to your method used at the very same time you would initialize a users folder. Just lookup how this is done (guess md5, but you can tune that imho)
  3. Manipulate basic authentication credentials via PHP header functions (or better cake).
    For group access, you could do some magic in this step.

Strong points (if the solution works, you are my guinea pig :-)):

  • Once this is set up the security is equivalent to the htaccess solution to the only weak point of a user giving away her credentials.
  • The basic idea then would be to only use the SecurityComponents force login feature if the user is not AUTH-enticated yet (maybe SecurityComponent can be omitted completely)
  • Streaming video is as easy as popping a html5 video tag in your view and referencing the target.
  • works on shared hosts with (.htaccess files)
  • will be cool over SSL

Weak points:
- Unfortunatly not a one-call-cakephp-will-do-it solution

Sources explicitly used to create this post:

  • devshed , has neat idea(s) but suffers from readable folder
  • apache httpd for htaccess, DirectoryIndex

It took me quite a time to come up with this, so everybody feel free to discuss your ideas (or upvote :-))

Edit2:
wrksx, an active contributor in the cakePHP community, gave me the tip to try MediaView
*sniff*

Edit3:
Another contributor, voidet, pointed out that MediaViews chunking - and by the way your used method of serving static files through PHP - hits the CPU. You can install
x-sendfile as apache module or resort to my solution, if the performance hit is too big.
Maintaining the htaccess files could be challenging.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文