phpCAS version 1.3.6

Functions
Authentication
User interface

## Functions
static | phpCAS::setCacheTimesForAuthRecheck ($n)
static | phpCAS::setCasAttributeParserCallback ($function, array $additionalArgs=array())
static | phpCAS::setPostAuthenticateCallback ($function, array $additionalArgs=array())
static | phpCAS::setSingleSignoutCallback ($function, array $additionalArgs=array())
static | phpCAS::checkAuthentication ()
static | phpCAS::forceAuthentication ()
static | phpCAS::renewAuthentication ()
static | phpCAS::isAuthenticated ()
static | phpCAS::isSessionAuthenticated ()
static | phpCAS::getUser ()
static | phpCAS::getAttributes ()
static | phpCAS::hasAttributes ()
static | phpCAS::hasAttribute ($key)
static | phpCAS::getAttribute ($key)
static | phpCAS::handleLogoutRequests ($check_client=true, $allowed_clients=false)
static | phpCAS::getServerLoginURL ()
static | phpCAS::setServerLoginURL ($url='')
static | phpCAS::setServerServiceValidateURL ($url='')
static | phpCAS::setServerProxyValidateURL ($url='')
static | phpCAS::setServerSamlValidateURL ($url='')
static | phpCAS::getServerLogoutURL ()
static | phpCAS::setServerLogoutURL ($url='')
static | phpCAS::logout ($params="")
static | phpCAS::logoutWithRedirectService ($service)
static | phpCAS::logoutWithUrl ($url)
static | phpCAS::logoutWithRedirectServiceAndUrl ($service, $url)
static | phpCAS::setFixedCallbackURL ($url='')
static | phpCAS::setFixedServiceURL ($url)
static | phpCAS::getServiceURL ()
static | phpCAS::retrievePT ($target_service, & $err_code, & $err_msg)
static | phpCAS::setCasServerCACert ($cert, $validate_cn=true)
static | phpCAS::setNoCasServerValidation ()
static | phpCAS::setNoClearTicketsFromUrl ()

## Detailed Description

## Function Documentation

## ◆ checkAuthentication()

static phpCAS::checkAuthentication | ( |  | ) |
| static

This method is called to check if the user is already authenticated locally or has a global cas session. A already existing cas session is determined by a cas gateway call.(cas login call without any interactive prompt)

Returns
  true when the user is authenticated, false when a previous gateway login failed or the function will not return if the user is redirected to the cas server for a gateway login attempt

Examples:
  example_gateway.php.

Definition at line 1073 of file CAS.php.

References $auth, phpCAS\_validateClientExists(), phpCAS\traceBegin(), and phpCAS\traceEnd().

## ◆ forceAuthentication()

static phpCAS::forceAuthentication | ( |  | ) |
| static

This method is called to force authentication if the user was not already authenticated. If the user is not authenticated, halt by redirecting to the CAS server.

Returns
  bool Authentication

Examples:
  example_advanced_saml11.php, example_custom_urls.php, example_gateway.php, example_html.php, example_lang.php, example_logout.php, example_pgt_storage_db.php, example_pgt_storage_file.php, example_proxy_GET.php, example_proxy_POST.php, example_proxy_serviceWeb.php, example_proxy_serviceWeb_chaining.php, example_service.php, example_service_POST.php, example_service_that_proxies.php, and example_simple.php.

Definition at line 1094 of file CAS.php.

References $auth, phpCAS\_validateClientExists(), phpCAS\traceBegin(), and phpCAS\traceEnd().

## ◆ getAttribute()

static phpCAS::getAttribute | ( |  | $key | ) |
| static

Answer an attribute for the authenticated user.

Parameters

  string | $key | attribute name

Returns
  mixed string for a single value or an array if multiple values exist.

Warning
  should only be called after phpCAS::forceAuthentication() or phpCAS::checkAuthentication().

Definition at line 1253 of file CAS.php.

References phpCAS\_validateClientExists(), and phpCAS\error().

## ◆ getAttributes()

static phpCAS::getAttributes | ( |  | ) |
| static

Answer attributes about the authenticated user.

Warning
  should only be called after phpCAS::forceAuthentication() or phpCAS::checkAuthentication().

Returns
  array

Examples:
  example_advanced_saml11.php.

Definition at line 1194 of file CAS.php.

References phpCAS\_validateClientExists(), and phpCAS\error().

## ◆ getServerLoginURL()

static phpCAS::getServerLoginURL | ( |  | ) |
| static

This method returns the URL to be used to login. or phpCAS::isAuthenticated().

Returns
  the login name of the authenticated user

Definition at line 1285 of file CAS.php.

References phpCAS\_validateClientExists().

## ◆ getServerLogoutURL()

