Closed alexhaberer closed 5 years ago
With regards to Windows system environment variables... you'd still have to manually update the CAS URL there. If I've understood you correctly, then you're just moving your problem from one place to a different place.
I'd ask the question "why does your CAS URL change every time your CAS SSO is updated?" I can't think of any good reason to do that. CAS is meant as a SSO (Single Sign On) system and usually lots of different systems use it as an authentication mechanism. That's not something you'd want to keep changing the URL of.
Maybe you and your team (and the CAS sysadmins) want to get together and put some automation behind your deployment processes. Something like Ansible. The scenario would be the CAS sysadmin deploys a new instance of CAS along with a new URL via Ansible. Then the next task would kick off to modify the web.config file on the web server(s) of your applications.
Honestly another quick solution is to make an entry in your DNS (your actual company DNS or whatever) for something like sso.example.com (but with your domain after the sso.) Then all of your applications just point to this domain. Then that name will resolve in your DNS to the new URL the CAS sysadmin keeps changing unnecessarily. Just update the DNS record when the CAS sysadmin does his/her crazy thing.
This way you abstract away the madness that your CAS sysadmin is doing.
I can't tell you why he changes the URL with new builds? But with the System Variable at least there would only be one location to update if multiple applications were made, I wouldn't need to go into every web.config to fix, just the Server's Environment Variable. From what I've seen online it doesn't seem that you can reference keys created within the web.config later on within the file.
I did see somewhere that linking an app.config file may be possible, then I would just be able to create an external file and have all our projects link/pull in that file.
https://www.youtube.com/watch?v=-KdqdWTNO7Q
Just not sure yet if that would work.
YouTubeHow to change connectionstring dynamically in c# connect to sql server database example. The c# basics beginner course is a free c# tutorial series that help...
I'm not actually sure I'm fully understanding your situation and I probably can't unless I see what you have actually done in your web.config.
You work at the University of South Dakota, correct? You guys already have your CAS server pinned to a "static" URL. This is it: https://sso.usd.edu
That's what you put in the web.config. Does that not work?
In the web.config file in the <forms>
element:
In the web.config file in the <casClientConfig>
element:
All of that should work.
Behind the scenes I think what you are referring to is the cluster of servers the CAS sysadmins are using behind a load balancer. They conveniently tell you the hostname of the actual server that is serving your CAS login page from behind the load balancer. If you view the source of the HTML on the login page there is an HTML tag called labelHostname. E.g. usd-cas4.usd.edu
I wouldn't actually use the servers behind the load balancer. Instead use sso.usd.edu
I think I was mistaken, it seems like our DEV version was changing very often, but the DNS for PROD was correct. I was just given some incorrect info which lead me on a wild goose chase. After speaking with our Operations team I believe no issue will come about until our next CAS upgrade.
:thumbsup:
Our CAS developer constantly changes the CAS URL with new builds, if I set the URL in the web.config I need to update the CAS path when he updates to a new build and URL. Is there a way to pull data from the systems environmental variables to populate it?
I've seen that they can add a key, but now how to use the key within the same file.
For more details please see https://stackoverflow.com/questions/57226685/is-it-possible-to-reference-environmental-variables-within-a-net-projects-web-c
Any options, bypasses, workarounds greatly appreciated.
Thanks,