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',
21+ ],
22+ 'ldap' => [
23+ 'authsource' => 'ldap-backend',
24+ ],
25+ ],
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+ ]
48+ ```
49+
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',
1959 ],
2060 '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',
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,
2882 ],
2983],
3084```
@@ -39,7 +93,7 @@ To get them, call `serviceValidate`, either directly:
3993
4094``` php
4195'cas' => [
42- 'serviceValidate' => 'https://cas.example.com/serviceValidate',
96+ 'serviceValidate' => 'https://cas.example.com/serviceValidate', // CAS v3
4397]
4498```
4599
@@ -62,18 +116,18 @@ You can opt in to Slate support:
62116 'serviceValidate' => 'https://cas.example.com/p3/serviceValidate',
63117 // Enable Slate support (optional)
64118 'slate.enabled' => true,
65-
119+
66120 // Optional XPath-based attribute mappings
67121 'attributes' => [
68122 // Standard CAS attributes
69- 'uid' => 'cas:user',
70- 'mail' => 'cas:attributes/cas:mail',
71-
123+ 'uid' => 'cas:user',
124+ 'mail' => 'cas:attributes/cas:mail',
125+
72126 // Slate namespaced attributes inside cas:attributes
73127 'slate_person' => 'cas:attributes/slate:person',
74128 'slate_round' => 'cas:attributes/slate:round',
75129 'slate_ref' => 'cas:attributes/slate:ref',
76-
130+
77131 // Some deployments also place vendor elements at the top level
78132 'slate_person_top' => '/cas:serviceResponse/cas:authenticationSuccess/slate:person',
79133 ],
@@ -105,10 +159,10 @@ for each value:
105159``` php
106160'cas' => [
107161 'attributes' => [
108- 'uid' => 'cas:user',
109- 'sn' => 'cas:attributes/cas:sn',
162+ 'uid' => 'cas:user',
163+ 'sn' => 'cas:attributes/cas:sn',
110164 'givenName' => 'cas:attributes/cas:firstname',
111- 'mail' => 'cas:attributes/cas:mail',
165+ 'mail' => 'cas:attributes/cas:mail',
112166 ],
113167],
114168```
@@ -131,3 +185,9 @@ set `ldap` to `null`:
131185 'ldap' => null,
132186]
133187```
188+
189+ ### Troubleshooting
190+
191+ - Mismatch between validate (v2) and serviceValidate (v3): ensure you use the correct endpoint for your CAS server.
192+ - Attribute mappings: verify XPath keys match your CAS response (case‑sensitive).
193+ - LDAP connection issues: confirm connection_string, credentials, and base DN; consider increasing ` network_timeout ` while testing.
0 commit comments