PHP 클래스 phpCAS

파일 보기 프로젝트 열기: jasig/phpcas 1 사용 예제들

공개 메소드들

메소드 설명
addRebroadcastHeader ( String $header ) : void This method is used to add header parameters when rebroadcasting pgtIou/pgtId or logoutRequest.
addRebroadcastNode ( string $rebroadcastNodeUrl ) : void Add a pgtIou/pgtId and logoutRequest rebroadcast node.
allowProxyChain ( CAS_ProxyChain_Interface $proxy_chain ) : void If you want your service to be proxied you have to enable it (default disabled) and define an accepable list of proxies that are allowed to proxy your service.
checkAuthentication ( ) : true 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)
client ( string $server_version, string $server_hostname, string $server_port, string $server_uri, boolean $changeSessionID = true ) : a phpCAS client initializer.
error ( string $msg ) : void This method is used by interface methods to print an error and where the function was originally called from.
forceAuthentication ( ) : boolean 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.
getAttribute ( string $key ) : mixed Answer an attribute for the authenticated user.
getAttributes ( ) : array Answer attributes about the authenticated user.
getProxiedService ( string $type ) : CAS_ProxiedService Answer a proxy-authenticated service handler.
getProxies ( ) : array Answer an array of proxies that are sitting in front of this application.
getServerLoginURL ( ) : the This method returns the URL to be used to login.
getServerLogoutURL ( ) : the This method returns the URL to be used to login.
getServiceURL ( ) : string Get the URL that is set as the CAS service parameter.
getUser ( ) : string This method returns the CAS user's login name.
getVerbose ( ) : boot Show is verbose mode is on
getVersion ( ) : the This method returns the phpCAS version.
handleLogoutRequests ( boolean $check_client = true, array $allowed_clients = false ) : void Handle logout requests.
hasAttribute ( string $key ) : boolean Answer true if an attribute exists for the authenticated user.
hasAttributes ( ) : boolean Answer true if there are attributes for the authenticated user.
initializeProxiedService ( CAS_ProxiedService $proxiedService ) : void Initialize a proxied-service handler with the proxy-ticket it should use.
isAuthenticated ( ) : true This method is called to check if the user is authenticated (previously or by tickets given in the URL).
isInitialized ( ) : boolean Answer whether or not the client or proxy has been initialized
isSessionAuthenticated ( ) : boolean Checks whether authenticated based on $_SESSION. Useful to avoid server calls.
log ( string $str ) : void Logs a string in debug mode.
logout ( string $params = "" ) : void This method is used to logout from CAS.
logoutWithRedirectService ( string $service ) : void This method is used to logout from CAS. Halts by redirecting to the CAS server.
logoutWithRedirectServiceAndUrl ( string $service, string $url ) : void This method is used to logout from CAS. Halts by redirecting to the CAS server.
logoutWithUrl ( string $url ) : void This method is used to logout from CAS. Halts by redirecting to the CAS server.
proxy ( string $server_version, string $server_hostname, string $server_port, string $server_uri, boolean $changeSessionID = true ) : a phpCAS proxy initializer.
renewAuthentication ( ) : void This method is called to renew the authentication.
retrievePT ( string $target_service, &$err_code, &$err_msg ) : string Retrieve a Proxy Ticket from the CAS server.
serviceMail ( string $url, string $service, string $flags, &$err_code, &$err_msg, &$pt ) : object This method is used to access an IMAP/POP3/NNTP service.
serviceWeb ( string $url, &$err_code, &$output ) : boolean This method is used to access an HTTP[S] service.
setCacheTimesForAuthRecheck ( integer $n ) : void 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
setCasAttributeParserCallback ( string $function, array $additionalArgs = [] ) : void Set a callback function to be run when receiving CAS attributes
setCasClient ( CAS_Client $client ) : void For testing purposes, use this method to set the client to a test double
setCasServerCACert ( string $cert, boolean $validate_cn = true ) : void Set the certificate of the CAS server CA and if the CN should be properly verified.
setDebug ( string $filename = '' ) : void Set/unset debug mode
setExtraCurlOption ( string $key, string $value ) : void Change CURL options.
setFixedCallbackURL ( string $url = '' ) : void 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.
setFixedServiceURL ( string $url ) : void 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.
setHTMLFooter ( string $footer ) : void This method sets the HTML footer used for all outputs.
setHTMLHeader ( string $header ) : void This method sets the HTML header used for all outputs.
setLang ( string $lang ) : void This method is used to set the language used by phpCAS.
setNoCasServerValidation ( ) : void Set no SSL validation for the CAS server.
setNoClearTicketsFromUrl ( ) : void 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
setPGTStorage ( CAS_PGTStorage $storage ) : void This method can be used to set a custom PGT storage object.
setPGTStorageDb ( string $dsn_or_pdo, string $username = '', string $password = '', string $table = '', string $driver_options = null ) : void This method is used to tell phpCAS to store the response of the CAS server to PGT requests in a database.
setPGTStorageFile ( string $path = '' ) : void This method is used to tell phpCAS to store the response of the CAS server to PGT requests onto the filesystem.
setPostAuthenticateCallback ( string $function, array $additionalArgs = [] ) : void Set a callback function to be run when a user authenticates.
setServerLoginURL ( string $url = '' ) : void Set the login URL of the CAS server.
setServerLogoutURL ( string $url = '' ) : void Set the logout URL of the CAS server.
setServerProxyValidateURL ( string $url = '' ) : void Set the proxyValidate URL of the CAS server.
setServerSamlValidateURL ( string $url = '' ) : void Set the samlValidate URL of the CAS server.
setServerServiceValidateURL ( string $url = '' ) : void Set the serviceValidate URL of the CAS server.
setSingleSignoutCallback ( string $function, array $additionalArgs = [] ) : void 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).
setVerbose ( boolean $verbose ) : void Enable verbose errors messages in the website output This is a security relevant since internal status info may leak an may help an attacker. Default is therefore false
trace ( string $str ) : void This method is used to log something in debug mode.
traceBegin ( ) : void This method is used to indicate the start of the execution of a function in debug mode.
traceEnd ( string $res = '' ) : void This method is used to indicate the end of the execution of a function in debug mode.
traceExit ( ) : void This method is used to indicate the end of the execution of the program

비공개 메소드들

메소드 설명
_validateClientExists ( ) : void Checks if a client already exists
_validateProxyExists ( ) : void Checks of a proxy client aready exists

메소드 상세

addRebroadcastHeader() 공개 정적인 메소드

This method is used to add header parameters when rebroadcasting pgtIou/pgtId or logoutRequest.
public static addRebroadcastHeader ( String $header ) : void
$header String Header to send when rebroadcasting.
리턴 void

addRebroadcastNode() 공개 정적인 메소드

Add a pgtIou/pgtId and logoutRequest rebroadcast node.
public static addRebroadcastNode ( string $rebroadcastNodeUrl ) : void
$rebroadcastNodeUrl string The rebroadcast node URL. Can be hostname or IP.
리턴 void

allowProxyChain() 공개 정적인 메소드

Add each allowed proxy definition object. For the normal CAS_ProxyChain class, the constructor takes an array of proxies to match. The list is in reverse just as seen from the service. Proxies have to be defined in reverse from the service to the user. If a user hits service A and gets proxied via B to service C the list of acceptable on C would be array(B,A). The definition of an individual proxy can be either a string or a regexp (preg_match is used) that will be matched against the proxy list supplied by the cas server when validating the proxy tickets. The strings are compared starting from the beginning and must fully match with the proxies in the list. Example: phpCAS::allowProxyChain(new CAS_ProxyChain(array( 'https://app.example.com/' ))); phpCAS::allowProxyChain(new CAS_ProxyChain(array( '/^https:\/\/app[0-9]\.example\.com\/rest\//', 'http://client.example.com/' ))); For quick testing or in certain production screnarios you might want to allow allow any other valid service to proxy your service. To do so, add the "Any" chain: phpcas::allowProxyChain(new CAS_ProxyChain_Any); THIS SETTING IS HOWEVER NOT RECOMMENDED FOR PRODUCTION AND HAS SECURITY IMPLICATIONS: YOU ARE ALLOWING ANY SERVICE TO ACT ON BEHALF OF A USER ON THIS SERVICE.
public static allowProxyChain ( CAS_ProxyChain_Interface $proxy_chain ) : void
$proxy_chain CAS_ProxyChain_Interface A proxy-chain that will be matched against the proxies requesting access
리턴 void

checkAuthentication() 공개 정적인 메소드

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)
public static checkAuthentication ( ) : true
리턴 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

client() 공개 정적인 메소드

