root / drupal7 / sites / all / modules / cas / cas_server.api.php @ ba09eb79
1 | 85ad3d82 | Assos Assos | <?php
|
---|---|---|---|
2 | |||
3 | /**
|
||
4 | * @file
|
||
5 | * Documentation for CAS Server API.
|
||
6 | */
|
||
7 | |||
8 | /**
|
||
9 | * Return additional CAS attributes when acting as a CAS server.
|
||
10 | *
|
||
11 | * This hook allows modules to add additional CAS attributes to the basic
|
||
12 | * response by the CAS Server module.
|
||
13 | *
|
||
14 | * @param $account
|
||
15 | * The user being logged in.
|
||
16 | * @param $service
|
||
17 | * The service URL of the site the user is logging in to.
|
||
18 | * @param $ticket
|
||
19 | * The login ticket the user provided.
|
||
20 | *
|
||
21 | * @return
|
||
22 | * An associative array of CAS attributes for the user.
|
||
23 | *
|
||
24 | * @see hook_cas_server_user_attributes_alter()
|
||
25 | */
|
||
26 | function hook_cas_server_user_attributes($account, $service, $ticket) { |
||
27 | $attributes = array(); |
||
28 | |||
29 | // Attributes can be single valued...
|
||
30 | $attributes['color'] = 'blue'; |
||
31 | |||
32 | // ... or multi-valued.
|
||
33 | $attributes['friends'] = array('dries', 'webchick'); |
||
34 | |||
35 | // Or change the response based upon the server.
|
||
36 | a2baadd1 | Assos Assos | if (preg_match("@^http://apple.com/@", $service)) { |
37 | 85ad3d82 | Assos Assos | // This data should not be confidential as the service URL is directly
|
38 | // supplied by the user and is in no way validated.
|
||
39 | $attributes['friends'] += 'sjobs'; |
||
40 | } |
||
41 | |||
42 | return $attributes; |
||
43 | } |
||
44 | |||
45 | /**
|
||
46 | * Alter additional CAS attributes to return when a user is authenticated.
|
||
47 | *
|
||
48 | * @param $attributes
|
||
49 | * CAS attributes, as constructed by hook_cas_server_user_attributes().
|
||
50 | * @param $account
|
||
51 | * The user being logged in.
|
||
52 | * @param $context
|
||
53 | * An associative array containing the following key-value pairs, matching the
|
||
54 | * arguments received by hook_cas_server_user_attributes():
|
||
55 | * - "service": The service URL of the site the user is logging in to.
|
||
56 | * - "ticket": The login ticket the user provided.
|
||
57 | *
|
||
58 | * @see hook_cas_server_user_attributes()
|
||
59 | */
|
||
60 | function hook_cas_server_user_attributes_alter(&$attributes, $account, $context) { |
||
61 | //...
|
||
62 | } |