I'm setting up a development template for .Net
projects. With that I'm using dot-net-cas-client for authentication backed by ADFS. The issue is, at times our CAS developer changes/migrates the service to new URLs.
Thus, if a plethora of projects were live and an update to the CAS URL has changed. I wouldn't want to manually update CAS URL locations for every live projects' web.config file
(I did consider creating a Powershell script that would read through all of the server directories searching for the web.config
files and then read through by line and capture the CAS URL strings to replace, but that seems outdated and could be problematic).
I was hoping to use environmental variables at the system or machine level, that way the web.config
files could reference one location and obtain the current URL there. Thus only one location would need to be updated when/if a change occurred.
I see that I can add a key to get environment variables' values and use it within the projects code, but I didn't find anything about then using that key or reference directly within the web.config
file.
I've attempted to create and reference a key, reference the environment variable directly %environmentVariableName%
, but wasn't sure on if it was possible within the web.config
.
I attempted to reference the variable %system.variable%
directly but didn't obtain the environmental variable value.
dot-net-cas-client
settings:
<casClientConfig casServerLoginUrl="https://example.com/cas/login"....
Replaced by something like:
<casClientConfig casServerLoginUrl="%environmentVariableName%"....
OR
<casClientConfig casServerLoginUrl=%environmentVariableName%....
OR
<casClientConfig casServerLoginUrl=Environment.ExpandEnvironmentVariables(ConfigurationManager.AppSetting("environmentVariableName"))....
The above all threw errors (missing quotes) or the request sent me to ...%environmentVariableName%...
rather then ...example.com/cas/login...
I understand you can add a KEY which I have also tried:
<add key='SomeSetting' value='%environmentVariableName%'/>
But didn't see anything about referencing that KEY directly in the settings of the web.config
file.
dot-net-cas-client
"casServerLoginUrl" and other attributes expect a string encapsulated by quotes. Or directed me to my URL, but with %environmentVariableName%
instead of the value stored in that variable.