phpCAS client initializer.
public static client ( string $server_version, string $server_hostname, string $server_port, string $server_uri, boolean $changeSessionID = true ) : a
$server_version string the version of the CAS server
$server_hostname string the hostname of the CAS server
$server_port string the port the CAS server is running on
$server_uri string the URI the CAS server is responding on
$changeSessionID boolean Allow phpCAS to change the session_id (Single Sign Out/handleLogoutRequests is based on that change)
리턴 a newly created CAS_Client object

error() 공개 정적인 메소드

This method is used by interface methods to print an error and where the function was originally called from.
public static error ( string $msg ) : void
$msg string the message to print
리턴 void

forceAuthentication() 공개 정적인 메소드

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.
public static forceAuthentication ( ) : boolean
리턴 boolean Authentication

getAttribute() 공개 정적인 메소드

Answer an attribute for the authenticated user.
public static getAttribute ( string $key ) : mixed
$key string attribute name
리턴 mixed string for a single value or an array if multiple values exist.

getAttributes() 공개 정적인 메소드

Answer attributes about the authenticated user.
public static getAttributes ( ) : array
리턴 array

getProxiedService() 공개 정적인 메소드

Answer a proxy-authenticated service handler.
public static getProxiedService ( string $type ) : CAS_ProxiedService
$type string The service type. One of PHPCAS_PROXIED_SERVICE_HTTP_GET; PHPCAS_PROXIED_SERVICE_HTTP_POST; PHPCAS_PROXIED_SERVICE_IMAP
리턴 CAS_ProxiedService

getProxies() 공개 정적인 메소드

This method will only return a non-empty array if we have received and validated a Proxy Ticket.
부터: 6/25/09
public static getProxies ( ) : array
리턴 array

getServerLoginURL() 공개 정적인 메소드

or phpCAS::isAuthenticated().
public static getServerLoginURL ( ) : the
리턴 the login name of the authenticated user

getServerLogoutURL() 공개 정적인 메소드

or phpCAS::isAuthenticated().
public static getServerLogoutURL ( ) : the
리턴 the login name of the authenticated user

getServiceURL() 공개 정적인 메소드

Get the URL that is set as the CAS service parameter.
public static getServiceURL ( ) : string
리턴 string Service Url

getUser() 공개 정적인 메소드

This method returns the CAS user's login name.
public static getUser ( ) : string
리턴 string the login name of the authenticated user

getVerbose() 공개 정적인 메소드

Show is verbose mode is on
public static getVerbose ( ) : boot
리턴 boot verbose

getVersion() 공개 정적인 메소드

This method returns the phpCAS version.
public static getVersion ( ) : the
리턴 the phpCAS version.

handleLogoutRequests() 공개 정적인 메소드

Handle logout requests.
public static handleLogoutRequests ( boolean $check_client = true, array $allowed_clients = false ) : void
$check_client boolean additional safety check
$allowed_clients array array of allowed clients
리턴 void

hasAttribute() 공개 정적인 메소드

Answer true if an attribute exists for the authenticated user.
public static hasAttribute ( string $key ) : boolean
$key string attribute name
리턴 boolean

hasAttributes() 공개 정적인 메소드

Answer true if there are attributes for the authenticated user.
public static hasAttributes ( ) : boolean
리턴 boolean

initializeProxiedService() 공개 정적인 메소드

Initialize a proxied-service handler with the proxy-ticket it should use.
public static initializeProxiedService ( CAS_ProxiedService $proxiedService ) : void
$proxiedService CAS_ProxiedService Proxied Service Handler
리턴 void

isAuthenticated() 공개 정적인 메소드

This method is called to check if the user is authenticated (previously or by tickets given in the URL).
public static isAuthenticated ( ) : true
리턴 true when the user is authenticated.

isInitialized() 공개 정적인 메소드

Answer whether or not the client or proxy has been initialized
public static isInitialized ( ) : boolean
리턴 boolean

isSessionAuthenticated() 공개 정적인 메소드

Checks whether authenticated based on $_SESSION. Useful to avoid server calls.
부터: 0.4.22 by Brendan Arnold
public static isSessionAuthenticated ( ) : boolean
리턴 boolean true if authenticated, false otherwise.

log() 공개 정적인 메소드

Logs a string in debug mode.
public static log ( string $str ) : void
$str string the string to write
리턴 void

logout() 공개 정적인 메소드

This method is used to logout from CAS.
public static logout ( string $params = "" ) : void
$params string an array that contains the optional url and service parameters that will be passed to the CAS server
리턴 void

logoutWithRedirectService() 공개 정적인 메소드

This method is used to logout from CAS. Halts by redirecting to the CAS server.
public static logoutWithRedirectService ( string $service ) : void
$service string a URL that will be transmitted to the CAS server
리턴 void

logoutWithRedirectServiceAndUrl() 공개 정적인 메소드

This method is used to logout from CAS. Halts by redirecting to the CAS server.
사용 중단: The url parameter has been removed from the CAS server as of version 3.3.5.1
public static logoutWithRedirectServiceAndUrl ( string $service, string $url ) : void
$service string a URL that will be transmitted to the CAS server
$url string a URL that will be transmitted to the CAS server
리턴 void

logoutWithUrl() 공개 정적인 메소드

This method is used to logout from CAS. Halts by redirecting to the CAS server.
사용 중단: The url parameter has been removed from the CAS server as of version 3.3.5.1
public static logoutWithUrl ( string $url ) : void
$url string a URL that will be transmitted to the CAS server
리턴 void

proxy() 공개 정적인 메소드

phpCAS proxy initializer.
public static proxy ( string $server_version, string $server_hostname, string $server_port, string $server_uri, boolean $changeSessionID = true ) : a
$server_version string the version of the CAS server
$server_hostname string the hostname of the CAS server
$server_port string the port the CAS server is running on
$server_uri string the URI the CAS server is responding on
$changeSessionID boolean Allow phpCAS to change the session_id (Single Sign Out/handleLogoutRequests is based on that change)
리턴 a newly created CAS_Client object

renewAuthentication() 공개 정적인 메소드

This method is called to renew the authentication.
public static renewAuthentication ( ) : void
리턴 void

retrievePT() 공개 정적인 메소드

Retrieve a Proxy Ticket from the CAS server.
public static retrievePT ( string $target_service, &$err_code, &$err_msg ) : string
$target_service string Url string of service to proxy
리턴 string Proxy Ticket

serviceMail() 공개 정적인 메소드

This method is used to access an IMAP/POP3/NNTP service.
public static serviceMail ( string $url, string $service, string $flags, &$err_code, &$err_msg, &$pt ) : object
$url string a string giving the URL of the service, including the mailing box for IMAP URLs, as accepted by imap_open().
$service string a string giving for CAS retrieve Proxy ticket
$flags string options given to imap_open().
리턴 object IMAP stream on success, false otherwise (in this later case, $err_code gives the reason why it failed and $err_msg contains an error message).

serviceWeb() 공개 정적인 메소드

This method is used to access an HTTP[S] service.
public static serviceWeb ( string $url, &$err_code, &$output ) : boolean
$url string the service to access.
리턴 boolean true on success, false otherwise (in this later case, $err_code gives the reason why it failed and $output contains an error message).

setCacheTimesForAuthRecheck() 공개 정적인 메소드

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
public static setCacheTimesForAuthRecheck ( integer $n ) : void
$n integer an integer.
리턴 void

setCasAttributeParserCallback() 공개 정적인 메소드

The callback function will be passed an $success_elements payload of the response (\DOMElement) as its first parameter.
public static setCasAttributeParserCallback ( string $function, array $additionalArgs = [] ) : void
$function string Callback function
$additionalArgs array optional array of arguments
리턴 void

setCasClient() 공개 정적인 메소드

For testing purposes, use this method to set the client to a test double
public static setCasClient ( CAS_Client $client ) : void
$client CAS_Client
리턴 void

setCasServerCACert() 공개 정적인 메소드

Set the certificate of the CAS server CA and if the CN should be properly verified.
public static setCasServerCACert ( string $cert, boolean $validate_cn = true ) : void
$cert string CA certificate file name
$validate_cn boolean Validate CN in certificate (default true)
리턴 void

setDebug() 공개 정적인 메소드

Set/unset debug mode
public static setDebug ( string $filename = '' ) : void
$filename string the name of the file used for logging, or false to stop debugging.
리턴 void

setExtraCurlOption() 공개 정적인 메소드

CURL is used to connect through HTTPS to CAS server
public static setExtraCurlOption ( string $key, string $value ) : void
$key string the option key
$value string the value to set
리턴 void

setFixedCallbackURL() 공개 정적인 메소드

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.
public static setFixedCallbackURL ( string $url = '' ) : void
$url string the URL
리턴 void

setFixedServiceURL() 공개 정적인 메소드

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.
public static setFixedServiceURL ( string $url ) : void
$url string the URL
리턴 void

