One of the way of building if conditional blocks with env variables is using mod_macro module.
I made an example previously here.
In this particular case you would have on top of the VirtualHost file (before the VirtualHost definition):
<Macro ConditionalBlockMacroSecurity_production>
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /path/to/file/.htpasswd
AuthGroupFile /dev/null
require valid-user
</Macro>
<Macro ConditionalBlockMacroSecurity_development >
<IfModule mod_headers.c>
Header set MyHeader "Hello this is DEVELOPMENT envirronment. It took %D microseconds for Apache to serve this request."
</IfModule>
</Macro>
And inside the Virtualhost:
Use ConditionalBlockMacroSecurity_${APP_ENV}
where path to the htpassword file could also be set as a parameter of the macro.
The downside of this solution is that you need to install mod_macro on the production server, it's not a commonly installed module and you will need some control of the production env to do that. On the other side, a simple solution is to have several version of your virtualhosts depending on the environment, and to add some comments on the Auth section. But if you are searching for a generic solution it certainly means it's a recurent problem and you want to avoid manual editing of files, in such cases mod_macro can become a very professional way of capitalizing your apache experiences, until your apache configurations becomes a single macro with parameters, calling a lot of other macros.
Satisfy All
because of other constraints. – Oneill