Adding CAS to your .NET application can be done with a few simple steps. Full implementation details are available at https://wiki.jasig.org/display/CASC/.Net+Cas+Client but for purposes of Auburn sites do the following:
<configSections> <section name="casClientConfig" ;type="DotNetCasClient.Configuration.CasClientConfiguration, DotNetCasClient"/> <!-- Other custom sections here --> </configSections>
<casClientConfig casServerLoginUrl="https://authenticate.auburn.edu/cas/login" casServerUrlPrefix="https://authenticate.auburn.edu/cas/" serverName="https://{YourAuburnURL}" notAuthorizedUrl="~/NotAuthorized.aspx" cookiesRequiredUrl="~/CookiesRequired.aspx" redirectAfterValidation="true" renew="false" singleSignOut="true" ticketValidatorName="Cas20" serviceTicketManager="CacheServiceTicketManager" />
<httpModules> <add name="DotNetCasClient" type="DotNetCasClient.CasAuthenticationModule,DotNetCasClient"/> <!-- Other modules here --> </httpModules>
and
<system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules> <remove name="DotNetCasClient"/> <add name="DotNetCasClient" type="DotNetCasClient.CasAuthenticationModule,DotNetCasClient"/> <!-- Other modules here -->
</modules> </system.webServer>
<authentication mode="Forms"> <forms loginUrl="https://authenticate.auburn.edu/cas/login-d" timeout="30" defaultUrl="~{YourDefaultPage}" cookieless="UseCookies" slidingExpiration="true" path="/{YourSiteName}/" /> </authentication>
//this attribute will redirect the user to authenticate if they aren't already //authorize is a misnomer in this case as this doesn't manage user authorization at all [Authorize] public ActionResult LogOn() { return RedirectToAction("Index", "Home"); } public ActionResult LogOff() { FormsService.SignOut(); return RedirectToAction("Index", "Home"); }
public ActionResult Index() { //this.ControllerContext.HttpContext is the alternative for HttpContext.Current.User in webforms string username = this.ControllerContext.HttpContext.User.Identity.Name; return View(); }