setHTMLFooter() 공개 정적인 메소드

This method sets the HTML footer used for all outputs.
public static setHTMLFooter ( string $footer ) : void
$footer string the HTML footer.
리턴 void

setHTMLHeader() 공개 정적인 메소드

This method sets the HTML header used for all outputs.
public static setHTMLHeader ( string $header ) : void
$header string the HTML header.
리턴 void

setLang() 공개 정적인 메소드

This method is used to set the language used by phpCAS.
public static setLang ( string $lang ) : void
$lang string string representing the language.
리턴 void

setNoCasServerValidation() 공개 정적인 메소드

Set no SSL validation for the CAS server.
public static setNoCasServerValidation ( ) : void
리턴 void

setNoClearTicketsFromUrl() 공개 정적인 메소드

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
public static setNoClearTicketsFromUrl ( ) : void
리턴 void

setPGTStorage() 공개 정적인 메소드

This method can be used to set a custom PGT storage object.
public static setPGTStorage ( CAS_PGTStorage $storage ) : void
$storage CAS_PGTStorage a PGT storage object that inherits from the CAS_PGTStorage class
리턴 void

setPGTStorageDb() 공개 정적인 메소드

This method is used to tell phpCAS to store the response of the CAS server to PGT requests in a database.
public static setPGTStorageDb ( string $dsn_or_pdo, string $username = '', string $password = '', string $table = '', string $driver_options = null ) : void
$dsn_or_pdo string a dsn string to use for creating a PDO object or a PDO object
$username string the username to use when connecting to the database
$password string the password to use when connecting to the database
$table string the table to use for storing and retrieving PGT's
$driver_options string any driver options to use when connecting to the database
리턴 void

setPGTStorageFile() 공개 정적인 메소드

This method is used to tell phpCAS to store the response of the CAS server to PGT requests onto the filesystem.
public static setPGTStorageFile ( string $path = '' ) : void
$path string the path where the PGT's should be stored
리턴 void

setPostAuthenticateCallback() 공개 정적인 메소드

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.
public static setPostAuthenticateCallback ( string $function, array $additionalArgs = [] ) : void
$function string Callback function
$additionalArgs array optional array of arguments
리턴 void

setServerLoginURL() 공개 정적인 메소드

Set the login URL of the CAS server.
부터: 0.4.21 by Wyman Chan
public static setServerLoginURL ( string $url = '' ) : void
$url string the login URL
리턴 void

setServerLogoutURL() 공개 정적인 메소드

Set the logout URL of the CAS server.
부터: 0.4.21 by Wyman Chan
public static setServerLogoutURL ( string $url = '' ) : void
$url string the logout URL
리턴 void

setServerProxyValidateURL() 공개 정적인 메소드

Used for all CAS 2.0 validations
public static setServerProxyValidateURL ( string $url = '' ) : void
$url string the proxyValidate URL
리턴 void

setServerSamlValidateURL() 공개 정적인 메소드

Set the samlValidate URL of the CAS server.
public static setServerSamlValidateURL ( string $url = '' ) : void
$url string the samlValidate URL
리턴 void

setServerServiceValidateURL() 공개 정적인 메소드

Used only in CAS 1.0 validations
public static setServerServiceValidateURL ( string $url = '' ) : void
$url string the serviceValidate URL
리턴 void

setSingleSignoutCallback() 공개 정적인 메소드

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).
public static setSingleSignoutCallback ( string $function, array $additionalArgs = [] ) : void
$function string Callback function
$additionalArgs array optional array of arguments
리턴 void

setVerbose() 공개 정적인 메소드

Enable verbose errors messages in the website output This is a security relevant since internal status info may leak an may help an attacker. Default is therefore false
public static setVerbose ( boolean $verbose ) : void
$verbose boolean enable verbose output
리턴 void

trace() 공개 정적인 메소드

This method is used to log something in debug mode.
public static trace ( string $str ) : void
$str string string to log
리턴 void

traceBegin() 공개 정적인 메소드

This method is used to indicate the start of the execution of a function in debug mode.
public static traceBegin ( ) : void
리턴 void

traceEnd() 공개 정적인 메소드

This method is used to indicate the end of the execution of a function in debug mode.
public static traceEnd ( string $res = '' ) : void
$res string the result of the function
리턴 void

traceExit() 공개 정적인 메소드

This method is used to indicate the end of the execution of the program
public static traceExit ( ) : void
리턴 void