Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For an example of how to do CAS proxying with classic ASP, see me other article CAS Proxying with Classic ASP

First

...

drop the

...

CASAuthentication.dll (attached) into your project's bin folder. Then, In Web.config, make the following changes:

  1. Turn on Forms Authentication:
    Code Block
    xml
    xml
    <!--Authentication mode configuration -->
    <authentication mode="Forms">
        <forms name="casAuth" defaultUrl="Default.aspx" loginUrl="Login.aspx" />
    </authentication>
    
  2. Deny all unauthenticated users
    Code Block
    xml
    xml
    <!-- Authorization configuration -->
    <authorization>
      <deny users="?"/>
    </authorization>
    
  3. Include the CAS.Web.Security namespace in your pages section.
    Code Block
    xml
    xml
    <!-- Pages configuration, Globally Import the CAS.Web.Security namespace so it can be used throughout your CAS application -->
    <pages>
      <namespaces>
        <add namespace="CAS.Web.Security"/>
      </namespaces>
    </pages>
    
  4. Add the CAS host url to the appSettings section. You must name the key: CASURL
    Code Block
    xml
    xml
    <!-- Application settings configuration -->
      <appSettings>
        <!---change CAS Url accordingly-->
        <add key="CASURL" value="https://auth.berkeley.edu/cas"/>
      </appSettings>
    
  5. Add an httpModules section with the following module. It must be inside the system.web section of your web.config file.
    Code Block
    xml
    xml
    <httpModules>
      <add name="CASAuthenticationV2" type="CAS.Web.Security.CASAuthenticationV2, CASAuthentication"/>
    </httpModules >
    
  6. (Optional) If you want all CASAuthentication class related errors routed to your own error page, simply add a customErrors page section to your system.web section. Mode must be set to On for the errors to be re-directed. If mode is Off or the customErrors section is not present in web.config, all errors will be written out to the current application page.
    Code Block
    xml
    xml
    <customErrors mode="On" defaultRedirect="MyErrorPage.aspx">
      <error statusCode="403" redirect="NoAccess.htm"/>
      <error statusCode="404" redirect="FileNotFound.htm"/>
    </ customErrors>
    
    In this example, the page MyErrorPage.aspx can access the last error reported by calling the CASAuthentication.LastError property of the CASAuthentication class.

...