Révision a2baadd1
Ajouté par Assos Assos il y a environ 10 ans
drupal7/sites/all/modules/cas/tests/cas_test.module | ||
---|---|---|
103 | 103 |
|
104 | 104 |
if ($cas_user) { |
105 | 105 |
if (!is_array($cas_user)) { |
106 |
$cas_user = array('name' => $cas_user); |
|
106 |
$cas_user = array('name' => $cas_user, 'attributes' => array());
|
|
107 | 107 |
} |
108 | 108 |
// Generate a ticket and redirect to the service URL with the login ticket. |
109 | 109 |
$ticket = _cas_test_ticket_generate($service, $cas_user); |
... | ... | |
128 | 128 |
* Validate a ticket using the CAS 1.x protocol. |
129 | 129 |
*/ |
130 | 130 |
function cas_test_validate() { |
131 |
// Prevent this page from being cached. |
|
132 |
drupal_page_is_cacheable(FALSE); |
|
133 |
|
|
134 |
// Set content type. |
|
135 |
drupal_add_http_header('Content-Type', 'text/plain; charset=utf-8'); |
|
136 |
|
|
131 | 137 |
//Obtain the ticket from the url and validate it. |
132 | 138 |
$ticket = $_GET['ticket']; |
133 | 139 |
$service = $_GET['service']; |
... | ... | |
148 | 154 |
* Validate a ticket using the CAS 2.0 protocol. |
149 | 155 |
*/ |
150 | 156 |
function cas_test_service_validate() { |
157 |
// Prevent this page from being cached. |
|
158 |
drupal_page_is_cacheable(FALSE); |
|
159 |
|
|
160 |
// Set content type. |
|
161 |
drupal_add_http_header('Content-Type', 'text/xml; charset=utf-8'); |
|
162 |
|
|
151 | 163 |
$ticket = $_GET['ticket']; |
152 | 164 |
$service = $_GET['service']; |
153 | 165 |
|
154 |
header('Content-type:', 'text/xml'); |
|
155 | 166 |
if ($cas_user = _cas_test_ticket_validate($service, $ticket)) { |
156 | 167 |
print theme('cas_service_validate_success', $cas_user); |
157 | 168 |
} |
... | ... | |
234 | 245 |
* |
235 | 246 |
* @param $cas_user |
236 | 247 |
*/ |
237 |
function cas_test_single_sign_out($cas_name) { |
|
248 |
function cas_test_single_sign_out($cas_name, $double_encode=FALSE) {
|
|
238 | 249 |
$sso = variable_get('cas_test_sso', array()); |
239 | 250 |
foreach ($sso[$cas_name] as $service => $tickets) { |
240 | 251 |
foreach ($tickets as $ticket) { |
... | ... | |
243 | 254 |
'logoutRequest' => t("<samlp:LogoutRequest ID=\"!id\" Version=\"2.0\" IssueInstant=\"!time\">\n<saml:NameID>@NOT_USED@</saml:NameID>\n<samlp:SessionIndex>!ticket</samlp:SessionIndex>\n</samlp:LogoutRequest>", array('!id' => user_password(10), '!time' => time(), '!ticket' => $ticket)), |
244 | 255 |
); |
245 | 256 |
|
257 |
if ($double_encode) { |
|
258 |
// Certain CAS servers urlencode the logoutRequest. |
|
259 |
$data['logoutRequest'] = urlencode($data['logoutRequest']); |
|
260 |
} |
|
261 |
|
|
246 | 262 |
// Sign out the user. |
247 | 263 |
$options = array( |
248 | 264 |
'method' => 'POST', |
Formats disponibles : Unified diff
Weekly update of contrib modules