Skip to main content

Simulate an authentication workflow for CAS, particularly for service checks

Project description

cas-simulation

A way to simulate a web browser visiting a service authenticated by CAS and proceeding through the authentication.

Originally developed to facilitate authenticated service checks in Nagios.

check_cas_sp

cas_simulation object instances are created using the included check_cas_sp script, intended to be called from Nagios

The simulation will follow redirects from a starting URL (typically a service provider like https://myportal.example.edu) until it reaches a form that it believes is a CAS authentication page (at least the one presented by the JASIG/Apereo implementation). It will then submit the form using the credentials provided. It will follow redirects and submit forms (e.g. "Click here to continue" javascript alternatives) until it receives a 200 OK page without a form, or the form contains an id or action attribute matching argument provided to the --form.

The final landing page is searched for an expected pattern using --expression. If it matches, the script returns 0 which corresponds to a OK in Nagios API. Otherwise it returns 2 for CRITICAL

Optionally, the check_cas_sp will also fetch and check an expression against a URL that is only expected to be available after authentication. This would simulate clicking a link on a portal after logging in.

Gotchas

Notably, the --verbose option stupidly assumes it can write to /var/log/nagios

Examples

check_cas_sp --help

List all current command line options

check_cas_sp \
    --url https://fee-portal.csusb.edu/auth/shibboleth" \
    --expression "Fines .{1,30}for Joe Coyote" \
    -w 5.0 \
    --post-auth-check https://fee-portal.csusb.edu/fines/alma "Balance [Dd]ue" \
    --credentials "/etc/cas/joe-creds.json" \

Authenticate fee-portal.csusb.edu using the credentials in /etc/cas/joe-creds.json. The post authentication redirect contains "Fines and fees for Joe Coyote" and should match the regular expression given.

After that check, also check a url that requires an authenticated active session. In this case, a check for the Alma library fees that should contain the text "Balance Due". Return WARNING if the authentication takes more than 5 seconds. (It probably should be --post-auth-url and --post-auth-expression instead of being combined like it is.)

check_cas_sp \
    --url https://my.csusb.edu \
    --expression 'Signed in as Joe Coyote<div .{1,30}>Tap to sign out' \
    -w 10 \
    --form '/default/kurogo_module_search/search' \
    --credentials credentails.json

Authenticate to my.csusb.edu and expect a name next to a "Tap to sign out" after authentication. Do not proceed past the form with the name or id of '/default/kurogo_module_search/search' Typically, the simulation will submit any forms it encounters, assuming they are "Click here to continue" type forms)

Examples Nagios command objects

define command {
        command_name    check-cas-sp
        command_line    /opt/virtualenv/cas-simulation/bin/check_cas_sp --url '$ARG1$' --expression '$ARG2$' $ARG3$ --verbose --credentials /etc/nagios/secrets/credentials.json
}
define command {
        command_name    check-cas-sp-post-auth
        command_line    /opt/virtualenv/cas-simulation/bin/check_cas_sp --url '$ARG1$' --expresison '$ARG2$' $ARG3$ --post-auth-check '$ARG4$' '$ARG5$' --verbose --credentials /etc/nagios/secrets/credentials.json
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cas-simulation-1.1.1.tar.gz (6.1 kB view details)

Uploaded Source

File details

Details for the file cas-simulation-1.1.1.tar.gz.

File metadata

  • Download URL: cas-simulation-1.1.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.5.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.15

File hashes

Hashes for cas-simulation-1.1.1.tar.gz
Algorithm Hash digest
SHA256 f819b21884cd54bdd04280039fa60cb51a3e45c030ce9fcad022698595a1252e
MD5 e9695f9d95c42a42af23ca23287948cf
BLAKE2b-256 6e85aa2ae8ed3a817ac2f49554c49c01c0e33c737eb2083783dfbd6773f5a413

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page