CAS Apache2: Password Protect Directory

Note tutorial based on linux type os, not sure how it would work for anything else


  • Web Server running apache2
  • Knowledge of what the CAS login URL is
  • Knowledge of what the CAS validate URL is
  • Knowledge of what the CAS certificate is

Step 1: Installing the CAS module

sudo apt-get install libapache2-mod-auth-cas

Step 2: Enabling the CAS module

cd /etc/apache2/mods-available/
sudo a2enmod auth_cas

Step 3: Creating the certificate

sudo vim /etc/ssl/certs/cert.pem

Then paste the certificate into the file.

Step 4: Editing the VHost File

sudo vim /etc/apache2/sites-available/default

Paste in:

<IfModule mod_auth_cas.c>
  CASCertificatePath /etc/ssl/certs/cert.pem
  CASCookiePath /tmp/
  CASValidateServer On
  CASDebug Off

<Directory "/var/www/path/to/directory">
 <IfModule mod_auth_cas.c>
   AuthType CAS
   AuthName "CAS Login"
    AuthGroupFile /var/secureusers
    Require group secureusers
    Satisfy All

Note, add in the correct urls. The “AuthGroupFile”, and “Require group” are optional. Step 5 explains what you do if you included them.

Step 5 (Optional): Creating users restrictions

sudo vim /var/secureusers

Paste in:

secureusers: user-name user-name