...
The purpose of this tutorial is to outline the steps required to set up the ExampleWebsite ASP.NET web application, located at https://source.jasig.org/cas-clients/dotnet-client/trunk/ExampleWebSite/
System Environment
- Microsoft Visual Studio 2010 Professional Edition
- Windows 7 Professional
- AnkhSVN - Subversion Support for Visual Studio
- Internet Information Services 6 [Full Pack] (May be installed in "Windows Features")
- A git client such as GitExtensions.
Set up the CAS Server
Follow the instructions at this link to setup an instance of the CAS server. Additional software may be required.
Set up ExampleWebsite in Visual Studio
- Using the Git client, download the source from here.
- Launch Microsoft Visual Studio with admin privileges. You can do so by right clicking on Visual Studio and selecting Run as Administrator. This is required for you to publish application artifacts to the local instance of IIS.
- From the File menu, select Open -> Subversion Project. Enter the following link into the address bar: https://source.jasig.org/cas-clients/dotnet-client/trunk/ExampleWebSite/
Open the “DotNetCasClient.vs2010.sln” solution file. Visual Studio will download the artifacts to the project folder.
- Navigate to where you have the ExampleWebsite project and open it.
- Right click on the ExampleWebsite app and selecting Select as Startup Project.
- Right click on the DotNetCasClient app and select Build.
- Add a Web.config file to the ExampleWebsite. Copy the contents of web.config.sample file into Web.config and modify the following sections:
Code Block | ||||
---|---|---|---|---|
| ||||
<casClientConfig casServerLoginUrl="https://<youryour-full-machine-name>name:8443/cas/login" casServerUrlPrefix="https://<youryour-full-machine-name>name:8443/cas/" serverName="https://<your-full-machine-name>" notAuthorizedUrl="~/NotAuthorized.aspx" cookiesRequiredUrl="~/CookiesRequired.aspx" redirectAfterValidation="true" gateway="false" renew="false" singleSignOut="true" ticketTimeTolerance="5000" ticketValidatorName="Cas20" proxyTicketManager="CacheProxyTicketManager" serviceTicketManager="CacheServiceTicketManager" gatewayStatusCookieName="CasGatewayStatus" /> <authentication mode="Forms"> <forms loginUrl="https://<youryour-full-machine-name>name:8443/cas/login" timeout="90" defaultUrl="~/Default.aspx" cookieless="UseCookies" slidingExpiration="true" /> </authentication> |
- Replace the <youryour-full-machine-name> name with your full computer name.
...
- Expand the node Certificates – Current User,Trusted Root Certification Authorities and then Certificates.
- Make sure both certificates exist in the list. Also, copy all certificates and put them in Certificates – Local Computer - Trusted Root Certification Authorities. This is required for IIS to validate and authenticate requests.
Configure CAS Server Credentials
You should configure the CAS server credentials so they match the ExampleWebsite accounts, which are defined in App_Data\UserRoles.xml.
Locate the bean entry: $
CATALINA_HOME/webapps/cas/WEB-INF/deployerConfigContext.xml
- Locate the bean entry:
<
bean
class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler"
/>
- Replace it with the following:
Code Block | ||||
---|---|---|---|---|
| ||||
<bean class="org.jasig.cas.adaptors.generic.AcceptUsersAuthenticationHandler"> <property name="users"> <map> <entry> <key><value>admin</value></key> <value>admin</value> </entry> <entry> <key><value>bob</value></key> <value>bob</value> </entry> </map> </property> </bean> |
Info | |||||
---|---|---|---|---|---|
| |||||
If you have not followed the WAR Overlay Method to deploy CAS, you need to make sure the following dependency is properly declared inside the cas pom.xml file.
|
Run
First, make sure you have the CAS server up and running and you can log into CAS using the above credentials.
For the web application, (after you can launch the project by pressing F5 in the Visual Studio Environment. You should be redirected to: http://localhost:3273/ExampleWebSite/Default.aspxhave published the artifacts) you can browse to "https://<full-machine-name>" and you should be presented with the default page of the Example Website.
Info | ||
---|---|---|
| ||
You may have to configure IIS server bindings, so access to https://<full-machine-name> can be granted. |
Use the links on the left-hand side (i.e “Administrators Role Only”) to test the authentication mechanism. You should be redirected to CAS and after authenticating successfully with (i.e. admin/admin), you should be returned to the website and section allowed for admins onlyadmins only.