如何在使用 SVN 时密码保护开发人员但不能使用? [英] How can I password protect dev but not live while using SVN?

查看:15
本文介绍了如何在使用 SVN 时密码保护开发人员但不能使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有这个工作流程:开发在 dev.example.com 上完成更改提交到 SVN,然后导出到实时站点.实时站点位于 www.example.com

We have this workflow: Development is done on dev.example.com Changes are committed to SVN, then exported to live site. Live site is at www.example.com

我想用密码保护 dev.example.com,但如果我用 .htaccess 来做,我们将在现场使用相同的 .htaccess,它也会得到密码保护.

I want to password protect dev.example.com, but if I do it with .htaccess, we will be using the same .htaccess at live site and it will get password protected too.

我们使用的是 Dreamhost 共享主机,我有 SSH 访问权限,但我无法编辑 Apache 的配置 .conf 文件.

We are using Dreamhost shared hosting, I have SSH access, but I can not edit Apache's configuration .conf files.

我们不想在 SVN 中为 dev&live 提供单独的 .htaccess 文件并忽略 .htaccess,因为对 .htaccess 也进行了更新.

We don't want to have separate .htaccess files for dev&live and ignore .htaccess in SVN because updates are done to .htaccess as well.

那我该怎么办?

推荐答案

如果在服务器上启用了 mod_setenvif,您可以将其添加到您的 .htaccess 文件中:

If mod_setenvif is enabled on the server, you could add this to your .htaccess file:

SetEnvIfNoCase ^HOST$ .+ unauthenticated
SetEnvIfNoCase ^HOST$ ^dev.example.com$ !unauthenticated

AuthType Basic
AuthName "Secured"
AuthUserFile /path/to/.htpasswd
Require valid-user
Order allow,deny
Allow from env=unauthenticated
Satisfy any

这基本上是设置一个名为unauthenticated"的环境变量,但如果 HOST(浏览器请求的主机)恰好是dev.example.com",则取消设置它.在 Directory 指令中,满足任何条件"告诉 Apache 在满足任何一个条件时允许该请求.这意味着在dev.example.com"上,不会设置环境变量,因此您需要输入密码.对于任何其他主机,将设置该变量,以便 Apache 不会要求提供凭据.

What this basically does is it sets an environment variable called "unauthenticated" but unsets it if the HOST (the host requested by the browser) is exactly "dev.example.com". In the Directory directive, the "satisfy any" tell Apache to allow the request if any one of the conditions are met. This means that on "dev.example.com", the environment variable won't be set and as such, you'll be required a password. For any other hosts, the variable will be set so Apache won't ask for credentials.

这篇关于如何在使用 SVN 时密码保护开发人员但不能使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