static phpCAS::getServerLogoutURL | ( |  | ) |
| static

This method returns the URL to be used to login. or phpCAS::isAuthenticated().

Returns
  the login name of the authenticated user

Definition at line 1393 of file CAS.php.

References phpCAS\_validateClientExists().

## ◆ getServiceURL()

static phpCAS::getServiceURL | ( |  | ) |
| static

Get the URL that is set as the CAS service parameter.

Returns
  string Service Url

Definition at line 1585 of file CAS.php.

References phpCAS\_validateProxyExists().

## ◆ getUser()

static phpCAS::getUser | ( |  | ) |
| static

This method returns the CAS user's login name.

Returns
  string the login name of the authenticated user

Warning
  should only be called after phpCAS::forceAuthentication() or phpCAS::checkAuthentication().

Examples:
  example_advanced_saml11.php, example_lang.php, example_service.php, and example_service_POST.php.

Definition at line 1175 of file CAS.php.

References phpCAS\_validateClientExists(), and phpCAS\error().

## ◆ handleLogoutRequests()

static phpCAS::handleLogoutRequests | ( |  | $check_client = `true`,
|  |  | $allowed_clients = `false`
| ) |  |
| static

Handle logout requests.

Parameters

  bool | $check_client | additional safety check
  array | $allowed_clients | array of allowed clients

Returns
  void

Examples:
  example_advanced_saml11.php, and example_logout.php.

Definition at line 1272 of file CAS.php.

References phpCAS\_validateClientExists().

## ◆ hasAttribute()

static phpCAS::hasAttribute | ( |  | $key | ) |
| static

Answer true if an attribute exists for the authenticated user.

Parameters

  string | $key | attribute name

Returns
  bool

Warning
  should only be called after phpCAS::forceAuthentication() or phpCAS::checkAuthentication().

Definition at line 1233 of file CAS.php.

References phpCAS\_validateClientExists(), and phpCAS\error().

## ◆ hasAttributes()

static phpCAS::hasAttributes | ( |  | ) |
| static

Answer true if there are attributes for the authenticated user.

Warning
  should only be called after phpCAS::forceAuthentication() or phpCAS::checkAuthentication().

Returns
  bool

Definition at line 1213 of file CAS.php.

References phpCAS\_validateClientExists(), and phpCAS\error().

## ◆ isAuthenticated()

static phpCAS::isAuthenticated | ( |  | ) |
| static

This method is called to check if the user is authenticated (previously or by tickets given in the URL).

Returns
  true when the user is authenticated.

Definition at line 1139 of file CAS.php.

References $auth, phpCAS\_validateClientExists(), phpCAS\traceBegin(), and phpCAS\traceEnd().

## ◆ isSessionAuthenticated()

static phpCAS::isSessionAuthenticated | ( |  | ) |
| static

Checks whether authenticated based on $_SESSION. Useful to avoid server calls.

Returns
  bool true if authenticated, false otherwise.

Since
  0.4.22 by Brendan Arnold

Definition at line 1161 of file CAS.php.

References phpCAS\_validateClientExists().

## ◆ logout()

static phpCAS::logout | ( |  | $params = `""` | ) |
| static

This method is used to logout from CAS.

Parameters

  string | $params | an array that contains the optional url and service parameters that will be passed to the CAS server

Returns
  void

Examples:
  example_advanced_saml11.php, example_custom_urls.php, example_gateway.php, and example_simple.php.

Definition at line 1430 of file CAS.php.

References phpCAS\_validateClientExists(), phpCAS\error(), phpCAS\traceBegin(), and phpCAS\traceEnd().

## ◆ logoutWithRedirectService()

static phpCAS::logoutWithRedirectService | ( |  | $service | ) |
| static

This method is used to logout from CAS. Halts by redirecting to the CAS server.

Parameters

  string | $service | a URL that will be transmitted to the CAS server

Returns
  void

Definition at line 1463 of file CAS.php.

References phpCAS\_validateClientExists(), phpCAS\error(), phpCAS\traceBegin(), and phpCAS\traceEnd().

## ◆ logoutWithRedirectServiceAndUrl()

static phpCAS::logoutWithRedirectServiceAndUrl | ( |  | $service,
|  |  | $url
| ) |  |
| static

This method is used to logout from CAS. Halts by redirecting to the CAS server.

Parameters

  string | $service | a URL that will be transmitted to the CAS server
  string | $url | a URL that will be transmitted to the CAS server

Returns
  void

Deprecated:
  The url parameter has been removed from the CAS server as of version 3.3.5.1

Definition at line 1513 of file CAS.php.

References phpCAS\_validateClientExists(), phpCAS\error(), phpCAS\traceBegin(), and phpCAS\traceEnd().

