Skip to content
Snippets Groups Projects
Commit 773fa85a authored by Mads Freek Petersen's avatar Mads Freek Petersen
Browse files

Added support for attributes in <cas:serviceResponse>:

Need to be enabled in config/module_casserver.php with:

'attributes' => TRUE,

The 'schema' is:

<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
  <cas:authenticationSuccess>
    <cas:user>xxx</cas:user>
    <cas:attributes>
      <cas:foo>bar</cas:foo>
      <cas:foo>baz</cas:foo>
    </cas:attributes>
  </cas:authenticationSuccess>
</cas:serviceResponse>

where foo is the attribute name and bar,baz are the values.


git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1464 44740490-163a-0410-bde0-09ae8108e29a
parent 20317dc1
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,7 @@ $config = array ( ...@@ -18,6 +18,7 @@ $config = array (
'ticketcache' => 'ticketcache', 'ticketcache' => 'ticketcache',
'attrname' => 'mail', // 'eduPersonPrincipalName', 'attrname' => 'mail', // 'eduPersonPrincipalName',
#'attributes' => TRUE, // enable transfer of attributes
); );
......
...@@ -37,9 +37,10 @@ try { ...@@ -37,9 +37,10 @@ try {
$ticketcontent = retrieveTicket($ticket, $path); $ticketcontent = retrieveTicket($ticket, $path);
$usernamefield = $casconfig->getValue('attrname', 'eduPersonPrincipalName'); $usernamefield = $casconfig->getValue('attrname', 'eduPersonPrincipalName');
$dosendattributes = $casconfig->getValue('attributes', FALSE);;
if (array_key_exists($usernamefield, $ticketcontent)) { if (array_key_exists($usernamefield, $ticketcontent)) {
returnResponse('YES', $ticketcontent[$usernamefield][0]); returnResponse('YES', $ticketcontent[$usernamefield][0], $dosendattributes ? $ticketcontent : array());
} else { } else {
returnResponse('NO'); returnResponse('NO');
} }
...@@ -49,12 +50,21 @@ try { ...@@ -49,12 +50,21 @@ try {
returnResponse('NO', $e->getMessage()); returnResponse('NO', $e->getMessage());
} }
function returnResponse($value, $content = '') { function returnResponse($value, $content = '', $attributes = array()) {
if ($value === 'YES') { if ($value === 'YES') {
$attributesxml = "";
foreach ($attributes as $attributename => $attributelist) {
$attr = htmlentities($attributename);
foreach ($attributelist as $attributevalue) {
$attributesxml .= "<cas:$attr>" . htmlentities($attributevalue) . "</cas:$attr>";
}
}
if (sizeof($attributes)) $attributesxml = '<cas:attributes>' . $attributesxml . '</cas:attributes>';
echo '<cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas"> echo '<cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
<cas:authenticationSuccess> <cas:authenticationSuccess>
<cas:user>' . htmlentities($content) . '</cas:user> <cas:user>' . htmlentities($content) . '</cas:user>' .
</cas:authenticationSuccess> $attributesxml .
'</cas:authenticationSuccess>
</cas:serviceResponse>'; </cas:serviceResponse>';
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment