11# Using the CAS authentication source with SimpleSAMLphp
22
3- This is completely based on the original cas authentication,
4- the only difference is this is authentication module and not a script.
3+ This is completely based on the original CAS authentication;
4+ the only difference is this is an authentication module, not a script.
55
66## Setting up the CAS authentication module
77
8- Adding an authentication source
8+ ### Adding an authentication source
9+
10+ In new deployments using ldap v2.5+, configure LDAP as a separate authsource in the ldap module and reference it by id from CAS.
911
1012Example authsource.php:
1113
1214``` php
1315'example-cas' => [
1416 'cas:CAS',
1517 'cas' => [
16- 'login' => 'https://cas.example.com/login',
17- 'validate' => 'https://cas.example.com/validate',
18- 'logout' => 'https://cas.example.com/logout'
18+ 'login' => 'https://cas.example.com/login',
19+ 'validate' => 'https://cas.example.com/validate', // CAS v2
20+ 'logout' => 'https://cas.example.com/logout',
1921 ],
2022 'ldap' => [
21- 'servers' => 'ldaps://ldaps.example.be:636/',
22- 'enable_tls' => true,
23- 'searchbase' => 'ou=people,dc=org,dc=com',
24- 'searchattributes' => 'uid',
25- 'attributes' => ['uid','cn'],
26- 'priv_user_dn' => 'cn=simplesamlphp,ou=applications,dc=org,dc=com',
27- 'priv_user_pw' => 'password',
23+ 'authsource' => 'ldap-backend',
2824 ],
2925],
26+
27+ // LDAP authsource (dnpattern mode)
28+ 'ldap-backend' => [
29+ 'ldap:Ldap',
30+
31+ // REQUIRED in v2.5: one or more LDAP URLs
32+ 'connection_string' => 'ldaps://ldap.example.com',
33+
34+ // Optional extras
35+ 'encryption' => 'ssl',
36+ 'version' => 3,
37+ 'options' => [
38+ 'network_timeout' => 3,
39+ 'referrals' => false,
40+ ],
41+
42+ // Dnpattern mode (no search)
43+ 'dnpattern' => 'uid=%username%,cn=people,dc=example,dc=com',
44+ 'search.enable' => false,
45+
46+ // 'attributes' => ['uid', 'cn', 'mail'],
47+ ]
3048```
3149
50+ OR:
51+
52+ ``` php
53+ 'example-cas' => [
54+ 'cas:CAS',
55+ 'cas' => [
56+ 'login' => 'https://cas.example.com/login',
57+ 'serviceValidate' => 'https://cas.example.com/serviceValidate', // CAS v3
58+ 'logout' => 'https://cas.example.com/logout',
59+ ],
60+ 'ldap' => [
61+ 'authsource' => 'ldap-backend',
62+ ],
63+ ],
64+
65+ // LDAP authsource (search mode)
66+ 'ldap-backend' => [
67+ 'ldap:Ldap',
68+ 'connection_string' => 'ldaps://ldap1.example.com ldaps://ldap2.example.com',
69+ 'search' => [
70+ 'username' => 'cn=simplesamlphp,ou=apps,dc=example,dc=com',
71+ 'password' => 'secret',
72+ 'base' => ['ou=people,dc=example,dc=com'],
73+ 'filter' => '(uid=%username%)',
74+ 'scope' => 'sub',
75+ ],
76+ 'attributes' => ['*'],
77+ 'attributes.binary' => ['jpegPhoto'],
78+ 'timeout' => 3,
79+ 'options' => [
80+ 'network_timeout' => 3,
81+ 'referrals' => false,
82+ ],
83+ ],
84+ ```
85+
86+
3287## Querying Attributes
3388
3489CAS v3 (since 2017) supports querying attributes. Those have to be published
@@ -39,7 +94,7 @@ To get them, call `serviceValidate`, either directly:
3994
4095``` php
4196'cas' => [
42- 'serviceValidate' => 'https://cas.example.com/serviceValidate',
97+ 'serviceValidate' => 'https://cas.example.com/serviceValidate', // CAS v3
4398]
4499```
45100
@@ -62,18 +117,18 @@ You can opt in to Slate support:
62117 'serviceValidate' => 'https://cas.example.com/p3/serviceValidate',
63118 // Enable Slate support (optional)
64119 'slate.enabled' => true,
65-
120+
66121 // Optional XPath-based attribute mappings
67122 'attributes' => [
68123 // Standard CAS attributes
69- 'uid' => 'cas:user',
70- 'mail' => 'cas:attributes/cas:mail',
71-
124+ 'uid' => 'cas:user',
125+ 'mail' => 'cas:attributes/cas:mail',
126+
72127 // Slate namespaced attributes inside cas:attributes
73128 'slate_person' => 'cas:attributes/slate:person',
74129 'slate_round' => 'cas:attributes/slate:round',
75130 'slate_ref' => 'cas:attributes/slate:ref',
76-
131+
77132 // Some deployments also place vendor elements at the top level
78133 'slate_person_top' => '/cas:serviceResponse/cas:authenticationSuccess/slate:person',
79134 ],
@@ -105,10 +160,10 @@ for each value:
105160``` php
106161'cas' => [
107162 'attributes' => [
108- 'uid' => 'cas:user',
109- 'sn' => 'cas:attributes/cas:sn',
163+ 'uid' => 'cas:user',
164+ 'sn' => 'cas:attributes/cas:sn',
110165 'givenName' => 'cas:attributes/cas:firstname',
111- 'mail' => 'cas:attributes/cas:mail',
166+ 'mail' => 'cas:attributes/cas:mail',
112167 ],
113168],
114169```
@@ -131,3 +186,9 @@ set `ldap` to `null`:
131186 'ldap' => null,
132187]
133188```
189+
190+ ### Troubleshooting
191+
192+ - Mismatch between validate (v2) and serviceValidate (v3): ensure you use the correct endpoint for your CAS server.
193+ - Attribute mappings: verify XPath keys match your CAS response (case‑sensitive).
194+ - LDAP connection issues: confirm connection_string, credentials, and base DN; consider increasing ` network_timeout ` while testing.
0 commit comments