## ◆ logoutWithUrl()

static phpCAS::logoutWithUrl | ( |  | $url | ) |
| static

This method is used to logout from CAS. Halts by redirecting to the CAS server.

Parameters

  string | $url | a URL that will be transmitted to the CAS server

Returns
  void

Deprecated:
  The url parameter has been removed from the CAS server as of version 3.3.5.1

Definition at line 1486 of file CAS.php.

References phpCAS\error(), phpCAS\traceBegin(), and phpCAS\traceEnd().

## ◆ renewAuthentication()

static phpCAS::renewAuthentication | ( |  | ) |
| static

This method is called to renew the authentication.

Returns
  void

Definition at line 1119 of file CAS.php.

References $auth, phpCAS\_validateClientExists(), phpCAS\traceBegin(), and phpCAS\traceEnd().

## ◆ retrievePT()

static phpCAS::retrievePT | ( |  | $target_service,
|  | & | $err_code,
|  | & | $err_msg
| ) |  |
| static

Retrieve a Proxy Ticket from the CAS server.

Parameters

  string | $target_service | Url string of service to proxy
  string | &$err_code | error code
  string | &$err_msg | error message

Returns
  string Proxy Ticket

Definition at line 1600 of file CAS.php.

References phpCAS\_validateProxyExists(), and phpCAS\error().

## ◆ setCacheTimesForAuthRecheck()

static phpCAS::setCacheTimesForAuthRecheck | ( |  | $n | ) |
| static

Set the times authentication will be cached before really accessing the CAS server in gateway mode:

- -1: check only once, and then never again (until you pree login)
- 0: always check
- n: check every "n" time

Parameters

  int | $n | an integer.

Returns
  void

Definition at line 986 of file CAS.php.

References phpCAS\_validateClientExists(), and phpCAS\error().

## ◆ setCasAttributeParserCallback()

static phpCAS::setCasAttributeParserCallback | ( |  | $function,
|  | array | $additionalArgs = `array()`
| ) |  |
| static

Set a callback function to be run when receiving CAS attributes

The callback function will be passed an $success_elements payload of the response () as its first parameter.

Parameters

  string | $function | Callback function
  array | $additionalArgs | optional array of arguments

Returns
  void

Definition at line 1009 of file CAS.php.

References phpCAS\_validateClientExists().

## ◆ setCasServerCACert()

static phpCAS::setCasServerCACert | ( |  | $cert,
|  |  | $validate_cn = `true`
| ) |  |
| static

Set the certificate of the CAS server CA and if the CN should be properly verified.

Parameters

  string | $cert | CA certificate file name
  bool | $validate_cn | Validate CN in certificate (default true)

Returns
  void

Examples:
  example_advanced_saml11.php.

Definition at line 1620 of file CAS.php.

References phpCAS\_validateClientExists(), phpCAS\error(), phpCAS\traceBegin(), and phpCAS\traceEnd().

## ◆ setFixedCallbackURL()

static phpCAS::setFixedCallbackURL | ( |  | $url = `''` | ) |
| static

Set the fixed URL that will be used by the CAS server to transmit the PGT. When this method is not called, a phpCAS script uses its own URL for the callback.

Parameters

  string | $url | the URL

Returns
  void

Definition at line 1544 of file CAS.php.

References phpCAS\_validateProxyExists(), phpCAS\error(), phpCAS\traceBegin(), and phpCAS\traceEnd().

## ◆ setFixedServiceURL()

static phpCAS::setFixedServiceURL | ( |  | $url | ) |
| static

Set the fixed URL that will be set as the CAS service parameter. When this method is not called, a phpCAS script uses its own URL.

Parameters

  string | $url | the URL

Returns
  void

Definition at line 1566 of file CAS.php.

References phpCAS\_validateProxyExists(), phpCAS\error(), phpCAS\traceBegin(), and phpCAS\traceEnd().

## ◆ setNoCasServerValidation()

static phpCAS::setNoCasServerValidation | ( |  | ) |
| static

Set no SSL validation for the CAS server.

Returns
  void

Examples:
  example_custom_urls.php, example_gateway.php, example_html.php, example_lang.php, example_logout.php, example_pgt_storage_db.php, example_pgt_storage_file.php, example_proxy_GET.php, example_proxy_POST.php, example_proxy_serviceWeb.php, example_proxy_serviceWeb_chaining.php, example_service.php, example_service_POST.php, example_service_that_proxies.php, and example_simple.php.

Definition at line 1639 of file CAS.php.

References phpCAS\_validateClientExists(), phpCAS\trace(), phpCAS\traceBegin(), and phpCAS\traceEnd().

## ◆ setNoClearTicketsFromUrl()

static phpCAS::setNoClearTicketsFromUrl | ( |  | ) |
| static

Disable the removal of a CAS-Ticket from the URL when authenticating DISABLING POSES A SECURITY RISK: We normally remove the ticket by an additional redirect as a security precaution to prevent a ticket in the HTTP_REFERRER or be carried over in the URL parameter

Returns
  void

Definition at line 1659 of file CAS.php.

References phpCAS\_validateClientExists(), phpCAS\traceBegin(), and phpCAS\traceEnd().

## ◆ setPostAuthenticateCallback()

static phpCAS::setPostAuthenticateCallback | ( |  | $function,
|  | array | $additionalArgs = `array()`
| ) |  |
| static

Set a callback function to be run when a user authenticates.

The callback function will be passed a $logoutTicket as its first parameter, followed by any $additionalArgs you pass. The $logoutTicket parameter is an opaque string that can be used to map the session-id to logout request in order to support single-signout in applications that manage their own sessions (rather than letting phpCAS start the session).

phpCAS::forceAuthentication() will always exit and forward client unless they are already authenticated. To perform an action at the moment the user logs in (such as registering an account, performing logging, etc), register a callback function here.

Parameters

  string | $function | Callback function
  array | $additionalArgs | optional array of arguments

Returns
  void

Definition at line 1035 of file CAS.php.

References phpCAS\_validateClientExists().

## ◆ setServerLoginURL()

static phpCAS::setServerLoginURL | ( |  | $url = `''` | ) |
| static

Set the login URL of the CAS server.

Parameters

  string | $url | the login URL

Returns
  void

Since
  0.4.21 by Wyman Chan

Definition at line 1300 of file CAS.php.

References phpCAS\_validateClientExists(), phpCAS\error(), phpCAS\traceBegin(), and phpCAS\traceEnd().

## ◆ setServerLogoutURL()

static phpCAS::setServerLogoutURL | ( |  | $url = `''` | ) |
| static

Set the logout URL of the CAS server.

Parameters

  string | $url | the logout URL

Returns
  void

Since
  0.4.21 by Wyman Chan

Definition at line 1408 of file CAS.php.

References phpCAS\_validateClientExists(), phpCAS\error(), phpCAS\traceBegin(), and phpCAS\traceEnd().

## ◆ setServerProxyValidateURL()

static phpCAS::setServerProxyValidateURL | ( |  | $url = `''` | ) |
| static

Set the proxyValidate URL of the CAS server. Used for all CAS versions of proxy URL validations Examples: CAS 1.0 http://www.exemple.com/ CAS 2.0 http://www.exemple.com/proxyValidate CAS 3.0 http://www.exemple.com/p3/proxyValidate

Parameters

  string | $url | the proxyValidate URL

Returns
  void

Examples:
  example_custom_urls.php.

Definition at line 1352 of file CAS.php.

References phpCAS\_validateClientExists(), phpCAS\error(), phpCAS\traceBegin(), and phpCAS\traceEnd().

## ◆ setServerSamlValidateURL()

static phpCAS::setServerSamlValidateURL | ( |  | $url = `''` | ) |
| static

Set the samlValidate URL of the CAS server.

Parameters

  string | $url | the samlValidate URL

Returns
  void

Definition at line 1373 of file CAS.php.

References phpCAS\_validateClientExists(), phpCAS\error(), phpCAS\traceBegin(), and phpCAS\traceEnd().

## ◆ setServerServiceValidateURL()

static phpCAS::setServerServiceValidateURL | ( |  | $url = `''` | ) |
| static

Set the serviceValidate URL of the CAS server. Used for all CAS versions of URL validations. Examples: CAS 1.0 http://www.exemple.com/validate CAS 2.0 http://www.exemple.com/validateURL CAS 3.0 http://www.exemple.com/p3/serviceValidate

Parameters

  string | $url | the serviceValidate URL

Returns
  void

Definition at line 1326 of file CAS.php.

References phpCAS\_validateClientExists(), phpCAS\error(), phpCAS\traceBegin(), and phpCAS\traceEnd().

## ◆ setSingleSignoutCallback()

static phpCAS::setSingleSignoutCallback | ( |  | $function,
|  | array | $additionalArgs = `array()`
| ) |  |
| static

Set a callback function to be run when a single-signout request is received. The callback function will be passed a $logoutTicket as its first parameter, followed by any $additionalArgs you pass. The $logoutTicket parameter is an opaque string that can be used to map a session-id to the logout request in order to support single-signout in applications that manage their own sessions (rather than letting phpCAS start and destroy the session).

Parameters

  string | $function | Callback function
  array | $additionalArgs | optional array of arguments

Returns
  void

Definition at line 1056 of file CAS.php.

References phpCAS\_validateClientExists().